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

Expert 2.5K+
P: 3,112
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;
  5. public class ServletBean {
  6.     public ServletBean(){}
  7.     public ServletBean(String xmlPath)
  8.     {
  9.         ...
  10.     }
  11.     ...
  12. }
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.     }
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);
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 ternalDoFilter(
at Filter(
at org.apache.catalina.core.StandardWrapperValve.invo ke(
at org.apache.catalina.core.StandardContextValve.invo ke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke (
at org.apache.catalina.core.StandardEngineValve.invok e(
at org.apache.catalina.connector.CoyoteAdapter.servic e(
at org.apache.coyote.http11.Http11Processor.process(H
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt
at Socket(
at ead.runIt(
at org.apache.tomcat.util.threads.ThreadPool$ControlR
at 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

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.