Spring Boot Error Creating bean with name: Lookup method resolution failed to introspect class from classloader

我正在开发一个 Spring 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 文件中添加了以下条带依赖项:

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

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

stack overflow Spring Boot Error creating bean with name: Lookup method resolution failed Fail to introspect class from classloader
原文答案

答案:

作者头像

这可能是因为您的项目可能正在使用一些依赖项目来快速使用 Maven 再次安装该项目然后运行,希望它可以解决您的问题!

相关问题