java - Failed to import bean definitions from URL location [classpath:applicationContext-core.xml] -
i'm working on java project spring on eclipse using maven, , running on tomcat server v6.0. working fine since yesterday morning.
here problem : i'm building project, got build success. start tomcat server , got error :
org.springframework.beans.factory.parsing.beandefinitionparsingexception: configuration problem: failed import bean definitions url location [classpath:applicationcontext- core.xml]
offending resource: servletcontext resource [/web-inf/applicationcontext.xml]; nested exception org.springframework.beans.factory.beandefinitionstoreexception: ioexception parsing xml document class path resource [applicationcontext-core.xml]; nested exception java.io.filenotfoundexception: class path resource [applicationcontext-core.xml] cannot opened because not exist
i found out similar problem on website none of them give me solution worked me.
it seems eclipse isn't able find applicationcontext-core.xml when i'm doing :
<import resource="classpath:applicationcontext-core.xml" />
however, have needed jar file nad-core-0.0.1-snapshot.jar in web-inf/lib containing applicationcontext-core.xml.
i tried add manually classpath still having same problem.
i keep on looking solution, when suddendly work again once after restarting eclipse , building while eclipse still updating indexes , project having strange status hg status pending instead of default. surprised result decide build again project after restarting eclipse , got error again , enable make work again. it's quite annoying...
this looks random problem.
thanks lot :)
as you've not specified web application structure. assume you've simple web application @ hand following structures
- webapp
- web-inf/classes/applicationcontext.xml
- web-inf/lib/nad-core-0.0.1-snapshot.jar/applicationcontext-core.xml
application context.xml refers applicationcontext-core.xml file using import tag. did encounter similar situation in web application, here're check lists should go through , may 1 of them can apply situation.
- check generated snapshot jar file applicationcontext-core.xml file , make sure in root directory of jar. silly sounds, root cause of issue faced in deployment.
- make sure maven pom.xml file configured include xml file resources folder. can use resource tags in build phase of maven package them within jar file itself.
- you can try removing import tag application context.xml file , instead load both of them spring's webapplication context itself.
- add context loader listener class spring
org.springframework.web.context.contextloaderlistener
- add context-param contextconfiglocation value classpath:applicationcontext-core.xml,classpath:applicationcontext.xml. spring has ability dynamically sort out dependencies before initiating bean factory.
- add context loader listener class spring
hope check list helps.
Comments
Post a Comment