I'm working on a project using tomcat and spring. Now I have written a Bean class, which reads an XML-File via Springs XmlBeanFactory, creates a Vector from the collected Information and then passes it on. So far, so good.
Simplified, my Bean looks like this:
Expand|Select|Wrap|Line Numbers
- import org.springframework.beans.factory.BeanFactory;
- import org.springframework.beans.factory.xml.XmlBeanFactory;
- import org.springframework.core.io.FileSystemResource;
- public class ServletBean {
- public ServletBean(){}
- public ServletBean(String xmlPath)
- {
- ...
- }
- ...
- }
Expand|Select|Wrap|Line Numbers
- public static void main(String[] args) {
- String xmlPath = "E:\\workspace\\CSG-Update-Server\\WEB-INF" + File.separator + "beans.xml";
- ServletBean servlet = new ServletBean(xmlPath);
- for(int i=0;i<servlet.collect().size();i++)
- {
- ...
- }
- }
Expand|Select|Wrap|Line Numbers
- String xml = "E:\\workspace\\Project\\WEB-INF" + File.separator + "beans.xml";
- if(new File(xmlPath).exists()) System.out.println("**** File found");
- else System.out.println("**** File not found");
- ServletProductBean test = new ServletProductBean(xmlPath);
**** File found
Servlet.service () for servlet myServlet threw exception
java.lang.NoCla ssDefFoundError : org/springframework/core/io/Resource
at com.csg.remotin g.server.myServ let.doPost(mySe rvlet.java:81)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:710)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:803)
at org.apache.cata lina.core.Appli cationFilterCha in.internalDoFi lter(Applicatio nFilterChain.ja va:269)
at org.apache.cata lina.core.Appli cationFilterCha in.doFilter(App licationFilterC hain.java:188)
at org.apache.cata lina.core.Stand ardWrapperValve .invoke(Standar dWrapperValve.j ava:210)
at org.apache.cata lina.core.Stand ardContextValve .invoke(Standar dContextValve.j ava:174)
at org.apache.cata lina.core.Stand ardHostValve.in voke(StandardHo stValve.java:12 7)
at org.apache.cata lina.valves.Err orReportValve.i nvoke(ErrorRepo rtValve.java:11 7)
at org.apache.cata lina.core.Stand ardEngineValve. invoke(Standard EngineValve.jav a:108)
at org.apache.cata lina.connector. CoyoteAdapter.s ervice(CoyoteAd apter.java:151)
at org.apache.coyo te.http11.Http1 1Processor.proc ess(Http11Proce ssor.java:870)
at org.apache.coyo te.http11.Http1 1BaseProtocol$H ttp11Connection Handler.process Connection(Http 11BaseProtocol. java:665)
at org.apache.tomc at.util.net.Poo lTcpEndpoint.pr ocessSocket(Poo lTcpEndpoint.ja va:528)
at org.apache.tomc at.util.net.Lea derFollowerWork erThread.runIt( LeaderFollowerW orkerThread.jav a:81)
at org.apache.tomc at.util.threads .ThreadPool$Con trolRunnable.ru n(ThreadPool.ja va:685)
at java.lang.Threa d.run(Unknown Source)
(Line 81 in the servlet is ServletProductB ean test = new ServletProductB ean(xml);)
I have checked and checked again, the spring.jar is in the classpath (so this isn't the problem), the main method (which is in the same project with the same classpath etc.) has no problems finding it, but it just won't work with the Servlet.
Does anybody have an idea?