473,654 Members | 3,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NoClassDefFound Error where there shouldn't be one

Nepomuk
3,112 Recognized Expert Specialist
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.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?
Aug 22 '07 #1
1 6421
Nepomuk
3,112 Recognized Expert Specialist
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
167097
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 gives me the same exception. What could be the problem? Thanks in advance, Lem
1
9109
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 version 1.4.0 and WMQ Series version 5.3 with CSD04. Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/server/MQSESSION at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:67) at...
1
47606
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 java1.4.2_04 (JIT: null) My Java version is:
0
1723
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 and created data base instance. I am able sucessfully play with the DB2 related commands.
1
987
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 it ? Help please?
4
3126
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 my Apache logfile: Attempting to load any page on my webserver results in a segfault. Whee.
3
2203
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 I execute it from the command prompt I get a NoClassDefFoundError. Here is the stack trace: Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/jdbc/sq lserver/SQLServerDriver at...
1
2492
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 server and tried and create the deployment descriptor.. I am getting the error below even after I set the classpath. Is there any other correct way to set the classpath? C:\bea\jdk150_04\bin\ejb\demo>set...
4
14719
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 "appframework-1.0.3.jar;swing-worker-1.1.jar";CurrentStrobe.jar com.visionpro.currentstrobe.CurrentStrobeApp However, the statement below produces the error: java -cp "appframework-1.0.3.jar;swing-worker-1.1.jar" -jar CurrentStrobe.jar Exception in thread "main"...
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8594
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.