Spring boot No class DefFound net / bytebuddy / dynamic / loading / ClassLoadingStrategy

时间:2019-03-17 12:23:11

标签: java spring tomcat

我需要一些帮助。在tomcat上部署spring应用程序时,出现以下异常:

 17-Mar-2019 12:50:21.482 INFORMAZIONI [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [C:\Users\vince\develop\apache-tomcat-8.5.38\webapps\reportingsystem.war]
17-Mar-2019 12:50:22.013 GRAVE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/reportingsystem]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: net/bytebuddy/dynamic/loading/ClassLoadingStrategy
        at com.vaadin.flow.server.startup.ApplicationRouteRegistry.createRegistry(ApplicationRouteRegistry.java:361)
        at com.vaadin.flow.server.startup.ApplicationRouteRegistry.getInstance(ApplicationRouteRegistry.java:211)
        at com.vaadin.flow.server.startup.RouteRegistryInitializer.onStartup(RouteRegistryInitializer.java:43)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5272)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more
Caused by: java.lang.ClassNotFoundException: net.bytebuddy.dynamic.loading.ClassLoadingStrategy
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1185)
        ... 15 more

17-Mar-2019 12:50:22.013 GRAVE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [C:\Users\vince\develop\apache-tomcat-8.5.38\webapps\reportingsystem.war]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/reportingsystem]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:758)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

17-Mar-2019 12:50:22.029 INFORMAZIONI [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [C:\Users\vince\develop\apache-tomcat-8.5.38\webapps\reportingsystem.war] has finished in [547] ms
17-Mar-2019 12:50:22.029 INFORMAZIONI [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
17-Mar-2019 12:50:22.045 INFORMAZIONI [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
17-Mar-2019 12:50:22.045 INFORMAZIONI [main] org.apache.catalina.startup.Catalina.start Server startup in 619 ms

这是我的build.gradle文件:

 plugins {
    id 'org.springframework.boot' version '2.1.3.RELEASE'
    id 'java'
    id 'net.researchgate.release' version '2.6.0'
    id 'war'
}


war {
    enabled = true
}

apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.researchgate.release'
apply plugin: 'war'

repositories {
    mavenCentral()
    maven {
        url 'http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts'
    }
}

sourceSets {
    main {
        resources {

        }
    }
}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-cache' //NO
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa' // SI
    implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'//NO
    implementation 'org.springframework.boot:spring-boot-starter-security' //NO
    implementation 'org.springframework.boot:spring-boot-starter-web' //NO

    implementation platform(group: "com.vaadin", name: "vaadin-bom", version: bomVersions_vaadin)
    implementation 'com.vaadin:vaadin-spring-boot-starter' // SI

    implementation 'io.springfox:springfox-swagger2:2.9.2' //SI
    implementation 'io.springfox:springfox-swagger-ui:
    implementation 'net.sf.jasperreports:jasperreports:6.7.1'
    implementation ('net.sf.jasperreports:jasperreports-fonts:6.0.0')

    runtimeOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'mysql:mysql-connector-java'
    runtimeOnly 'com.h2database:h2:1.4.196'

    compileOnly 'org.projectlombok:lombok:1.18.6'
    annotationProcessor 'org.projectlombok:lombok:1.18.6'
    runtimeOnly group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

我的application.property文件:

## Logging
logging.level.org.springframework.web=INFO
logging.level.org.springframework.ws.client.MessageTracing.sent=trace
logging.level.org.springframework.ws.client.MessageTracing.received=TRACE

# Naming strategy
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.show-sql=false
spring.jpa.generate-ddl=false
spring.jpa.hibernate.ddl-auto=none
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
#spring.jpa.properties.hibernate.connection.provider_disables_autocommit=true
spring.jmx.default-domain=reportingsystem

#useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
## LOCAL DB
spring.datasource.url=jdbc:mysql://localhost:3306/develop?useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&useJDBCCompliantTimezoneShift=true
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect


# Hikari Datasource
spring.datasource.hikari.maximum-pool-size=20
spring.datasource.hikari.connection-timeout=5000
spring.datasource.hikari.minimum-idle=15
spring.datasource.hikari.pool-name=HikariConnectionPool

spring.jpa.properties.hibernate.connection.charSet=UTF-8
spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor

spring.profiles.active=local
security.basic.enabled=false
security.ignored=/**

我还注意到net / bytebuddy / dynamic / loading / ClassLoadingStrategy存在于不同的模块中,例如,我在io.springfox:springfox-swagger2:2.9.2',org.springframework.boot:spring-boot中找到了它-starter-data-jpa和com.vaadin:vaadin-spring-boot-starter。我试图将其排除在外,但没有任何反应,但我遇到了同样的例外。

有什么可以帮助我吗? 提前致谢。

1 个答案:

答案 0 :(得分:0)

您的堆栈跟踪告诉您com.vaadin.flow.server.startup.ApplicationRouteRegistry类无法加载所需的net.bytebuddy.dynamic.loading.ClassLoadingStrategy类。

仅凭您的build.gradle很难说出正在发生什么。将Vaadin与Spring Boot集成存在一些已知问题,例如Spring boot overrides ByteBuddy version

您必须找到哪个依赖项提供了ApplicationRouteRegistry,并且其中之一:

  1. 弄清楚为什么WAR中不包括字节预算传递依赖项。可能是您的Vaadin依赖项之一损坏了pom.xml
  2. 如果不需要,请删除ApplicationRouteRegistry