遇到了一个神奇的bug,在开发环境能好好运行的jar,到生产环境启动的时候报Error creating bean with name 'XXXX' defined in URL的异常,并且每次都是报的同一个类找不到,试了各种方法都没能解决,网上也找了很多资料基本无用,异常如下。文章来源:https://www.toymoban.com/news/detail-517592.html
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-02-21 10:07:21.541 ERROR 29664 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nettyExecuter' defined in URL [jar:file:/D:/XinAo/3-dataHandler/DataHandler-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/photon/core/DataHandler/Netty/NettyExecuterImpl.class]: Instantiation of bean failed; nested exception is java.lang.StackOverflowError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1320) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
at com.photon.core.DataHandler.DataHandlerApplication.main(DataHandlerApplication.java:24) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) [DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.StackOverflowError: null
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_171]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_171]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_171]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_171]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_171]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_171]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_171]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[DataHandler-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_171]
at io.netty.util.ConstantPool.<init>(ConstantPool.java:32) ~[netty-all-4.1.45.Final.jar!/:4.1.45.Final]
at io.netty.util.AttributeKey$1.<init>(AttributeKey.java:27) ~[netty-all-4.1.45.Final.jar!/:4.1.45.Final]
at io.netty.util.AttributeKey.<clinit>(AttributeKey.java:27) ~[netty-all-4.1.45.Final.jar!/:4.1.45.Final]
at com.photon.core.DataHandler.Netty.NettyExecuter.<clinit>(NettyExecuter.java:16) ~[classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_171]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:203) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
... 25 common frames omitted
经过多次猜测和尝试,终于发现原因。原来是由于一个服务器跑了多个项目,资源不够用,所以每个jar包都设置了启动参数,最终是原因启动参数中给该jar包的资源不足,修改了启动参数后,顺利运行起来文章来源地址https://www.toymoban.com/news/detail-517592.html
到了这里,关于解决Error creating bean with name ‘XXXX‘ defined in URL的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!