Spring Boot Sping Boot 创建名为Bean时出错:无法从classloader内省类

vm0i2vca  于 12个月前  发布在  Spring
关注(0)|答案(1)|浏览(217)

我正在开发一个Sping Boot Web应用程序。在应用程序中,我已经实现了Stripe支付网关。我的应用程序在本地机器上工作正常,但当我将Web应用程序部署到Apache Web服务器时,我得到了下面的错误:

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stripeService': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [wing.rakhi.ecdl.service.StripeService] from ClassLoader [ParallelWebappClassLoader
      context: ecdl
      delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@65b54208
    ]
    2022-04-01 04:27:16.990  INFO 50409 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
    2022-04-01 04:27:16.994  INFO 50409 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-3 - Shutdown initiated...
    2022-04-01 04:27:17.009  INFO 50409 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-3 - Shutdown completed.
    2022-04-01 04:27:17.026  INFO 50409 --- [ost-startStop-1] ConditionEvaluationReportLoggingListener :
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2022-04-01 04:27:17.034 ERROR 50409 --- [ost-startStop-1] o.s.boot.SpringApplication               : Application run failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stripeService': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [wing.rakhi.ecdl.service.StripeService] from ClassLoader [ParallelWebappClassLoader
      context: ecdl
      delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@65b54208
    ]
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1269) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1184) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
            at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171) [spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5225) [catalina.jar:8.5.40]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.40]
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) [catalina.jar:8.5.40]
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) [catalina.jar:8.5.40]
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.40]
            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1135) [catalina.jar:8.5.40]
            at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1869) [catalina.jar:8.5.40]
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_272]
            at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_272]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_272]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_272]
            at java.lang.Thread.run(Thread.java:748) [na:1.8.0_272]
    Caused by: java.lang.IllegalStateException: Failed to introspect Class [wing.rakhi.ecdl.service.StripeService] from ClassLoader [ParallelWebappClassLoader
      context: ecdl
      delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@65b54208
    ]
            at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:507) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:404) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:389) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:248) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            ... 31 common frames omitted
    Caused by: java.lang.NoClassDefFoundError: com/stripe/model/PaymentIntent
            at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_272]
            at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_272]
            at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_272]
            at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
            ... 34 common frames omitted
    Caused by: java.lang.ClassNotFoundException: com.stripe.model.PaymentIntent
            at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364) ~[catalina.jar:8.5.40]
            at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1185) ~[catalina.jar:8.5.40]
            ... 38 common frames omitted
    01-Apr-2022 04:27:17.035 SEVERE [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[/ecdl]]
            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.deployDirectory(HostConfig.java:1135)
            at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1869)
            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: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stripeService': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [wing.rakhi.ecdl.service.StripeService] from ClassLoader [ParallelWebappClassLoader
      context: ecdl
      delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@65b54208
    ]
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1269)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1184)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
            at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
            at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5225)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            ... 10 more
    Caused by: java.lang.IllegalStateException: Failed to introspect Class [wing.rakhi.ecdl.service.StripeService] from ClassLoader [ParallelWebappClassLoader
      context: ecdl
      delegate: false
    ----------> Parent Classloader:
    java.net.URLClassLoader@65b54208
    ]
            at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:507)
            at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:404)
            at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:389)
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:248)
            ... 31 more
    Caused by: java.lang.NoClassDefFoundError: com/stripe/model/PaymentIntent
            at java.lang.Class.getDeclaredMethods0(Native Method)
            at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
            at java.lang.Class.getDeclaredMethods(Class.java:1975)
            at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489)
            ... 34 more
    Caused by: java.lang.ClassNotFoundException: com.stripe.model.PaymentIntent
            at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
            at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1185)
            ... 38 more
    01-Apr-2022 04:27:17.037 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory [/home/tomcat/webapps/ecdl]
     java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ecdl]]
            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.deployDirectory(HostConfig.java:1135)
            at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1869)
            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)

字符串
我还在我的pom.xml文件中添加了下面的stripe依赖:

<dependency>
   <groupId>com.stripe</groupId>
   <artifactId>stripe-java</artifactId>
   <version>20.94.0</version>
</dependency>

我应该怎么做才能运行我的应用程序?请提供一些解决方案。

ffdz8vbo

ffdz8vbo1#

这可能是因为你的项目可能会使用一些依赖项目快速只是maven再次安装项目,然后运行希望它可能会解决你的问题!

相关问题