Spring 5.0.3依赖项问题

时间:2018-01-31 07:40:33

标签: spring maven wildfly

升级到spring 5.0.3后,我遇到以下问题:

09:25:29,141 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 175) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./chatservice: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./chatservice: java.lang.RuntimeException: javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:84)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:241)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:99)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
        ... 6 more
Caused by: javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:158)
        at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:192)
        at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:174)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:239)
        ... 8 more
Caused by: java.lang.NoSuchMethodError: org.springframework.util.ReflectionUtils.accessibleConstructor(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:155)
        ... 18 more

输出日志错误

我的pom.xml依赖关系结构我为版本5.0.3添加了新的spinrg请求

  <properties>
            <endorsed.dir>target/endorsed</endorsed.dir>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.source>1.8</maven.compiler.source>
        </properties>     

        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.spec</groupId>
                    <artifactId>jboss-javaee-7.0</artifactId>
                    <version>1.0.0.Final</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-web-api</artifactId>
                <version>7.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> 
                <version>5.1.39</version> </dependency> -->
            <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>42.1.4</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>5.0.7.Final</version>
                <scope>provided</scope>        
                <exclusions>
                    <exclusion>
                        <artifactId>dom4j</artifactId>
                        <groupId>dom4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>5.2.3.Final</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>5.2.1.Final</version>
                <exclusions>
                    <exclusion>
                        <artifactId>dom4j</artifactId>
                        <groupId>dom4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.jboss.logging</groupId>
                <artifactId>jboss-logging</artifactId>
                <version>3.3.0.Final</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.enterprise</groupId>
                <artifactId>cdi-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.spec.javax.annotation</groupId>
                <artifactId>jboss-annotations-api_1.2_spec</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.spec.javax.servlet</groupId>
                <artifactId>jboss-servlet-api_3.1_spec</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.mail</groupId>
                <artifactId>javax.mail-api</artifactId>
                <version>1.5.5</version>
                <scope>provided</scope>
            </dependency>
            <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-asm</artifactId> 
                <version>3.1.4.RELEASE</version> </dependency> -->
            <!--dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> 
                <version>1.8.9</version> </dependency -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>5.0.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>5.0.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>5.0.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jms</artifactId>
                <version>5.0.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>5.0.3.RELEASE</version>
            </dependency>
            <!--dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> 
                <version>5.0.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> 
                <artifactId>spring-security-web</artifactId> <version>5.0.1.RELEASE</version> 
                </dependency > <dependency> <groupId>org.springframework.security</groupId> 
                <artifactId>spring-security-config</artifactId> <version>5.0.1.RELEASE</version> 
                </dependency> <dependency> <groupId>org.springframework.security</groupId> 
                <artifactId>spring-security-taglibs</artifactId> <version>5.0.1.RELEASE</version> 
                </dependency -->
            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-configuration2</artifactId>
                <version>2.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.3.2</version>
            </dependency>
            <!-- dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> 
                <version>1.1.3</version> </dependency -->
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>1.9.2</version>
            </dependency>
            <!-- dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> 
                <version>1.9</version> </dependency -->
            <dependency>
                <groupId>commons-jxpath</groupId>
                <artifactId>commons-jxpath</artifactId>
                <version>1.3</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-jexl</artifactId>
                <version>2.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-vfs2</artifactId>
                <version>2.0</version>
            </dependency>
            <dependency>
                <groupId>xml-resolver</groupId>
                <artifactId>xml-resolver</artifactId>
                <version>1.2</version>
            </dependency>
            <!-- <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> 
                <version>1.9.13</version> </dependency> -->
            <dependency>
                <groupId>com.googlecode.json-simple</groupId>
                <artifactId>json-simple</artifactId>
                <version>1.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.15</version>
            </dependency>
            <dependency>
                <groupId>com.lowagie</groupId>
                <artifactId>itext</artifactId>
                <version>2.1.7</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.3.2</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.5</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency> 
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>4.0.0</version>
            </dependency>

            <!-- dependency> <groupId>org.opensmpp</groupId> <artifactId>opensmpp-sim</artifactId> 
                <version>3.0.0</version> </dependency> <dependency> <groupId>org.opensmpp</groupId> 
                <artifactId>opensmpp-client</arifactId> <version>3.0.0</version> </dependency -->
            <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
            <dependency>
                <groupId>org.jsoup</groupId>
                <artifactId>jsoup</artifactId>
                <version>1.10.3</version>
            </dependency>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-all</artifactId>
                <version>5.15.2</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/javax.jms/javax.jms-api> <dependency> 
                <groupId>javax.jms</groupId> <artifactId>javax.jms-api</artifactId> <version>2.0</version> 
                </dependency -->
        </dependencies>

我还检查旧的jar库,以确保没有兼容性问题。  另外跟随spring-core https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/WebApplicationInitializer.html

的api结构

1 个答案:

答案 0 :(得分:0)

java.lang.NoSuchMethodError表示可以找到类org.springframework.util.ReflectionUtils,但它没有签名为accessibleConstructor(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;的方法。

javadoc表示此方法是在Spring 5.0中引入的。因此,它应该在您的spring-core依赖项中可用。

发布spring-core时此列出了mvn dependency:tree依赖关系(这里只是相关代码段),且版本大于&gt; 5.0(此处为5.0.3.RELEASE):

[INFO] +- org.springframework:spring-context-support:jar:5.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:5.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:5.0.3.RELEASE:compile
[INFO] |  \- org.springframework:spring-core:jar:5.0.3.RELEASE:compile
[INFO] |     \- org.springframework:spring-jcl:jar:5.0.3.RELEASE:compile

唯一的结论是Wilfly找到了旧版本。在你的战争/耳朵中或作为$JBOSS_HOME/modules内的模块。请仔细检查您是否找不到版本为spring-core.jar的版本&lt; 5.0。