By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

NoClassDefFoundError where there shouldn't be one

Nepomuk
Expert 2.5K+
P: 3,112
Hi!
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
  1. import org.springframework.beans.factory.BeanFactory;
  2. import org.springframework.beans.factory.xml.XmlBeanFactory;
  3. import org.springframework.core.io.FileSystemResource;
  4.  
  5. public class ServletBean {
  6.     public ServletBean(){}
  7.     public ServletBean(String xmlPath)
  8.     {
  9.         ...
  10.     }
  11.     ...
  12. }
  13.  
When I call this bean with a Class including a main method like this one here:
Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) {
  2.         String xmlPath = "E:\\workspace\\CSG-Update-Server\\WEB-INF" + File.separator + "beans.xml";
  3.         ServletBean servlet = new ServletBean(xmlPath);
  4.         for(int i=0;i<servlet.collect().size();i++)
  5.         {
  6.             ...
  7.         }
  8.     }
  9.  
it works without any problems. However, when I have it called by the HTTP Servlet (in the doPost() method) in nearly the same way:
Expand|Select|Wrap|Line Numbers
  1. String xml = "E:\\workspace\\Project\\WEB-INF" + File.separator + "beans.xml";
  2. if(new File(xmlPath).exists()) System.out.println("**** File found");
  3. else System.out.println("**** File not found");
  4. ServletProductBean test = new ServletProductBean(xmlPath);
  5.  
it gives me the runtime-error:
**** 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?
Aug 22 '07 #1
Share this Question
Share on Google+
1 Reply


Nepomuk
Expert 2.5K+
P: 3,112
OK, Tomcat didn't know where to find spring.jar - that's that error solved. ^^
Aug 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.