Я пытаюсь развернуть приложение Spring Boot на сервере WildFly.
Мое приложение состоит из 3 подпроектов: dao (jar), metier (jar) и web (war).
Веб зависит от мети, а мети зависит от дао.
Используя Java, Spring Boot 2, Maven, Angular 6, я адаптировал свое приложение (файлы pom.xml) для развертывания на моем сервере WildFly.
Перед адаптацией для моего сервера WildFly мое приложение отлично работает на локальном сервере (Eclipse Tomcat и Angular local server).
Сначала я попытался выполнить из терминала maven чистую установку в моем веб-проекте (война) командой:
mvn clean install --also-make
Но зависимости от metier и dao не удовлетворяли.
Итак, я создал родительский файл pom.xml для моего родительского проекта.
Это мой родитель pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.hillsoft</groupId>
<artifactId>ecommerce-projet</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>ecommerce-dao</module>
<module>ecommerce-metier</module>
<module>ecommerce-web</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
И это файлы pom.xml для моих 3 подпроектов:
ecommerce-dao:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- <groupId>fr.hillsoft</groupId> -->
<artifactId>ecommerce-dao</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
<packaging>jar</packaging>
<name>ecommerce-dao</name>
<description>e-commerce Hillsoft DAO</description>
<parent>
<groupId>fr.hillsoft</groupId>
<artifactId>ecommerce-projet</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<!-- <parent> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-parent</artifactId> -->
<!-- <version>2.0.2.RELEASE</version> -->
<!-- <relativePath/> lookup parent from repository -->
<!-- </parent> -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- <build> -->
<!-- <plugins> -->
<!-- <plugin> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-maven-plugin</artifactId> -->
<!-- </plugin> -->
<!-- </plugins> -->
<!-- </build> -->
</project>
ecommerce-metier:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- <groupId>fr.hillsoft</groupId> -->
<artifactId>ecommerce-metier</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
<packaging>jar</packaging>
<name>ecommerce-metier</name>
<description>e-commerce Hillsoft Métier</description>
<parent>
<groupId>fr.hillsoft</groupId>
<artifactId>ecommerce-projet</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<!-- <parent> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-parent</artifactId> -->
<!-- <version>2.0.3.RELEASE</version> -->
<!-- <relativePath/> lookup parent from repository -->
<!-- </parent> -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>fr.hillsoft</groupId>
<artifactId>ecommerce-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- <build> -->
<!-- <plugins> -->
<!-- <plugin> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-maven-plugin</artifactId> -->
<!-- </plugin> -->
<!-- </plugins> -->
<!-- </build> -->
</project>
ecommerce-web:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- <groupId>fr.hillsoft</groupId> -->
<artifactId>ecommerce-web</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
<packaging>war</packaging>
<name>ecommerce-web</name>
<description>e-commerce Hillsoft Web</description>
<parent>
<groupId>fr.hillsoft</groupId>
<artifactId>ecommerce-projet</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<!-- <parent> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-parent</artifactId> -->
<!-- <version>2.0.2.RELEASE</version> -->
<!-- <relativePath/> lookup parent from repository -->
<!-- </parent> -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>fr.hillsoft</groupId>
<artifactId>ecommerce-metier</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.wildfly.core/wildfly-server -->
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-server</artifactId>
<version>5.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
</dependencies>
<!-- <build> -->
<!-- <plugins> -->
<!-- <plugin> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-maven-plugin</artifactId> -->
<!-- </plugin> -->
<!-- </plugins> -->
<!-- </build> -->
</project>
Но проблема сохраняется. Эта ошибка возникает при попытке maven чистой установки родительского проекта из терминала:
package does not exist [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Consultat Hillsoft/workingset/workspace-ecommerce/ecommerce-projet/ecommerce-metier/src/main/java/fr/hillsoft/metier/impl/InternauteImpl.java:[11,25] package fr.hillsoft.model does not exist
[INFO] 100 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] ecommerce-projet 0.0.1-SNAPSHOT .................... SUCCESS [ 1.986 s]
[INFO] ecommerce-dao ...................................... SUCCESS [ 18.025 s]
[INFO] ecommerce-metier ................................... FAILURE [ 1.687 s]
[INFO] ecommerce-web 0.0.1-SNAPSHOT ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.369 s
[INFO] Finished at: 2018-08-31T14:17:18+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project ecommerce-metier: Compilation failure: Compilation failure:
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :ecommerce-metier
В поисках решения, поскольку я использую Eclipse, я попробовал «Maven build…» из записи «Run As» в веб-подпроекте, с целями «чистой установки», «Пропустить тесты» и «Resolve Workspace». артефакты "проверено.
Я скопировал файл WAR, созданный из целевого репозитория, в автономный репозиторий развертываний wildfly.
Эта ошибка возникает, когда я пытаюсь развернуть свой проект на сервере WildFly с помощью standalone.sh run:
Это важные строки списка ошибок:
11:51:35,702 ERROR [org.springframework.boot.SpringApplication] (ServerService Thread Pool -- 66) Application run failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
Caused by: java.lang.NoClassDefFoundError: fr/hillsoft/model/MyUser
Caused by: java.lang.ClassNotFoundException: fr.hillsoft.model.MyUser from [Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
11:51:35,704 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 66) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host."/ecommerce-web-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."/ecommerce-web-0.0.1-SNAPSHOT": java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
Caused by: java.lang.NoClassDefFoundError: fr/hillsoft/model/MyUser
Caused by: java.lang.ClassNotFoundException: fr.hillsoft.model.MyUser from [Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
11:51:35,710 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ecommerce-web-0.0.1-SNAPSHOT.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host.\"/ecommerce-web-0.0.1-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.\"/ecommerce-web-0.0.1-SNAPSHOT\": java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module \"deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main\" from Service Module Loader]
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module \"deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main\" from Service Module Loader]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module \"deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main\" from Service Module Loader]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module \"deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main\" from Service Module Loader]
Caused by: java.lang.NoClassDefFoundError: fr/hillsoft/model/MyUser
Caused by: java.lang.ClassNotFoundException: fr.hillsoft.model.MyUser from [Module \"deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main\" from Service Module Loader]"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host.\"/ecommerce-web-0.0.1-SNAPSHOT\""],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
11:51:35,769 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "ecommerce-web-0.0.1-SNAPSHOT.war" (runtime-name : "ecommerce-web-0.0.1-SNAPSHOT.war")
11:51:35,772 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.undertow.deployment.default-server.default-host."/ecommerce-web-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."/ecommerce-web-0.0.1-SNAPSHOT": java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRestController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [fr.hillsoft.controller.AccountRestController] from ClassLoader [ModuleClassLoader for Module "deployment.ecommerce-web-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
11:51:35,883 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started (with errors) in 11384ms - Started 516 of 768 services (2 services failed or missing dependencies, 405 services are lazy, passive or on-demand)
11:51:35,907 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0019: Stopped Driver service with driver-name = ecommerce-web-0.0.1-SNAPSHOT.war_org.postgresql.Driver_42_2
11:51:35,960 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0028: Stopped deployment ecommerce-web-0.0.1-SNAPSHOT.war (runtime-name: ecommerce-web-0.0.1-SNAPSHOT.war) in 59ms
WFLYCTL0186: Services which failed to start: service jboss.undertow.deployment.default-server.default-host."/ecommerce-web-0.0.1-SNAPSHOT"
Это первые строки MyUser.java:
package fr.hillsoft.model;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Version;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSetter;
@Entity
public class MyUser {
private Long id;
И это первые строки AccountRestController.java:
package fr.hillsoft.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import fr.hillsoft.metier.AccountService;
import fr.hillsoft.model.MyUser;
@RestController
public class AccountRestController {
@Autowired
private AccountService accountService;
@PostMapping("/register")
public MyUser register(@RequestBody RegisterForm registerForm) {
Все попытки, вероятно, связаны с одной и той же причиной, это из-за зависимостей Maven? Как это исправить?