NoClassDefFoundError javax / servlet / Registration $ Dynamic with spring boot + spring boot legacy

时间:2018-04-24 12:40:02

标签: java spring spring-boot

我正在将spring boot 1.4.2部署到weblogic 10.3 ...我正在包含spring-boot-legacy来处理servlet版本兼容性问题(3.0 / 2.5)...我在部署时收到此错误:

Caused By: java.lang.NoClassDefFoundError: javax/servlet/Registration$Dynamic
    at org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration.messageDispatcherServlet(WebServicesAutoConfiguration.java:64)
    at org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration$$EnhancerBySpringCGLIB$$77b29a1f.CGLIB$messageDispatcherServlet$0(<generated>)
    at org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration$$EnhancerBySpringCGLIB$$77b29a1f$$FastClassBySpringCGLIB$$f1781529.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
    at org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration$$EnhancerBySpringCGLIB$$77b29a1f.messageDispatcherServlet(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
    at org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:61)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1868)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
    at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:149)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

奇怪的是,javax/servlet/Registration$Dynamic spring boot 2.0.0中访问ServletRegistrationBean ... spring boot 1.4.2中的相应内容是ServletRegistration.Dynamic 应在spring-boot-legacy

中处理
@ConditionalOnMissingClass("javax.servlet.ServletRegistration")
@AutoConfigureAfter({
        MetricRepositoryAutoConfiguration.class,
        org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration.class })
public class MetricFilterAutoConfiguration {

编辑: build.gradle依赖项:

dependencies {
    compile('org.springframework.boot:spring-boot-legacy:1.1.0.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE')
    compile('com.fasterxml.jackson.core:jackson-databind:2.6.7') //java6
    compile('org.springframework.ws:spring-ws-core:2.2.4.RELEASE')
    compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2'){
        exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
    }
    compile('org.projectlombok:lombok:1.16.10')
    compileOnly('com.oracle:ojdbc6:11.1.0.7.0') //java6
    //compileOnly('org.springframework.boot:spring-boot-devtools')
    compileOnly('javax.servlet:servlet-api:2.5')
    //compile(files(genJaxb.classesDir).builtBy(genJaxb))

