This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post your spring-servlet.xml.
You have posted web.xml twice.
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your web.xml, change the below part

to,

and remove the contextloaderlistener in web.xml, it's not needed..
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you remove the below part in web.xml and check
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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



Getting the same error..
 
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you building the project, do use ANT or Maven or anything else?
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, then can you try cleaning the eclipse workspace.
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Krishnegowda wrote:Ok, then can you try cleaning the eclipse workspace.



I tried clean build option and tried in new project also .I checked after restarting my PC and eclipse also. still problem occurs
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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..

 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not able to find anything in logs..
Can you try deploying the war file to tomcat outside eclipse manually, and see if the exception is still coming.
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Krishnegowda wrote:Not able to find anything in logs..
Can you try deploying the war file to tomcat outside eclipse manually, and see if the exception is still coming.



I am deployed my war file into tomcat web apps folder and still error exists
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using JDK1.8?
If Yes, you should upgrade to Spring 4.
 
Rengasamy Athali
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Krishnegowda wrote:Are you using JDK1.8?
If Yes, You should upgrade to Spring 4.



Thank you prasad ..finally it's working fine..once again thank you for Continuously helping me.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rengasamy Athali wrote:Thank you prasad ..finally it's working fine..once again thank you for Continuously helping me.


Welcome Brother.. Glad to know its working
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rengasamy Athali wrote:

Prasad Krishnegowda wrote:Are you using JDK1.8?
If Yes, You should upgrade to Spring 4.



Thank you prasad ..finally it's working fine..once again thank you for Continuously helping me.




@Rengasamy Athali.. The same error occured for me. Could you please let me know how do you fix the issue.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The solution is mentioned in the thread, he was using JDK1.8, so solution was to upgrade Spring to version 4.x

If you are still facing any error after this, please create a new thread telling all the details and appropriate error messages.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!