2014-10-29 30 views
7

我有一個Spring MVC應用程序(4.1.1發佈版本)。當我嘗試發佈並在服務器上運行時,我收到下面提到的錯誤。Spring MVC項目無法發佈和運行...消息:未能反省註釋

其他信息

  • 使用Spring工具套件3.6.1
  • Spring版本4.1.1-RELEASE
  • 這是一個Maven項目
  • 它沒有任何編譯錯誤
  • 當我做mvn乾淨安裝,構建成功

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController' defined in file [/home/abc/Tools/sts-bundle/pivotal-tc-server-developer-3.0.0.RELEASE/base-instance/wtpwebapps/project-name/WEB-INF/classes/com/abc/project/HomeController.class]: Post-processing failed of bean type [class com.abc.project.HomeController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect annotations: public java.lang.String com.abc.project.HomeController.hello() at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:929) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1686) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: Failed to introspect annotations: public java.lang.String com.abc.project.HomeController.hello() at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:166) at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:91) at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:85) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiredAnnotation(AutowiredAnnotationBeanPostProcessor.java:416) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.buildAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:388) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:358) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(AutowiredAnnotationBeanPostProcessor.java:233) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:924) ... 25 more Caused by: java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:208) at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:162) ... 32 more Oct 29, 2014 5:00:21 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController' defined in file [/home/abc/Tools/sts-bundle/pivotal-tc-server-developer-3.0.0.RELEASE/base-instance/wtpwebapps/project-name/WEB-INF/classes/com/abc/project/HomeController.class]: Post-processing failed of bean type [class com.abc.project.HomeController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect annotations: public java.lang.String com.abc.project.HomeController.hello() at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:929) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1686) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: Failed to introspect annotations: public java.lang.String com.abc.project.HomeController.hello() at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:166) at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:91) at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:85) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiredAnnotation(AutowiredAnnotationBeanPostProcessor.java:416) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.buildAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:388) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:358) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(AutowiredAnnotationBeanPostProcessor.java:233) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:924) ... 25 more Caused by: java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:208) at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:162) ... 32 more

+0

我們必須看到你的代碼 - 堆棧跟蹤是不夠的 – blackpanther 2014-10-29 11:50:00

+0

從stacktrace來看,你正在混合不同版本的Spring。 'java.lang.NoSuchMethodError:org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)'是指示器。檢查你的依賴關係,並確保你不會引入衝突的版本。 – 2014-10-29 11:57:25

回答

1

你可能在你的applicationContext.xml文件OR

@ComponentScan("com.example") 

註釋丟失

<context:component-scan base-package="org.example"> 

如果你正在做基於代碼的配置。

1

我在我的WEB-INF/lib中有舊版本的彈簧庫。我刪除了lib文件夾中的所有內容,並嘗試構建和發佈。有效。

謝謝。

9

我在通過@import導入未在服務器上部署的類時出現此錯誤。不幸的是,堆棧並沒有告訴你什麼課程缺失,但你可以通過逐個刪除它們並重新啓動你的應用程序來弄清楚。

現在,如果項目實際編譯,爲什麼不在服務器上部署類?

編輯: 我發現我有問題,當導入使用通過Maven依賴關係在類路徑上的類。我也有這個依賴項(項目)在Eclipse中檢出。在這種情況下,Eclipse似乎將部署檢出的項目,而不是從存儲庫中構建。它不會考慮這個項目的外部依賴性。

解決方案:關閉Eclipse中的所有外部依賴項目,以確保您實際從Maven存儲庫部署版本。

+1

我有這個問題,當我關閉導入項目時,它工作。 – vineeth 2017-08-14 06:18:46