• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Struggling to run code ( java . lang . NoClassDefFoundError: )

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working in linux. I'm able to compile code but not run it. The generated error type is java.lang.NoClassDefFoundError. I know that the error is generated because java can't find the byte code after the code is compiled.
All the byte code is in "/var/tomcat/bin" and I try to run it from this directory. The defined directories are below. Is there anything else I need to add to the directories?
CLASSPATH =
/var/tomcat/webapps/axis/WEB-INF/lib/axis.jar:
/var/tomcat/webapps/axis/WEB-INF/lib/wsdl4j.jar:
/var/tomcat/webapps/axis/WEB-INF/lib/clutil.jar:
/var/tomcat/webapps/axis/WEB-INF/lib/xerces.jar:
/var/tomcat/webapps/axis/WEB-INF/lib/log4j-core.jar:
/usr/java /j2sdk1.4.2_01 /bin
JAVA_HOME = /usr/java/j2sdk1.4.2_01
PATH = /usr/local/bin:
/usr/bin:
/bin:
/usr/X11R6/bin:
/home/simon/bin:
/usr/java/j2sdk1.4.2_01/bin/
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly what are your trying to run here? A SOAP client?
There is a findingclasses.html page in the SDK docs/tooldocs directory you may find useful.
Bill
 
GeofferyR Durham
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry its taken so long to get back to you bill. It is a soap client. I found the problem though. I needed to add server.jar found in the tomcat folder to the classpath.
I am having another problem though. I am trying to create an additional context to the tomcat web server. The context seems to have been initialized in the startup of tomcat. However when I type this url; http://localhost:8080/bg/ByteBourmetServer it should invoke a servlet page that would appear in the browser. It doesn't do this, but it generates the following error in the browser:
Not Found (404)
Original request: /bg/ByteGourmetServer
Not found request: /bg/ByteGourmetServer
In the terminal it generates this error:
2003-10-27 11:08:58 - Ctx(/bg) : Status code:404 request:R( /bg +/ByteGourmetServer + null) msg:null
I think the problem is in the web.xml deployment descriptor and where to put the compiled class code so that it can be located when initializing the bg context.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure you are correct, it just isn't recognizing your web applications.
The following points occur to me:
1. be sure to put your servlet class in a package
2. be sure to follow the convention for locating your web.xml and class files under the WEB-INF subdirectory - see the examples that come with Tomcat. It really pays to have the complete servlet API documentation - you can download a pdf file from java.sun.com - but you have to hunt because they keep fooling around with the organization.
Start at java.sun.com/products/servlet
3. you will have to restart tomcat to get it to see changes in web.xml, (or use the management application)
Bill
 
GeofferyR Durham
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
Thanks again for replying. Those guidelines were definitely a help. I reckon its the right area to be concerned with. I tried to create a jar file to make things simpler.
I put all my java files into a package called myServlets. In the CLASSPATH along with all the other concerned directories, I typed

export CLASSPATH = /var/tomcat/webapps/bg/WB_INF/lib/myServlets.jar
This is my web.xml file in WB_INF file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!--Define servlets that are included in the ByteGourmet application -->
<servlet>
<servlet-name>ByteGourmetServer</servlet-name>
<servlet-class>myServlets.ByteGourmetServer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ByteGourmetServer</servlet-name>
<url-pattern>
/ByteGourmetServer
</url-pattern>
</servlet-mapping>
</web-app>
The jar file structure in myServlets.jar looks like this:
myServlets/*.class
Could you give directions on where to find the standard servlet directory.
Thanks
Geof.
[ October 28, 2003: Message edited by: GeofferyR Durham ]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand the question, the convention is that all webapplications are under the tomcat/webapps directory unless otherwise specified in the server.xml file. Note that Tomcat does not pay any attention to your environment CLASSPATH setting.
Bill
 
GeofferyR Durham
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
Found most of the problems. Miss types in the CLASSPATH and a lack of understanding in other areas. Thanks for helping. Thanks for the additional info. It helped alot.
Cheers
Geof
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic