简体   繁体   English

在带有Spring Boot模块的Jboss 6.2.0 GA中部署Ear时出现NoSuchMethodError异常

[英]NoSuchMethodError exception while deploying an Ear in Jboss 6.2.0 GA with Spring Boot module in it

I have spended more than entire day on looking a way to get out of this situation. 我花了整整一整天的时间寻找摆脱这种情况的方法。

Preamble 前言

My goal is to deploy a Spring Boot application inside a EAR with other two already working modules. 我的目标是在EAR内部署Spring Boot应用程序以及其他两个已经工作的模块。 I have overcome many issues due the fact the Spring Boot application's POM have to be linked to the parent POM as the structure is the following: 我克服了许多问题,因为Spring Boot应用程序的POM必须链接到父POM,因为其结构如下:

/ Parent POM / 家长POM

-----> EAR POM ----->耳朵聚甲醛

-----> Module 1 POM ----->模块1 POM

-----> Module 2 POM ----->模块2 POM

-----> Spring Boot App POM -----> Spring Boot App POM

Problem 问题

The Spring Boot application does the packaging as WAR correctly and is put inside the Ear successfully. Spring Boot应用程序正确地将WAR打包,并成功放入Ear中。 The issue appears when this War is being loaded on JBoss as there are some dependecy issues. 该问题在JBoss上加载War时出现,因为存在一些依赖问题。

What I have done 我做了什么

I played with jboss-deployment-structure.xml a bit and, at the end of the day, the result is this ( restService is the spring boot application): 我稍微玩了一下jboss-deployment-structure.xml ,最终结果是这样的( restService是spring boot应用程序):

 <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <ear-subdeployments-isolated>false</ear-subdeployments-isolated> <deployment> <exclusions> <!-- WFCORE-209 workaround --> <module name="javaee.api" /> <module name="org.hibernate.validator"/> <module name="javax.persistence.api" /> <module name="org.hibernate" /> <!--<module name="javax.validation"/>--> </exclusions> <exclude-subsystems> <subsystem name="jaxrs" /> <subsystem name="datasources" /> <subsystem name="ejb3" /> <subsystem name="infinispan" /> <subsystem name="jca" /> <subsystem name="logging" /> <subsystem name="jdr" /> <subsystem name="jpa" /> <subsystem name="jsf" /> <subsystem name="mail" /> <subsystem name="threads" /> <subsystem name="pojo" /> <subsystem name="sar" /> <subsystem name="transactions" /> <subsystem name="webservices" /> <subsystem name="weld" /> </exclude-subsystems> <dependencies> <!-- WFCORE-209 workaround --> <module name="javax.activation.api" export="true"/> <module name="javax.annotation.api" export="true"/> <module name="javax.ejb.api" export="true"/> <module name="javax.el.api" export="true"/> <module name="javax.enterprise.api" export="true"/> <module name="javax.enterprise.deploy.api" export="true"/> <module name="javax.inject.api" export="true"/> <module name="javax.interceptor.api" export="true"/> <module name="javax.jms.api" export="true"/> <module name="javax.jws.api" export="true"/> <module name="javax.mail.api" export="true"/> <module name="javax.management.j2ee.api" export="true"/> <!-- <module name="javax.persistence.api" export="true"/> --> <module name="javax.resource.api" export="true"/> <module name="javax.rmi.api" export="true"/> <module name="javax.security.auth.message.api" export="true"/> <module name="javax.security.jacc.api" export="true"/> <module name="javax.servlet.api" export="true"/> <module name="javax.servlet.jsp.api" export="true"/> <module name="javax.transaction.api" export="true"/> <module name="javax.validation.api" export="true"/> <module name="javax.ws.rs.api" export="true" services="export"/> <module name="javax.xml.bind.api" export="true"/> <module name="javax.xml.registry.api" export="true"/> <module name="javax.xml.soap.api" export="true"/> <module name="javax.xml.ws.api" export="true"/> <!-- This one always goes last. --> <module name="javax.api" export="true"/> </dependencies> </deployment> <sub-deployment name="CRVbusinessService.war"> <dependencies> <module name="javax.xml.rpc.api"/> <module name="javax.wsdl4j.api"/> </dependencies> <exclusions> <module name="org.apache.commons.logging"/> <module name="org.apache.log4j"/> <module name="org.jboss.logging"/> <module name="org.jboss.logging.jul-to-slf4j-stub"/> <module name="org.jboss.logmanager"/> <module name="org.jboss.logmanager.log4j"/> <module name="org.slf4j"/> <module name="org.slf4j.impl"/> </exclusions> </sub-deployment> <sub-deployment name="restService.war"> <local-last value="true" /> <dependencies> <module name="deployment.jpa2.1"/> </dependencies> <exclusions> <module name="org.jboss.logging"/> <!--<module name="javax.validation"/>--> <module name="javaee.api" /> </exclusions> </sub-deployment> <module name="deployment.jpa2.1" > <module-alias name="jpa2.1"/> <resources> <resource-root path="hibernate-jpa-2.1-api-1.0.0.Final.jar" /> </resources> </module> </jboss-deployment-structure> 

However I wasn't able to sort out the problem as I am actually receiving this exception: 但是,由于我实际上收到此异常,因此无法解决问题:

Application run failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Invocation of init method failed; 应用程序运行失败:org.springframework.beans.factory.BeanCreationException:创建在类路径资源[org / springframework / boot / autoconfigure / validation / ValidationAutoConfiguration.class]中定义的名称为'defaultValidator'的bean时出错:调用init方法失败; nested exception is java.lang.NoSuchMethodError: javax.validation.Configuration.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider; 嵌套的异常是java.lang.NoSuchMethodError:javax.validation.Configuration.getDefaultParameterNameProvider()Ljavax / validation / ParameterNameProvider;

In order to provide further details here it is the Spring Boot app pom.xml: 为了在此处提供更多详细信息,它是Spring Boot应用程序pom.xml:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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> <parent> <groupId>it.test.businessService</groupId> <artifactId>parent-parent</artifactId> <version>0.0</version> </parent> <groupId>com.crvservice</groupId> <artifactId>restService</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <failOnMissingWebXml>false</failOnMissingWebXml> <org.springframework-version>5.0.9.RELEASE</org.springframework-version> <!--<hibernate.version>5.2.17.Final</hibernate.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.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.16</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <!-- Import dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.0.3.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>development</id> <properties> <spring.profiles.active>dev</spring.profiles.active> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> <profile> <id>production</id> <properties> <spring.profiles.active>ci</spring.profiles.active> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles> </project> 

Adding <module name="javax.validation"/> in jboss-deployment-structure.xml seems not helping as it did with other similar issues that were fixed by adding the relative exclusion on Jboss. 在jboss-deployment-structure.xml中添加<module name="javax.validation"/>似乎<module name="javax.validation"/>因为它通过在Jboss上添加相对排除来解决其他类似问题。 I fear that my Spring Boot version and on cascade of everything connected such as hibernate is too recent to function correctly on this JBoss version. 我担心我的Spring Boot版本以及所连接的所有事物(如休眠)的级联太新,无法在此JBoss版本上正常运行。

Am I missing something? 我想念什么吗? I looked around, but it seems that few persons actually needed doing such things. 我环顾四周,但似乎很少有人真正需要这样做。

Thank you in advance. 先感谢您。

It seems the issue was due to Jboss 6 which supports only Spring Boot version 1.5.x instead of the 2.x. 似乎该问题是由于Jboss 6仅支持Spring Boot版本1.5.x而不是2.x引起的。

Remember that Spring boot 2.x supports only Javax Servlet 3.1 while Jboss 3.0. 请记住,Spring Boot 2.x仅在Jboss 3.0时支持Javax Servlet 3.1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM