IncompleteClassChangeError: javax.servlet.http.HttpServlet(在 JBoss WildFly 环境中部署 Spring Boot 项目时)

问题描述 投票:0回答:1

这是我的错误消息 在我看来,主要错误似乎就是这个。 “由于:java.lang.InknownClassChangeError:javax.servlet.http.HttpServlet和javax.servlet.http.HttpServlet$NoBodyAsyncContextListener在InnerClasses属性上不一致”

10:12:12,897 ERROR \[org.jboss.msc.service.fail\] (MSC service thread 1-1) MSC000001: Failed to startservicejboss.deployment.unit.component."javax.servlet.http.HttpServlet$NoBodyAsyncContextListener".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit.component."javax.servlet.http.HttpServlet$NoBodyAsyncContextListener".WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1731)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
at java.lang.Thread.run(Thread.java:750)
Caused by: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class javax.servlet.http.HttpServlet$NoBodyAsyncContextListener
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:186)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
at org.jboss.weld.resources.ClassTransformer.getEnhancedAnnotatedType(ClassTransformer.java:232)
at org.jboss.as.weld.injection.InjectionTargets.createInjectionTarget(InjectionTargets.java:64)
at org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:121)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
... 6 more
Caused by: java.lang.IncompatibleClassChangeError: javax.servlet.http.HttpServlet and javax.servlet.http.HttpServlet$NoBodyAsyncContextListener disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass0(Native Method)
at java.lang.Class.getDeclaringClass(Class.java:1235)
at org.jboss.weld.util.reflection.Reflections.checkDeclaringClassLoadable(Reflections.java:427)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:83)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:79)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$new$0(ReentrantMapBackedComputingCache.java:55)
at org.jboss.weld.util.WeakLazyValueHolder$1.computeValue(WeakLazyValueHolder.java:35)
at org.jboss.weld.util.WeakLazyValueHolder.get(WeakLazyValueHolder.java:53)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getCastValue(ReentrantMapBackedComputingCache.java:78)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:177)
... 12 more

我的jboss-deployment-struct.xml和build.gradle是这样的

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <dependencies>
            <module name="javax.servlet.api"/>
            <module name="javax.servlet.jsp.api"/>
<!--            <module name="org.apache.juli.logging"/>-->
        </dependencies>
        <exclude-subsystems>
            <subsystem name="logging" />
            <subsystem name="jaxrs" />
            <subsystem name="resteasy" />
        </exclude-subsystems>
        <!-- exclusions allow you to prevent the server from automatically adding some dependencies -->
        <exclusions>
            <module name="org.slf4j" />
            <module name="org.slf4j.impl" />
            <module name="org.slf4j.jcl-over-slf4j"/>
            <module name="org.apache.commons.logging"/>
            <module name="tomcat-embed-core"/>
            <module name="org.apache.juli"/>
            <module name="org.apache.juli.logging"/>
            <module name="org.apache.juli.logging.LogFactory"/>
            <module name="org.apache.log4j"/>
            <module name="javaee.api" />
            <module name="javax.xml.bind.api" />
            <module name="com.fasterxml.jackson.core.jackson-core" />
            <module name="com.fasterxml.jackson.core.jackson-databind" />
            <module name="com.fasterxml.jackson.core.jackson-annotations" />
            <module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
            <module name="org.jboss.resteasy.resteasy-jaxb-provider" />
            <module name="org.jboss.resteasy.resteasy-jettison-provider"/>
            <module name="org.jboss.resteasy.resteasy-jackson-provider"/>
            <module name="org.jboss.resteasy.resteasy-jackson2-provider" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>


plugins {
    id 'java'
    id 'war'
    id 'org.springframework.boot' version '2.7.10'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

description = ''

java {
    sourceCompatibility = '1.8'
}

jar {
    enabled = false
}

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
        exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j'
        exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
    }
}


repositories {
    mavenCentral()
}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-aop'


    // -- DATABASE start
    implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3'
    implementation 'com.mysql:mysql-connector-j:8.0.32'
    // -- DATABASE end


    implementation "org.apache.tomcat.embed:tomcat-embed-jasper"

    implementation 'org.apache.tiles:tiles-jsp:3.0.8'
    implementation 'org.apache.tiles:tiles-core:3.0.8'
    implementation 'org.apache.tiles:tiles-servlet:3.0.8'



    implementation 'com.navercorp.lucy:lucy-xss-servlet:2.0.1'
    implementation 'com.navercorp.lucy:lucy-xss:1.6.3'
    implementation 'org.apache.commons:commons-text:1.8'


    implementation group: 'org.apache.tika', name: 'tika-core', version: '2.8.0'
    implementation group: 'org.apache.tika', name: 'tika-parsers', version: '2.8.0', ext: 'pom'



    // log4j
    implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'
//    logback
    implementation 'ch.qos.logback:logback-classic:1.2.6'



    compileOnly 'org.projectlombok:lombok:1.18.24'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'


    runtimeOnly 'com.mysql:mysql-connector-j'
    annotationProcessor 'org.projectlombok:lombok'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
//    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

    // https://mvnrepository.com/artifact/org.wildfly/wildfly-ejb-client-bom
//    implementation group: 'org.wildfly', name: 'wildfly-ejb-client-bom', version: '25.0.0.Final', ext: 'pom'

    // Exclude spring-boot-starter-tomcat and add javax.servlet-api
//    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') {
//        exclude module: 'tomcat-embed-core'
//        exclude module: 'tomcat-embed-el'
//        exclude module: 'tomcat-embed-websocket'
//    }
//    providedRuntime 'javax.servlet:javax.servlet-api'
//    implementation('org.springframework.boot:spring-boot-starter-tomcat') {
//        exclude module: 'spring-boot-starter-tomcat'
//        exclude group: 'commons-logging', module: 'commons-logging'
//        exclude module: 'tomcat-embed-core'
//    }
    implementation 'org.reactivestreams:reactive-streams:1.0.1'
// https://mvnrepository.com/artifact/org.wildfly/wildfly-servlet-feature-pack
//    compileOnly group: 'org.wildfly', name: 'wildfly-servlet-feature-pack', version: '24.0.1.Final', ext: 'pom'


//    implementation 'org.springframework.boot:spring-boot-starter-undertow'

//    implementation 'javax.servlet:javax.servlet-api:3.1.0'

    providedRuntime 'javax.servlet:javax.servlet-api:3.1.0'


    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testCompileOnly 'org.projectlombok:lombok'
    testAnnotationProcessor 'org.projectlombok:lombok'

    //junit
    testImplementation("org.junit.platform:junit-platform-launcher:1.5.2")
    testImplementation("org.junit.jupiter:junit-jupiter:5.5.2")

    //ioutil
    implementation group: 'commons-io', name: 'commons-io', version: '2.13.0'
    implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.4' /* Apache Commons FileUpload */





}

java tomcat servlets server wildfly
1个回答
0
投票

我对此不太确定,但是在 Payara(服务器)上部署时,您将面临与 Tomcat 与您的环境冲突相关的问题,我认为 JBoss 就是这种情况,请尝试检查您的依赖项排除并确保您的依赖项是不会在您的服务器上造成冲突。

© www.soinside.com 2019 - 2024. All rights reserved.