Error occurred during initialization of boot layer
Создаю клиент-серверное приложение, хочу загружать книги из FileChooser на сервер в виде MultipartFile, на сервере уже помещать загруженную книгу в БД. До этого реализовал графический интерфейс и все работало нормально, далее реализовал уже отправку книги с полями (Автор, дата публикации и т.д.) на сервер и получаю ошибку ниже. Графический интерфейс реализован с использованием JavaFX.
Error occurred during initialization of boot layer java.lang.module.ResolutionException: Modules org.aspectj.weaver and org.aspectj.runtime export package org.aspectj.runtime.internal to module spring.boot.starter.data.jpa
При попытке использовать clean+install в Maven получаю следующую ошибку
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project client: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile failed: Cannot invoke "java.lang.Throwable.getCause()" because "cause" is null
Файл UploadedBook
package org.openjfx.DB.Entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UploadedBook {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String author;
private String title;
private String publish_date;
@Lob
private byte[] file_data;
}
Файл FileUploadService
package org.openjfx.SRV.FileUploadService;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
public interface FileUploadService {
public byte[] uploadToServer(File file);
}
Файл FileUploadServiceImpl
package org.openjfx.SRV.FileUploadService;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class FileUploadServiceImpl implements FileUploadService{
@Override
public byte[] uploadToServer(File file){
String strPath = file.getPath();
Path path = Paths.get(strPath);
String name = file.getName();
String originalFileName = file.getName();;
String contentType = "text/plain";
byte[] content = null;
byte[] data = null;
try {
content = Files.readAllBytes(path);
} catch (final IOException e) {
}
MultipartFile result = new MockMultipartFile(name,
originalFileName, contentType, content);
try {
data = result.getBytes();
} catch (IOException e) {
e.printStackTrace();
}
return data;
}
}
Файл LoadBookController
package org.openjfx.FrontEndControllers;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.openjfx.DB.Entity.UploadedBook;
import org.openjfx.SRV.FileUploadService.FileUploadService;
import org.openjfx.SRV.FileUploadService.FileUploadServiceImpl;
import java.io.File;
import java.io.IOException;
public class LoadBookController {
@FXML private Button loadBookBackButton;
@FXML private Button loadBookButton;
@FXML private TextField tbAuthor;
@FXML private Label labelAuthor;
@FXML private TextField tbTitle;
@FXML private Label labelTitle;
@FXML private TextField tbPublishDate;
@FXML private Label labelPublishDate;
@FXML private Button saveBookButton;
FXMLLoader loader = new FXMLLoader();
Stage stage = new Stage();
FileChooser fileChooser = new FileChooser();
File choosedFile;
@FXML
void initialize() {
UploadedBook uploadedBook = new UploadedBook();
FileUploadServiceImpl fileUploadServiceImpl = new FileUploadServiceImpl();
loadBookBackButton.setOnAction(
actionEvent -> {
loadBookBackButton.getScene().getWindow().hide();
loader.setLocation(getClass().getResource("/org/openjfx/FXML/mainMenu.fxml"));
try {
loader.load();
} catch (IOException e) {
e.printStackTrace();
}
Parent root = loader.getRoot();
stage.setScene(new Scene(root));
stage.show();
});
loadBookButton.setOnAction(
actionEvent -> {
FileChooser.ExtensionFilter extFilter =
new FileChooser.ExtensionFilter("PDF files (*.pdf)", "*.pdf");
fileChooser.getExtensionFilters().add(extFilter);
fileChooser.setTitle("Download book");
choosedFile = fileChooser.showOpenDialog(stage);
});
saveBookButton.setOnAction(
actionEvent -> {
if (tbAuthor.getText().trim().isEmpty()
|| tbTitle.getText().trim().isEmpty()
|| tbPublishDate.getText().trim().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Ошибка");
alert.setContentText("Вы заполнили не все поля");
alert.setHeaderText(null);
DialogPane dialogPane = alert.getDialogPane();
dialogPane
.getStylesheets()
.add(getClass().getResource("AlertStyles.css").toExternalForm());
dialogPane.getStyleClass().add("AlertStyles");
// DialogPane dialogPane = alert.getDialogPane();
// dialogPane.setStyle("-fx-background-color: rgb(33,33,33);");
alert.showAndWait();
} else {
JsonNode bookLoadResult = new JsonNode(null);
Boolean validationLogin;
try {
uploadedBook.setAuthor(tbAuthor.getText());
uploadedBook.setTitle(tbTitle.getText());
uploadedBook.setPublish_date(tbPublishDate.getText());
uploadedBook.setFile_data(fileUploadServiceImpl.uploadToServer(choosedFile));
bookLoadResult =
Unirest.post("http://localhost:8080/bookshelf/add")
.header("accept", "application/json")
.field("author", uploadedBook.getAuthor())
.field("title", uploadedBook.getTitle())
.field("publish_date", uploadedBook.getPublish_date())
.field("file_data", uploadedBook.getFile_data())
.asJson()
.getBody();
} catch (UnirestException e) {
e.printStackTrace();
}
}
});
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openjfx</groupId>
<artifactId>client</artifactId>
<version>0.0.4</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java -->
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.32.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.32.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<mainClass>org.openjfx.Client</mainClass>
</configuration>
</plugin>
<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>
<version>3.8.0</version>
<configuration>
<source>15.0.2</source>
<target>15.0.2</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</path>
<!-- This is needed when using Lombok 1.18.16 and above -->
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<!-- Mapstruct should follow the lombok path(s) -->
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>