Spring MVC project cannot publish and run ... Message: failed to view annotations

I have a Spring MVC application (version 4.1.1-Release). When I try to publish and run on the server, I get the error below.

Additional Information

  • Using Spring Tool Suite 3.6.1
  • Spring version 4.1.1-RELEASE
  • This is a maven project
  • It has no compilation errors
  • when i do mvn clean install the build is successful

org.springframework.beans.factory.BeanCreationException: error creating a bean with the name 'homeController' defined in the 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]: Error after processing bean type [class com.abc.project.HomeController] failed; java.lang.IllegalStateException nested exception: Failed to view annotations: public java.lang.String com.abc.project.HomeController.hello () at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFeforyAappeAutoryFutoryAutoryFutoryAutoryFutoryPautaFeoryPautaFeoryaputAboreAporyAporyAutoryFeoryaputAbepAnapeForyaputaEporyaputAporyAporyAutoryFeoryaputaeporyapostaputaepeoryapory ) in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.javahaps13) in org.springframework.beans.factory.support.ebreanFeanBeanFeBeanBeanFeBanAbstractAutstractFutaBeanFeBeanFeBeanFeBeanFeBeanFeBeanFeBeanBeanFeBeanBeanFeBeanFeBeanBeanFeBeanBeanFeBeanFeBeBeanBeanFeBeanBeanBeanBeanFeBeanBeanBeanBeanFeobabeBeanBeanBeanFeobabeBeanBeanFeobabeBeanBeanBeanFeBanBanBanBanBanBanBanBanBanBanBanBanBanBan, Andrun factory.support.AbstractBeanFactory $ 1.getObject (AbstractBeanFactory.java:302) in org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:229.anet.betanBeans.eetanBean.EbetanBeanEbetEBeanBeanBeanBeanBeanBeanBeanBeansBeanBeansBetanBean.beet.beet. (AbstractBeanFactory.java:298) in org.spri ngframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:193) in org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons. Default PrefistableBeanFactory.ava finishBeanFactoryInitialization (AbstractApplicationContext.java:918) in org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:469) in org.springframework.web.context.ContextLoader.configureAndrefrefrefrendrefreader .web. : 4760) in org.apache.catalina.core.StandardContext.startInternal (StandardContext.java//184) in org.apache.catal ina.util.LifecycleBase.start (LifecycleBase.java:150) in org.apache.catalina.core.ContainerBase.addChildInternal (ContainerBase.java:724) in org.apache.catalina.core.ContainerBase.addChild (ContainerBase.java: 700) in org.apache.catalina.core.StandardHost.addChild (StandardHost.java:714) in org.apache.catalina.startup.HostConfig.deployDescriptor (HostConfig.javahaps81) in org.apache.catalina.startup.HostConfig $ DeployDescriptor.run (HostConfig.java:1686) in java.util.concurrent.Executors $ RunnableAdapter.call (Executors.java:471) in java.util.concurrent.FutureTask.run (FutureTask.java:262) in java. util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145) in java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:615) on java.lang.Thread.run (Thread.java:745) Called: java.lang.IllegalStateException: could not view annotations: public java.lang.String com.abc.project.HomeController.hello () at org.spri ngframework.core.annotation. java: 85) in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiredAnnotation (AutowiredAnnotationBeanPostProcessor.java:416) in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.buildAutowiringMetadata (AutowiredAnnotationBeanPostProcessor.java:388) in org.springframework .beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata (AutowiredAnnotationBeanPostProcessor.javahaps58) in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorpentationanostationanentationanostationbanentationposteranentationposteranentationposteranentationposteranentationposteranentostanentationpostereanostationposteranentostanentanentationpostereanostonerostananostationpostereanostonerostanentostanentationbostaneanostationpostoronostanentostanetostanentationpostoronanostationnostationnostationnote ory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors (AbstractAutowireCapableBeanFactory.java:924) ... 25 more Caused: java.lang.NoSuchMethodError / org.jnotnotationUnnotationUnnotationUnnotationInnotationInnotationInationationInnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationation org.springframework.core.annotation.AnnotatedElementUtils.process (AnnotatedElementUtils.java:162) ... another 32 october 29, 2014 21 org.apache.catalina.core.StandardContext listenerStart SEVERE: Event triggered event of sending an exception for the listener instance class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: error creating bean named 'homeController' about defined in the 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]: Error after processing bean type [class com.abc.project.HomeController] failed; java.lang.IllegalStateException nested exception: Failed to view annotations: public java.lang.String com.abc.project.HomeController.hello () at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFeforyAappeAutoryFutoryAutoryFutoryAutoryFutoryPautaFeoryPautaFeoryaputAboreAporyAporyAutoryFeoryaputAbepAnapeForyaputaEporyaputAporyAporyAutoryFeoryaputaeporyapostaputaepeoryapory ) in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.javahaps13) in org.springframework.beans.factory.support.ebreanFeanBeanFeBeanBeanFeBanAbstractAutstractFutaBeanFeBeanFeBeanFeBeanFeBeanFeBeanFeBeanBeanFeBeanBeanFeBeanFeBeanBeanFeBeanBeanFeBeanFeBeBeanBeanFeBeanBeanBeanBeanFeBeanBeanBeanBeanFeobabeBeanBeanBeanFeobabeBeanBeanFeobabeBeanBeanBeanFeBanBanBanBanBanBanBanBanBanBanBanBanBanBan, Andrun factory.support.AbstractBeanFactory $ 1.getObject (AbstractBeanFactory.java:302) in org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:229.anet.betanBeans.eetanBean.EbetanBeanEbetEBeanBeanBeanBeanBeanBeanBeanBeansBeanBeansBetanBean.beet.beet. (AbstractBeanFactory.java:298) in org.spri ngframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:193) in org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons. Default PrefistableBeanFactory.ava finishBeanFactoryInitialization (AbstractApplicationContext.java:918) in org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:469) in org.springframework.web.context.ContextLoader.configureAndrefrefrefrendrefreader .web. : 4760) in org.apache.catalina.core.StandardContext.startInternal (StandardContext.java//184) in org.apache.catal ina.util.LifecycleBase.start (LifecycleBase.java:150) in org.apache.catalina.core.ContainerBase.addChildInternal (ContainerBase.java:724) in org.apache.catalina.core.ContainerBase.addChild (ContainerBase.java: 700) in org.apache.catalina.core.StandardHost.addChild (StandardHost.java:714) in org.apache.catalina.startup.HostConfig.deployDescriptor (HostConfig.javahaps81) in org.apache.catalina.startup.HostConfig $ DeployDescriptor.run (HostConfig.java:1686) in java.util.concurrent.Executors $ RunnableAdapter.call (Executors.java:471) in java.util.concurrent.FutureTask.run (FutureTask.java:262) in java. util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145) in java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:615) on java.lang.Thread.run (Thread.java:745) Called: java.lang.IllegalStateException: could not view annotations: public java.lang.String com.abc.project.HomeController.hello () at org.spri ngframework.core.annotation. java: 85) in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiredAnnotation (AutowiredAnnotationBeanPostProcessor.java:416) in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.buildAutowiringMetadata (AutowiredAnnotationBeanPostProcessor.java:388) in org.springframework .beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata (AutowiredAnnotationBeanPostProcessor.javahaps58) in org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorpentationanostationanentationanostationbanentationposteranentationposteranentationposteranentationposteranentationposteranentostanentationpostereanostationposteranentostanentanentationpostereanostonerostananostationpostereanostonerostanentostanentationbostaneanostationpostoronostanentostanetostanentationpostoronanostationnostationnostationnote ory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors (AbstractAutowireCapableBeanFactory.java:924) ... 25 more Caused: java.lang.NoSuchMethodError / org.jnotnotationUnnotationUnnotationUnnotationInnotationInnotationInationationInnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationationnotationation org.springframework.core.annotation.AnnotatedElementUtils.doProcess (AnnotatedElementUtils.java:208) in org.springframework.core.annotation.AnnotatedElementUtils.process (AnnotatedElementUtils.java:162) ... 32 more

+9
spring spring-mvc
source share
5 answers

I had this error when I imported through @import a class that was not deployed to the server. Unfortunately, the stack does not tell you which class is missing, but you can figure it out by deleting them one by one and reloading the application.

Now, why should the class not be deployed on the server if the project really compiles?

EDIT : I found out that I had a problem when import uses a class that is in the classpath through a dependency on Maven. I also had this dependency (project) tested in Eclipse. In this case, it seems that Eclipse will deploy the project, which will be verified instead of building from the repository. He will not look at the external dependence of this project.

Decision. Close all external dependency projects in Eclipse to make sure that you are actually deploying the version from the Maven repository.

+12
source share

You may be missing

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

in applicationContext.xml OR

 @ComponentScan("com.example") 

if you are doing code-based configuration.

+2
source share

I had old versions of spring libraries in my WEB-INF / lib. I deleted everything in the lib folder and tried to create and publish. It worked.

Thanks.

+2
source share

Judging by the stack trace, you are mixing different versions of Spring. java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;) is an indicator for this.

Check your dependencies and make sure you are not using conflicting versions.

General rule: never mix jars of different versions of the framework (in this case, Spring, but the same applies, for example, to Hibernate).

0
source share

Please check if you have added all the necessary dependencies.

0
source share

All Articles