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.NoClassDefFoundError: org/springframework/core/io/Resource
at com.csg.remoting.server.myServlet.doPost(myServlet .java:81)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Unknown Source)
(Line 81 in the servlet is ServletProductBean test = new ServletProductBean(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?