WebView[styleClass=root web-view]is already set as root of another scene
Я использую библиотеку WeaverFX, которая позволяет инъектить Javafx контекст внутрь SpringBoot контекста и также использую PDFViewr чтобы загружать PDF документы из массива байт в визуальное представление на сцене. Когда я пытаюсь сменить сцену в LibraryController (причем в первый раз PDF показывается нормально и никаких исключений не вызывается) я получаю исключение "WebView[styleClass=root web-view]is already set as root of another scene"
Ниже в LibraryController я прокомментировал как я пытаюсь установить сцену используя WeaverFX и PDFviewer, сначала вместе, а потом только используя PDFViewer
WeaverFX lib - https://github.com/rgielen/javafx-weaver
PDFViewer lib - https://github.com/Dansoftowner/PDFViewerFX
BaseController
import com.dansoftware.pdfdisplayer.PDFDisplayer;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
import net.rgielen.fxweaver.core.FxWeaver;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
public abstract class BaseController {
@Autowired private Stage stage;
public void setScene(Button button, String title, Class controller, FxWeaver fxWeaver) {
try {
button.getScene().getWindow().hide();
Parent root = (Parent) fxWeaver.loadView(controller);
stage.setScene(new Scene(root));
stage.setTitle(title);
stage.setResizable(false);
stage.show();
} catch (Exception e) {
log.error("Unexpected exception while setting scene " + e);
}
}
public void setScene(Hyperlink link, String title, Class controller, FxWeaver fxWeaver) {
try {
link.getScene().getWindow().hide();
Parent root = (Parent) fxWeaver.loadView(controller);
stage.setTitle(title);
stage.setResizable(false);
stage.setScene(new Scene(root));
stage.show();
} catch (Exception e) {
log.error("Unexpected exception while setting scene " + e);
}
}
public void setScene(String title, PDFDisplayer displayer, FxWeaver fxWeaver) {
try {
Parent root = (Parent) fxWeaver.loadView(displayer.toNode().getClass()); ---HERE I'M TRIED TO USE WEAVERFX+PDFVIEWER BUT GET NOSUCHBEANEXCEPTION
stage.setTitle(title);
stage.setResizable(false);
stage.setScene(new Scene(root));
stage.show();
} catch (Exception e) {
log.error("Unexpected exception while setting scene " + e);
}
}
}
LibraryController
import com.dansoftware.pdfdisplayer.PDFDisplayer;
import com.library.client.service.AlertService;
import com.library.client.service.FileUploadService;
import com.library.client.service.dto.BookDTO;
import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
import net.rgielen.fxweaver.core.FxWeaver;
import net.rgielen.fxweaver.core.FxmlView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import java.io.IOException;
import java.util.List;
@Slf4j
@Component
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@FxmlView("/FXML/library.fxml")
public class LibraryController extends BaseController {
@Autowired private FxWeaver fxWeaver;
@Autowired private WebClient webClient;
@Autowired private PDFDisplayer displayer;
@FXML private ScrollBar dataScroll;
@FXML private Button backButton;
@FXML private Button deletingButton;
@FXML private TableView<BookDTO> libTable;
@FXML private TableColumn<BookDTO, Long> id;
@FXML private TableColumn<BookDTO, String> title;
@FXML private TableColumn<BookDTO, String> author;
@FXML private TableColumn<BookDTO, String> publishDate;
private final AlertService alertService;
private final FileUploadService fileUploadService;
public LibraryController(AlertService alertService,
FileUploadService fileUploadService) {
this.alertService = alertService;
this.fileUploadService = fileUploadService;
}
@FXML
void initialize() {
List<BookDTO> booksList = webClient.get()
.uri("http://localhost:10120/book/get")
.retrieve()
.bodyToMono(new ParameterizedTypeReference<List<BookDTO>>() {
})
.doOnError(exception -> log.error("Error when trying to send request to server - [{}]", exception.getMessage()))
.block();
id.setCellValueFactory(new PropertyValueFactory<BookDTO, Long>("id"));
author.setCellValueFactory(new PropertyValueFactory<BookDTO, String>("author"));
title.setCellValueFactory(new PropertyValueFactory<BookDTO, String>("title"));
publishDate.setCellValueFactory(new PropertyValueFactory<BookDTO, String>("publishDate"));
libTable.getItems().addAll(booksList);
libTable.setRowFactory(
tableView -> {
TableRow<BookDTO> row = new TableRow<>();
row.setOnMouseClicked(
event -> {
if (event.getClickCount() == 2 && (!row.isEmpty())) {
byte[] bytesOfBook = webClient.get()
.uri("http://localhost:10120/book/get-bytes/" + row.getItem().getId())
.retrieve()
.bodyToMono(byte[].class)
.doOnError(exception -> log.error("Error when trying to send request to serve - [{}]", exception.getMessage()))
.block();
try {
--TRYING TO USE ONLY PDFVIEWER
Stage stage = new Stage();
displayer.loadPDF(fileUploadService.convertToFile(bytesOfBook));
Parent root = displayer.toNode();
Scene scene = new Scene(root);
stage.setTitle("Lib");
stage.setResizable(false);
stage.setScene(scene);
stage.show();
---CALL SERVICE WHICH TRIED TO USE WEAVERFX+PDFVIEWER TOGETHER
setScene("Lib", displayer, fxWeaver);
} catch (IOException e) {
e.printStackTrace();
}
}
});
return row;
});
}
}
BookDTO
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Builder(toBuilder = true)
public class BookDTO {
long id;
String title;
String author;
LocalDate publishDate;
String owner;
byte[] fileData;
}
AlertService
@Service
@RequiredArgsConstructor
public class AlertService {
public Optional<ButtonType> showAlert(Alert.AlertType type, String title, String content, boolean NeedToReturnResult) {
Alert alert = new Alert(type);
alert.setTitle(title);
alert.setContentText(content);
alert.setHeaderText(null);
Optional<ButtonType> result = alert.showAndWait();
if (NeedToReturnResult) return result;
else {
return null;
}
}
}
FileUploadService
@Slf4j
@Service
public class FileUploadService {
private final AlertService alertService;
public FileUploadService(AlertService alertService) {
this.alertService = alertService;
}
public File convertToFile(byte[] book) throws IOException {
File folder = new File("C:/temp/books");
if (!folder.exists()) {
try {
folder.mkdirs();
} catch (SecurityException e) {
log.error("Can't create output catalog because has not permission");
alertService.showAlert(Alert.AlertType.ERROR,
"Error",
"Error",
false);
}
}
Path filepath = Paths.get("C:/temp/books" + File.separator + "out.pdf");
if (Files.exists(filepath)) {
Files.delete(filepath);
}
Files.write(Files.createFile(filepath), book);
File file = new File(String.valueOf(filepath));
return file;
}
}
ClientApplication
public class ClientApplication extends Application {
private ConfigurableApplicationContext context;
@Override
public void init() throws Exception {
String[] args = getParameters().getRaw().toArray(new String[0]);
this.context = new SpringApplicationBuilder()
.sources(StartJavaFX.class)
.run(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
FxWeaver fxWeaver = context.getBean(FxWeaver.class);
Parent root = fxWeaver.loadView(LibraryController.class);
Scene scene = new Scene(root, 1280, 720);
primaryStage.setScene(scene);
primaryStage.setTitle("Main menu");
primaryStage.show();
}
@Override
public void stop() throws Exception {
this.context.close();
Platform.exit();
}
}
StartJavaFX
import com.dansoftware.pdfdisplayer.PDFDisplayer;
import javafx.application.Application;
import javafx.stage.Stage;
import net.rgielen.fxweaver.core.FxWeaver;
import net.rgielen.fxweaver.spring.SpringFxWeaver;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.reactive.function.client.WebClient;
@SpringBootApplication
public class StartJavaFX {
public static void main(String[] args) {
Application.launch(ClientApplication.class, args);
}
@Bean
public FxWeaver fxWeaver(ConfigurableApplicationContext applicationContext) {
return new SpringFxWeaver(applicationContext);
}
@Lazy
@Bean
public PDFDisplayer getPDF() {
return new PDFDisplayer();
}
@Lazy
@Bean
public Stage getStage() {
return new Stage();
}
@Lazy
@Bean
public WebClient createWebClient() {
return WebClient.create();
}
}
pom.xml
<properties>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<spring.boot.version>2.6.1</spring.boot.version>
<thymeleaf-spring5.version>3.1.0.M1</thymeleaf-spring5.version>
<jackson.version>2.12.2</jackson.version>
<lombok.version>1.18.22</lombok.version>
<javafx.version>15.0.1</javafx.version>
<javafx.weaver.version>1.3.0</javafx.weaver.version>
<javafx.pdfviewer.version>0.8</javafx.pdfviewer.version>
<springdoc.swagger.version>1.5.13</springdoc.swagger.version>
<unirest.version>1.4.9</unirest.version>
<jackson.version>2.13.0</jackson.version>
<commons.io.version>2.11.0</commons.io.version>
<spring.test.version>5.3.16</spring.test.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
<properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
</properties>
<!-- JavaFX PDFViewer -->
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- spring web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- web flux -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>${spring.boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-netty</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<!-- lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- javafx -->
<!-- javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- javafx-base -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- javafx-web -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- javafx-graphics -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- javafx-weaver starter -->
<dependency>
<groupId>net.rgielen</groupId>
<artifactId>javafx-weaver-spring-boot-starter</artifactId>
<version>${javafx.weaver.version}</version>
</dependency>
<!-- javafx-weaver core -->
<dependency>
<groupId>net.rgielen</groupId>
<artifactId>javafx-weaver-core</artifactId>
<version>${javafx.weaver.version}</version>
</dependency>
<!-- JavaFX PDFViewer -->
<dependency>
<groupId>com.github.Dansoftowner</groupId>
<artifactId>PDFViewerFX</artifactId>
<version>${javafx.pdfviewer.version}</version>
</dependency>
<!--Swagger-->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc.swagger.version}</version>
</dependency>
<!-- jackson-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>com.library.client.StartJavaFX</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
library.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollBar?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.library.client.frontend.LibraryController">
<children>
<StackPane layoutX="99.0" layoutY="177.0" prefHeight="426.0" prefWidth="1087.0">
<children>
<TableView fx:id="libTable" prefHeight="446.0" prefWidth="1159.0">
<columns>
<TableColumn fx:id="id" prefWidth="57.0" text="Id" />
<TableColumn fx:id="title" minWidth="0.0" prefWidth="442.0" text="Title" />
<TableColumn fx:id="author" prefWidth="231.0" text="Author" />
<TableColumn fx:id="publishDate" minWidth="0.0" prefWidth="343.0" text="Publish date" />
</columns>
</TableView>
<ScrollBar fx:id="dataScroll" orientation="VERTICAL" prefHeight="386.0" prefWidth="14.0" StackPane.alignment="TOP_RIGHT" />
</children>
</StackPane>
</children>
</AnchorPane>
Stacktrace when using only displayer
2022-03-29 17:34:27.962 INFO 3608 --- [JavaFX-Launcher] o.s.b.SpringApplication : No active profile set, falling back to default profiles: default
2022-03-29 17:34:28.445 INFO 3608 --- [JavaFX-Launcher] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-03-29 17:34:28.453 INFO 3608 --- [JavaFX-Launcher] o.a.c.c.StandardService : Starting service [Tomcat]
2022-03-29 17:34:28.454 INFO 3608 --- [JavaFX-Launcher] o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.55]
2022-03-29 17:34:28.516 INFO 3608 --- [JavaFX-Launcher] o.a.c.c.C.[.[.[/] : Initializing Spring embedded WebApplicationContext
2022-03-29 17:34:28.516 INFO 3608 --- [JavaFX-Launcher] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 533 ms
2022-03-29 17:34:29.005 INFO 3608 --- [JavaFX-Launcher] o.s.b.w.e.t.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-03-29 17:34:29.013 INFO 3608 --- [JavaFX-Launcher] o.s.b.SpringApplication : Started application in 1.259 seconds (JVM running for 2.018)
PDF 23fa3cab1a65ceae12b031b329ee254d [1.4 Skia/PDF m93 / Chromium] (PDF.js: 2.7.570)
Warning: Failed to load font 'normal': 'NetworkError: A network error occurred.'.
Warning: Failed to load font 'normal': 'NetworkError: A network error occurred.'.
Warning: Failed to load font 'normal': 'NetworkError: A network error occurred.'.
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: WebView@42bc3eb2[styleClass=root web-view]is already set as root of another scene
at javafx.scene.Scene$8.invalidated(Scene.java:1216)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.scene.Scene.setRoot(Scene.java:1178)
at javafx.scene.Scene.<init>(Scene.java:356)
at javafx.scene.Scene.<init>(Scene.java:207)
at com.library.client.frontend.LibraryController.lambda$initialize$2(LibraryController.java:87)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3563)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3865)
at javafx.scene.Scene.processMouseEvent(Scene.java:1851)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
at com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at com.sun.glass.ui.View.notifyMouse(View.java:942)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)
PDF 23fa3cab1a65ceae12b031b329ee254d [1.4 Skia/PDF m93 / Chromium] (PDF.js: 2.7.570)
Warning: Failed to load font 'normal': 'NetworkError: A network error occurred.'.
Warning: Failed to load font 'normal': 'NetworkError: A network error occurred.'.
Warning: Failed to load font 'normal': 'NetworkError: A network error occurred.'.
And stacktrace when I'm trying to use weaverFx+PDFViewer together
2022-03-29 17:35:38.960 INFO 19628 --- [JavaFX-Launcher] o.s.b.SpringApplication : No active profile set, falling back to default profiles: default
2022-03-29 17:35:39.447 INFO 19628 --- [JavaFX-Launcher] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-03-29 17:35:39.456 INFO 19628 --- [JavaFX-Launcher] o.a.c.c.StandardService : Starting service [Tomcat]
2022-03-29 17:35:39.456 INFO 19628 --- [JavaFX-Launcher] o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.55]
2022-03-29 17:35:39.518 INFO 19628 --- [JavaFX-Launcher] o.a.c.c.C.[.[.[/] : Initializing Spring embedded WebApplicationContext
2022-03-29 17:35:39.518 INFO 19628 --- [JavaFX-Launcher] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 537 ms
2022-03-29 17:35:40.005 INFO 19628 --- [JavaFX-Launcher] o.s.b.w.e.t.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-03-29 17:35:40.013 INFO 19628 --- [JavaFX-Launcher] o.s.b.SpringApplication : Started application in 1.259 seconds (JVM running for 2.016)
2022-03-29 17:35:42.711 ERROR 19628 --- [lication Thread] c.l.c.f.BaseController : Unexpected exception while setting scene org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javafx.scene.web.WebView' available
Ответы (1 шт):
Ошибка WebView[styleClass=root web-view]is already set as root of another scene возникает в этой строке Scene scene = new Scene(root); при повторном вызове.
Внутри PDFDisplayer для отображения pdf файла используется WebView и метод toNode() не создаёт каждый раз объект WebView: для кадого PDFDisplayer свой один WebView.
Попробуйте для каждого нового окна просмотра использовать отдельный PDFDisplayer.