    //jaxb "com.sun.xml.bind:jaxb-xjc:2.1.7"
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') // commented for java6
    providedRuntime('org.apache.tomcat:tomcat-juli:7.0.59') // java6
    compileOnly group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.59'

编辑:gradle依赖树:

org.springframework.boot:spring-boot-legacy:1.1.0.RELEASE
+--- org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE
|    +--- org.springframework.boot:spring-boot-starter:1.4.2.RELEASE
|    |    +--- org.springframework.boot:spring-boot:1.4.2.RELEASE
|    |    |    +--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |    \--- org.springframework:spring-context:4.3.4.RELEASE
|    |    |         +--- org.springframework:spring-aop:4.3.4.RELEASE
|    |    |         |    +--- org.springframework:spring-beans:4.3.4.RELEASE
|    |    |         |    |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |         |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |    |         +--- org.springframework:spring-core:4.3.4.RELEASE
|    |    |         \--- org.springframework:spring-expression:4.3.4.RELEASE
|    |    |              \--- org.springframework:spring-core:4.3.4.RELEASE
|    |    +--- org.springframework.boot:spring-boot-autoconfigure:1.4.2.RELEASE
|    |    |    \--- org.springframework.boot:spring-boot:1.4.2.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-starter-logging:1.4.2.RELEASE
|    |    |    +--- ch.qos.logback:logback-classic:1.1.7
|    |    |    |    +--- ch.qos.logback:logback-core:1.1.7
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.20 -> 1.7.21
|    |    |    +--- org.slf4j:jcl-over-slf4j:1.7.21
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.21
|    |    |    +--- org.slf4j:jul-to-slf4j:1.7.21
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.21
|    |    |    \--- org.slf4j:log4j-over-slf4j:1.7.21
|    |    |         \--- org.slf4j:slf4j-api:1.7.21
|    |    +--- org.springframework:spring-core:4.3.4.RELEASE
|    |    \--- org.yaml:snakeyaml:1.17
|    +--- org.hibernate:hibernate-validator:5.2.4.Final
|    |    +--- javax.validation:validation-api:1.1.0.Final
|    |    +--- org.jboss.logging:jboss-logging:3.2.1.Final -> 3.3.0.Final
|    |    \--- com.fasterxml:classmate:1.1.0 -> 1.3.3
|    +--- com.fasterxml.jackson.core:jackson-databind:2.8.4 -> 2.6.7
|    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.6.0 -> 2.8.4
|    |    \--- com.fasterxml.jackson.core:jackson-core:2.6.7 -> 2.8.4
|    +--- org.springframework:spring-web:4.3.4.RELEASE
|    |    +--- org.springframework:spring-aop:4.3.4.RELEASE (*)
|    |    +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |    +--- org.springframework:spring-context:4.3.4.RELEASE (*)
|    |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    \--- org.springframework:spring-webmvc:4.3.4.RELEASE
|         +--- org.springframework:spring-aop:4.3.4.RELEASE (*)
|         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|         +--- org.springframework:spring-context:4.3.4.RELEASE (*)
|         +--- org.springframework:spring-core:4.3.4.RELEASE
|         +--- org.springframework:spring-expression:4.3.4.RELEASE (*)
|         \--- org.springframework:spring-web:4.3.4.RELEASE (*)
+--- com.fasterxml.jackson.core:jackson-databind:2.6.7 (*)
+--- org.springframework.ws:spring-ws-core -> 2.3.1.RELEASE
|    +--- org.springframework.ws:spring-xml:2.3.1.RELEASE
|    |    +--- org.springframework:spring-beans:4.0.9.RELEASE -> 4.3.4.RELEASE (*)
|    |    +--- org.springframework:spring-context:4.0.9.RELEASE -> 4.3.4.RELEASE (*)
|    |    \--- org.springframework:spring-core:4.0.9.RELEASE -> 4.3.4.RELEASE
|    +--- org.springframework:spring-aop:4.0.9.RELEASE -> 4.3.4.RELEASE (*)
|    +--- org.springframework:spring-beans:4.0.9.RELEASE -> 4.3.4.RELEASE (*)
|    +--- org.springframework:spring-core:4.0.9.RELEASE -> 4.3.4.RELEASE
|    +--- org.springframework:spring-oxm:4.0.9.RELEASE -> 4.3.4.RELEASE
|    |    +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |    \--- org.springframework:spring-core:4.3.4.RELEASE
|    +--- org.springframework:spring-web:4.0.9.RELEASE -> 4.3.4.RELEASE (*)
|    \--- org.springframework:spring-webmvc:4.0.9.RELEASE -> 4.3.4.RELEASE (*)
+--- org.mybatis.spring.boot:mybatis-spring-boot-starter:1.2.0
|    +--- org.springframework.boot:spring-boot-starter:1.4.3.RELEASE -> 1.4.2.RELEASE (*)
|    +--- org.springframework.boot:spring-boot-starter-jdbc:1.4.3.RELEASE -> 1.4.2.RELEASE
|    |    +--- org.springframework.boot:spring-boot-starter:1.4.2.RELEASE (*)
|    |    +--- org.apache.tomcat:tomcat-jdbc:8.5.6
|    |    |    \--- org.apache.tomcat:tomcat-juli:8.5.6 -> 7.0.59
|    |    \--- org.springframework:spring-jdbc:4.3.4.RELEASE
|    |         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |         +--- org.springframework:spring-core:4.3.4.RELEASE
|    |         \--- org.springframework:spring-tx:4.3.4.RELEASE
|    |              +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
|    |              \--- org.springframework:spring-core:4.3.4.RELEASE
|    +--- org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.2.0
|    |    \--- org.springframework.boot:spring-boot-autoconfigure:1.4.3.RELEASE -> 1.4.2.RELEASE (*)
|    +--- org.mybatis:mybatis:3.4.2
|    \--- org.mybatis:mybatis-spring:1.3.1
+--- org.projectlombok:lombok:1.16.10
+--- com.oracle:ojdbc6:11.1.0.7.0
\--- org.apache.tomcat:tomcat-juli:7.0.59

0 个答案:

没有答案