RE: Odd classloader behavior in Tomcat 4.x

2003-02-24 Thread Shapira, Yoav

Howdy,
See intermixed.

I'm having trouble executing a JSP page that is throwing
NoClassDefFoundError for a class that it should find.  The JSP page
instantiates an object via the tag:

One of the keys to understanding this issue is understanding the
difference between a ClassNotFound and a NoClassDefFound errors.  The
JavaDocs for the two have some more details.

The class ipa.LoginBean is in WEB-INF/lib/ipa.jar.  However, it
references
a
class com.ibm.db.Statement which I've placed in
$CATALINA_HOME/shared/lib/ivjdab35.jar in my Tomcat 4.1.8 server (I
also
have it in $CATALINA_HOME/lib/ivjdab35.jar in my Tomcat 4.0.6 server).

Do you mean 4.1.18 instead of 4.1.8?  Assuming that you do, try moving
the ivjdab25.jar from shared/lib to common/lib.

This is totally IMHO, but I don't like putting anything in the
common/lib or shared/lib directories.  Two reasons:
- I like the principal of self-containment for web applications.  One
war file with everything, without needing to rely on server-specific
magic directories.
- Several server implementations (not just tomcat) seem to have bugs in
this complicated classloading implementation.

I can't figure out why the servlet engine can compile the page but not
run
it.

It's a pain of a classloading issue.  There is more than one related
open Bugzilla issue around this if you care to search there.
Essentially, the classpath for Jasper is NOT that same as the runtime
classpath for the compiled servlet.

Furthermore, the behavior between the 4.0.6 and 4.1.8 server is
different

True, but that's valid.

Lastly, if I copy ivjdab35.jar into WEB-INF/lib, it works properly
every
time.

See my above preference for this approach anyways.  The benefits from
putting anything in a common/lib type directory are negligible at best.

Yoav Shapira
Millennium ChemInformatics



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Odd classloader behavior in Tomcat 4.x

2003-02-22 Thread Richard Sand
Hi all,

I'm having trouble executing a JSP page that is throwing
NoClassDefFoundError for a class that it should find.  The JSP page
instantiates an object via the tag:

jsp:useBean id=loginBean class=ipa.LoginBean scope=session/

The class ipa.LoginBean is in WEB-INF/lib/ipa.jar.  However, it references a
class com.ibm.db.Statement which I've placed in
$CATALINA_HOME/shared/lib/ivjdab35.jar in my Tomcat 4.1.8 server (I also
have it in $CATALINA_HOME/lib/ivjdab35.jar in my Tomcat 4.0.6 server).

The .java file for the JSP page compiles to a .class file fine, but then it
throws the exception as follows:

Line 58 of the .java file is:

java.lang.NoClassDefFoundError: com/ibm/db/Statement at
java.lang.Class.getDeclaredConstructors0(Native Method) at
java.lang.Class.privateGetDeclaredConstructors(Class.java:1590) at
java.lang.Class.getConstructor0(Class.java:1762) at
java.lang.Class.newInstance0(Class.java:276) at
java.lang.Class.newInstance(Class.java:259) at
java.beans.Beans.instantiate(Beans.java:204) at
java.beans.Beans.instantiate(Beans.java:48) at
org.apache.jsp.index_jsp._jspService(index_jsp.java:58) ...

loginBean = (ipa.LoginBean)
java.beans.Beans.instantiate(this.getClass().getClassLoader(),
ipa.LoginBean);

I can't figure out why the servlet engine can compile the page but not run
it.

Furthermore, the behavior between the 4.0.6 and 4.1.8 server is different as
well.  On 4.0.6, I get the error only the first time that I access the page
after restarting Tomcat.  Subsequent requests succeed!  On 4.1.8, it fails
every request.

Lastly, if I copy ivjdab35.jar into WEB-INF/lib, it works properly every
time.

Am I being obtuse here and fundamentally misunderstanding how Tomcat's
classloader works, or is something odd occuring here?

Thanks for any help!

Best regards,

Richard


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]