You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Eric Harbeston <ha...@gmail.com> on 2006/05/30 22:54:33 UTC

ClassNotFoundException after successful Servlet run

Greetings,

For the past few-several days I have been scouring the internet and this
list extensively to no avail.  First I'll describe the error and then give
as much detail as possible about the structure of our web-app project as
possible.  Before I came to work on this project, it was running fine on a
tomcat 4.1 server by simply having all class files in a single jar file,
however it wasn't being managed very well and was being developed in Windows
even though our deployment was to be in Red Hat, so I decided to get the
project into Netbeans under a Red Hat VM with tomcat 5.5 and after a day had
it compiling and reporting no errors (there were plenty of errors when first
imported into netbeans).  But ever since then, its always been the same
problem with tomcat not being able to detect the class necessary for loading
the GUI.

After proper authentication with a db2 database, our servlets call up an
html page with an embedded applet in a new window (we've even tried loading
in the same window).  This applet has given me a ClassNotFoundException in
every instance I have tried.  I am using Netbeans 5.0 and it correctly
places all class files in the classes directory under WEB-INF with correct
package directory appearance and all jar library files in the lib
directory.  All of our program's custom classes now belong to a single
package, including the servlets (originally all custome classes had no
package), 3rd party classes are in their appopriate packages as well (they
are now in jars in the lib dir), and the whole thing compiles without any
errors.  The tomcat servers also starts without any errors, and both the
standalone and bundled Netbeans tomcats always give this same error in every
instance as well.  The Netbeans output tab shows that the user is being
appropriately authenticated after logging in and checking against the
database within our servlet (which also uses other classes within our
package).  After attempting the load the applet the only thing in netbeans
which indicates a problem has occurred is upon inspection of the HTTP
requests, which shows that two requests failed:
/ONLINEBOM/olb/HomeMenu.class and /ONLINEBOM/olb/HomeMenu/class.class.  The
former seems like it should be correct, since I assume netbeans
automatically sets correct classpaths and such. The latter is an inexistant
file whose lookup doesn't really seem to affect this particular problem.

