473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

NoClassDefFoundError where there shouldn't be one

Nepomuk
3,112 Expert 2GB
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
1 6412
Nepomuk
3,112 Expert 2GB
OK, Tomcat didn't know where to find spring.jar - that's that error solved. ^^
Aug 22 '07 #2

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

Similar topics

11
by: Lem | last post by:
I get the error Exception in thread "main" java.lang.NoClassDefFoundError when I type java app2 in the command prompt. I've tried moving to the jre directory and typed java c:\app2\app2, but it...
1
by: Andy Howells | last post by:
Can anybody help me on this? I am getting the below error but have not got a clue why. The file in my classpath eing used has the class that it says is not defined. Any ideas? I am running java...
1
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on...
0
by: shibubaby | last post by:
Hi All, I am trying to compile some embedded SQL using the SQLJ in DB2 environment. My setup is as follows. 1) Fedora Core 5 2)IBM DB2 V8.2 I installed both the client/admin tools in the DB2...
1
by: SolBet | last post by:
Hellow there ! I was working on java programming well but today morning, it compiles successfully. However when I try to execute, it throws an exceptions of NoClassDefFoundError: I can not fix...
4
pbmods
by: pbmods | last post by:
Heya. I just installed PHP-Java-Bridge on my system, but I'm having a hard time getting it to stop crashing Apache. When I activate the 'Java.so' module in php.ini, I get the following error in...
3
by: NamelessNumberheadMan | last post by:
I'm using MyEclipse to make a quick one or two use jar utility file to connect to a database and run some updates. I can get everything to compile fine, and create the jar without an issue, but when...
1
by: Nimesh dadhaniya | last post by:
Hi All, I am trying to learn EJB's on my own. I installed the WebLogic Server Trial version and then wrote the Home Interface, Component Interface and the Bean Class. Now I started the WebLogic...
4
by: jmitch89 | last post by:
I don't why I get this error: Exception in thread "main" java.lang.NoClassDefFoundError The statement below works just fine: java -cp...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.