相关文章推荐
Hi,

I am new to spring and I am trying to run the sample spring MVC with annotations application in my local but I am getting the Context initialization failed exception. Please find my files and error de

Error Log :


SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [C:\REngasamy\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Spring3MVC\WEB-INF\classes\net\viralpatel\spring3\controller\HelloWorldController.class]; nested exception is java.lang.IllegalArgumentException
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)


Web.xml



spring-servlet.xml



HelloWorldController.java



index.jsp




Please find the jar list which I am using for my my project.
1.commons-collections-2.1.1.jar
2.commons-logging-1.1.1.jar
3.spring-beans-3.2.1.RELEASE.jar
4.spring-context-3.2.1.RELEASE.jar
5.spring-core-3.2.1.RELEASE.jar
6.spring-expression-3.2.1.RELEASE.jar
7.spring-web-3.2.1.RELEASE.jar
8.spring-webmvc-3.2.1.RELEASE.jar



Server: Tomcat 8
IDE : ECLIPSE : Luna Service Release 1 (4.4.1)

Please help me to solve the issue ?

Thanks,
Rengasamy Athali
Prasad Krishnegowda wrote: can you post your spring-servlet.xml.
You have posted web.xml twice.

Prasad Krishnegowda wrote: can you post your spring-servlet.xml.
You have posted web.xml twice.



Thank you Prasad for the quick response.

Please find my files.
Web.xml



spring-servlet.xml



Thanks,
Rengasamy Athali
In your web.xml, change the below part

to,

and remove the contextloaderlistener in web.xml, it's not needed..
Prasad Krishnegowda wrote: In your web.xml, change the below part

to,

and remove the contextloaderlistener in web.xml, it's not needed..



Hi Prasad,

Still getting the same error after changing the URL pattern . Please find my latest web.xml.

can you remove the below part in web.xml and check
Prasad Krishnegowda wrote: can you remove the below part in web.xml and check



Getting the same error..
Jayesh A Lalwani wrote: It's a weird error. SPring is scanning the classpath to find classes with annotations. It finds your controller, but is unable to load the class. How are you building the class?



Jayesh,I have pasted all my jar files into jar folder under \WebContent\WEB-INF\lib and added those jars as External jar files to my project using Project-->Preference--> Java Build Path-->Libraries-->Add external Jars option.
1.I created simple java class (for controller) file and added annotations in my controller.
2.I have compiled my programs using the build All option in eclipse.

Prasad Krishnegowda wrote: How are you building the project, do use ANT or Maven or anything else?


I haven't use any tool to build my project and I am trying to run my project in eclipse and I have configured the tomcat 8 with eclipse. I am trying run my project using the Add/Remove project option in eclipse.
Prasad Krishnegowda wrote: Can you paste the entire stack trace, whole log file of the tomcat also should do..

P:S: Please use Code Tags while posting stack trace/log files.



Prasad please find my whole console log..

 
推荐文章