the standard structure of the files is as follows:
-the olb package is in WEB-INF/classes/olb/*.class
-all 3rd party libraries are in WEB-INF/lib/*.jar
-the web.xml file with the servlet declaration stuff is in WEB-INF
-html files are in the root directory of the project

the html file which calls the applet contains the following in its body:
<applet CODEBASE="olb" CODE="HomeMenu.class" WIDTH="400"
HEIGHT="280"></applet>
I have also tried not using codebase and placing in CODE both "
olb.HomeMenu.class" and "olb/HomeMenu.class".  I have also tried using the
ARCHIVE options when trying this and other attempts described below.


I have tried the following besides the standard for placement of
classes/packages:
-placing all classes in a single jar file (in lib, classes, or even in the
root folder for the webapp where the html is)
-placing our classes in one jar, 3rd party classes in 2 other jars (in lib,
classes, etc.)
-placing all classes in the directory structure without the use of jars (in
classes directory and lib)
-placing all classes/jars in the shared/classes and shared/lib tomcat
directories (when attempted with the standalone tomcat server)


Is this just a simple CLASSPATH problem? I assumed it wasn't from reading
that tomcat sets its own classpath anyway.  Is it entirely the fault of the
servlet?  Is there some other configuration settings I'm entirely missing
here?  I would really, completely, and utterly appreciate some help which
could get this poor web-app back on its feet and ready for continued
development.

Thanks!

Eric Harbeston

Re: ClassNotFoundException after successful Servlet run

Posted by Marc Farrow <ma...@gmail.com>.
the CODEBASE tag is for use of the base to where the code is located.  This
should be URL or even relative to your html page.  Also, the CODE tag needs
to be the fully package qualified name of the class such as
com.mycompany.mypackage.MyClass.class (I think the .class extension could be
left off).  You can use the ARCHIVE tag if the classes are in a JAR.  Also
below is the HTML specs link for OBJECT tag (since the applet tag is
deprecated but still usable).

try this:

<applet CODEBASE="http://localhost/mydeploymentjarlocation" Archive="
myjar.jar" CODE="olb.HomeMenu" WIDTH="400"
HEIGHT="280"></applet>

http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html


On 5/30/06, Eric Harbeston <ha...@gmail.com> wrote:
>
> Greetings,
>
> For the past few-several days I have been scouring the internet and this
> list extensively to no avail.  First I'll describe the error and then give
> as much detail as possible about the structure of our web-app project as
> possible.  Before I came to work on this project, it was running fine on a
> tomcat 4.1 server by simply having all class files in a single jar file,
> however it wasn't being managed very well and was being developed in
> Windows
> even though our deployment was to be in Red Hat, so I decided to get the
> project into Netbeans under a Red Hat VM with tomcat 5.5 and after a day
> had
> it compiling and reporting no errors (there were plenty of errors when
> first
> imported into netbeans).  But ever since then, its always been the same
> problem with tomcat not being able to detect the class necessary for
> loading
> the GUI.
>
> After proper authentication with a db2 database, our servlets call up an
> html page with an embedded applet in a new window (we've even tried
> loading
> in the same window).  This applet has given me a ClassNotFoundException in
> every instance I have tried.  I am using Netbeans 5.0 and it correctly
> places all class files in the classes directory under WEB-INF with correct
> package directory appearance and all jar library files in the lib
> directory.  All of our program's custom classes now belong to a single
> package, including the servlets (originally all custome classes had no
> package), 3rd party classes are in their appopriate packages as well (they
> are now in jars in the lib dir), and the whole thing compiles without any
> errors.  The tomcat servers also starts without any errors, and both the
> standalone and bundled Netbeans tomcats always give this same error in
> every
> instance as well.  The Netbeans output tab shows that the user is being
> appropriately authenticated after logging in and checking against the
> database within our servlet (which also uses other classes within our
> package).  After attempting the load the applet the only thing in netbeans
> which indicates a problem has occurred is upon inspection of the HTTP
> requests, which shows that two requests failed:
> /ONLINEBOM/olb/HomeMenu.class and
> /ONLINEBOM/olb/HomeMenu/class.class.  The
> former seems like it should be correct, since I assume netbeans
> automatically sets correct classpaths and such. The latter is an
> inexistant
> file whose lookup doesn't really seem to affect this particular problem.
>
> the standard structure of the files is as follows:
> -the olb package is in WEB-INF/classes/olb/*.class
> -all 3rd party libraries are in WEB-INF/lib/*.jar
> -the web.xml file with the servlet declaration stuff is in WEB-INF
> -html files are in the root directory of the project
>
> the html file which calls the applet contains the following in its body:
> <applet CODEBASE="olb" CODE="HomeMenu.class" WIDTH="400"
> HEIGHT="280"></applet>
> I have also tried not using codebase and placing in CODE both "
> olb.HomeMenu.class" and "olb/HomeMenu.class".  I have also tried using the
> ARCHIVE options when trying this and other attempts described below.
>
>
> I have tried the following besides the standard for placement of
> classes/packages:
> -placing all classes in a single jar file (in lib, classes, or even in the
> root folder for the webapp where the html is)
> -placing our classes in one jar, 3rd party classes in 2 other jars (in
> lib,
> classes, etc.)
> -placing all classes in the directory structure without the use of jars
> (in
> classes directory and lib)
> -placing all classes/jars in the shared/classes and shared/lib tomcat
> directories (when attempted with the standalone tomcat server)
>
>
> Is this just a simple CLASSPATH problem? I assumed it wasn't from reading
> that tomcat sets its own classpath anyway.  Is it entirely the fault of
> the
> servlet?  Is there some other configuration settings I'm entirely missing
> here?  I would really, completely, and utterly appreciate some help which
> could get this poor web-app back on its feet and ready for continued
> development.
>
> Thanks!
>
> Eric Harbeston
>
>


-- 
Marc Farrow

Re: ClassNotFoundException after successful Servlet run

Posted by Eric Harbeston <ha...@gmail.com>.
Thanks guys,

I placed the classes and jars in a code directory at the same level as the
HTML and fixed the applet tag accordingly, and now I'm back on track again.
I appreciate the swift and informative responses!

Eric

Re: JKMount with Tomcat and Access Restriction

Posted by Mark Thomas <ma...@apache.org>.
When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. To many of the list archiving services and mail clients
used by list subscribers this  makes your new message appear as part
of the old thread. This makes it harder for other users to find
relevant information when searching the lists.

This is known as thread hijacking and is behaviour that is frowned
upon on this list. Frequent offenders will be removed from the list.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.

The correct procedure is to create a new message with a new subject.
This will start a new thread.

Mark
tomcat-user-owner


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


JKMount with Tomcat and Access Restriction

Posted by Peter Neu <pe...@gmx.net>.
Hello,

I need to configure an ip filter for my tomcat/httpd server. Thus I need to
tell the httpd server to deny access for users of certain ip ranges. I
looked into the documentation of the connector but could not come up with a
working method. 
Has anyone tried to do this before? Is there a way to conditionally mount
certain URL's?

Httpd 2.0.49
Tomcat 5.5.9
Java 1.5.0_04-b05

Cheers,
Pete



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ClassNotFoundException after successful Servlet run

Posted by David Smith <dn...@cornell.edu>.
According to your description below, you've placed the files correctly 
for server-side execution, but not for client side execution.  Per 
servlet spec, the client does not have any direct access to anything in 
the WEB-INF directory.  Your applet's classes need to be placed 
somewhere else or made available via a servlet that can grant the client 
limited access to WEB-INF.

Try seeing what happens when the applet classes are stored outside of 
WEB-INF.

--David

Eric Harbeston wrote:

> Greetings,
>
> For the past few-several days I have been scouring the internet and this
> list extensively to no avail.  First I'll describe the error and then 
> give
> as much detail as possible about the structure of our web-app project as
> possible.  Before I came to work on this project, it was running fine 
> on a
> tomcat 4.1 server by simply having all class files in a single jar file,
> however it wasn't being managed very well and was being developed in 
> Windows
> even though our deployment was to be in Red Hat, so I decided to get the
> project into Netbeans under a Red Hat VM with tomcat 5.5 and after a 
> day had
> it compiling and reporting no errors (there were plenty of errors when 
> first
> imported into netbeans).  But ever since then, its always been the same
> problem with tomcat not being able to detect the class necessary for 
> loading
> the GUI.
>
> After proper authentication with a db2 database, our servlets call up an
> html page with an embedded applet in a new window (we've even tried 
> loading
> in the same window).  This applet has given me a 
> ClassNotFoundException in
> every instance I have tried.  I am using Netbeans 5.0 and it correctly
> places all class files in the classes directory under WEB-INF with 
> correct
> package directory appearance and all jar library files in the lib
> directory.  All of our program's custom classes now belong to a single
> package, including the servlets (originally all custome classes had no
> package), 3rd party classes are in their appopriate packages as well 
> (they
> are now in jars in the lib dir), and the whole thing compiles without any
> errors.  The tomcat servers also starts without any errors, and both the
> standalone and bundled Netbeans tomcats always give this same error in 
> every
> instance as well.  The Netbeans output tab shows that the user is being
> appropriately authenticated after logging in and checking against the
> database within our servlet (which also uses other classes within our
> package).  After attempting the load the applet the only thing in 
> netbeans
> which indicates a problem has occurred is upon inspection of the HTTP
> requests, which shows that two requests failed:
> /ONLINEBOM/olb/HomeMenu.class and 
> /ONLINEBOM/olb/HomeMenu/class.class.  The
> former seems like it should be correct, since I assume netbeans
> automatically sets correct classpaths and such. The latter is an 
> inexistant
> file whose lookup doesn't really seem to affect this particular problem.
>
> the standard structure of the files is as follows:
> -the olb package is in WEB-INF/classes/olb/*.class
> -all 3rd party libraries are in WEB-INF/lib/*.jar
> -the web.xml file with the servlet declaration stuff is in WEB-INF
> -html files are in the root directory of the project
>
> the html file which calls the applet contains the following in its body:
> <applet CODEBASE="olb" CODE="HomeMenu.class" WIDTH="400"
> HEIGHT="280"></applet>
> I have also tried not using codebase and placing in CODE both "
> olb.HomeMenu.class" and "olb/HomeMenu.class".  I have also tried using 
> the
> ARCHIVE options when trying this and other attempts described below.
>
>
> I have tried the following besides the standard for placement of
> classes/packages:
> -placing all classes in a single jar file (in lib, classes, or even in 
> the
> root folder for the webapp where the html is)
> -placing our classes in one jar, 3rd party classes in 2 other jars (in 
> lib,
> classes, etc.)
> -placing all classes in the directory structure without the use of 
> jars (in
> classes directory and lib)
> -placing all classes/jars in the shared/classes and shared/lib tomcat
> directories (when attempted with the standalone tomcat server)
>
>
> Is this just a simple CLASSPATH problem? I assumed it wasn't from reading
> that tomcat sets its own classpath anyway.  Is it entirely the fault 
> of the
> servlet?  Is there some other configuration settings I'm entirely missing
> here?  I would really, completely, and utterly appreciate some help which
> could get this poor web-app back on its feet and ready for continued
> development.
>
> Thanks!
>
> Eric Harbeston
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org