由于 NoClassDefFoundError,启动项目有时会无法启动 [英] boot project would sometimes fail to start due to NoClassDefFoundError

查看:44
本文介绍了由于 NoClassDefFoundError,启动项目有时会无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我会在尝试运行我的 jar 可执行文件时收到以下错误.尝试再次运行它几次最终会成功并且系统会正常工作.据我所知,我的 jar 中只有一个版本的 logback,所以我不相信在运行时会选择旧版本.我的 jar 旁边没有其他文件或文件夹.使用 spring-boot 1.3.8(过去在旧版本中也看到过)

On occasion I'll get the error below when trying to run my jar executable. trying to run it again a few times would eventually succeed and the system would work right. as far as I can tell only one version of logback is packed within my jar, so I don't believe there's an older version picked up while running. there are no other files or folders beside my jar. using spring-boot 1.3.8 (have seen this in older releases as well in the past)

谢谢

2017-01-11 19:02:44.999  WARN 21617 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource com.pany.common.configuration.DatabaseConfig.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.jdbc.DataSourceProperties org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.properties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource.CONFIGURATION_PROPERTIES': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/validator/group/GroupSequenceProvider
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:104)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:61)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.lang.NoClassDefFoundError: ch/qos/logback/classic/spi/ThrowableProxy
        at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:119)
        at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:419)
        at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
        at ch.qos.logback.classic.Logger.log(Logger.java:765)
        at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:216)
        at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:821)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
        at com.pany.common.configuration.ApplicationBuilder.run(ApplicationBuilder.java:48)
        at com.pany.ServerMain.main(ServerMain.java:16)
        ... 8 more
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:104)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:61)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
        ... 3 more
Caused by: java.lang.NoClassDefFoundError: ch/qos/logback/classic/spi/ThrowableProxy
        at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:119)
        at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:419)
        at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
        at ch.qos.logback.classic.Logger.log(Logger.java:765)
        at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:216)
        at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:821)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
        at com.pany.common.configuration.MyApplicationBuilder.run(ApplicationBuilder.java:48)
        at com.pany.ServerMain.main(ServerMain.java:16)
        ... 8 more

推荐答案

看来这可以通过将 o/s 级别的最大打开文件数从默认值 1024 提高到更高的值来解决.

It appears that this is solved by raising the max open files at the o/s level from default of 1024 to some higher value.

这篇关于由于 NoClassDefFoundError,启动项目有时会无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