web app can't load class in system classpath

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

web app can't load class in system classpath

espowers

Hello,

I have a servlet that loads a db2 driver from a db2 library in the system classpath (set using the jetty.class.path system property).

I have recently upgraded from Jetty version 5.0 to version 5.1.4.

I now get a ClassNotFoundException when trying to load the db2 driver from the servlet.

I see from the logs that the context classloader is only looking for the driver in the context classpath and not in the system classpath.

My understanding is that the parent classloader (system) is used after the context classloader
(see class loading problems FAQ: http://www.mortbay.org/jetty/faq?s=250-Configuration&t=200classloading),
so this should work.

How do I access the system classloader from a web app?
I've directly tried:  Class.forName("COM.ibm.db2.app.DB2Driver", true, ClassLoader.getSystemClassLoader())
in the servlet and that does not work either.

Regards,

Eric


This e-mail and any attachments are intended only for the individual or company to which it is addressed and may contain information which is privileged, confidential and prohibited from disclosure or unauthorized use under applicable law. If you are not the intended recipient of this e-mail, you are hereby notified that any use, dissemination, or copying of this e-mail or the information contained in this e-mail is strictly prohibited by the sender. If you have received this transmission in error, please return the material received to the sender and delete all copies from your system.

Reply | Threaded
Open this post in threaded view
|

Re: web app can't load class in system classpath

Greg Wilkins-5

Eric,

If Class.forName does not work, then I suspect that the driver is
not on the system classpath - or more probably the system classpath is
not what you think it is.

Where is the driver actually located?

How have you put that location on the classpath?

How do you start Jetty?

regards


[hidden email] wrote:

>
> Hello,
>
> I have a servlet that loads a db2 driver from a db2 library in the
> system classpath (set using the jetty.class.path system property).
>
> I have recently upgraded from Jetty version 5.0 to version 5.1.4.
>
> I now get a ClassNotFoundException when trying to load the db2 driver
> from the servlet.
>
> I see from the logs that the context classloader is only looking for the
> driver in the context classpath and not in the system classpath.
>
> My understanding is that the parent classloader (system) is used after
> the context classloader
> (see class loading problems FAQ:
> http://www.mortbay.org/jetty/faq?s=250-Configuration&t=200classloading),
> so this should work.
>
> How do I access the system classloader from a web app?
> I've directly tried:  Class.forName("COM.ibm.db2.app.DB2Driver", true,
> ClassLoader.getSystemClassLoader())
> in the servlet and that does not work either.
>
> Regards,
>
> Eric
>
> ------------------------------------------------------------------------
>
> * This e-mail and any attachments are intended only for the individual
> or company to which it is addressed and may contain information which is
> privileged, confidential and prohibited from disclosure or unauthorized
> use under applicable law. If you are not the intended recipient of this
> e-mail, you are hereby notified that any use, dissemination, or copying
> of this e-mail or the information contained in this e-mail is strictly
> prohibited by the sender. If you have received this transmission in
> error, please return the material received to the sender and delete all
> copies from your system. *
>



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Re: web app can't load class in system classpath

espowers

Greg,

The db2 driver is in the /export/home/db2cae/sqllib/java12/db2java.zip library.
Below is my startup script.

#!/bin/csh

setenv DB2INSTANCE db2cae
setenv LD_LIBRARY_PATH /export/home/db2cae/sqllib/lib

# use csh built-in nohup to avoid nohup.out file
nohup \
/lopt/java/bin/java \
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger \
-Dlog4j.configuration=file:///lopt/webf/content/WEB-INF/log4j.properties \
-Djetty.home=/lopt/webf/server \
-Djava.home=/lopt/java/jre \
-Dorg.mortbay.http.Version.paranoid=true \
-Djetty.class.path=/export/home/db2cae/sqllib/java12/db2java.zip \
-jar /lopt/webf/server/etc/start.jar /lopt/webf/server/etc/config.xml &

I used the jetty.class.path property according to the FAQ - 'What system properties can I set for Jetty':
http://www.mortbay.org/jetty/faq?s=250-Configuration&t=350System%20Properties

Thanks for taking a look.




Greg Wilkins <[hidden email]>
Sent by: [hidden email]

08/17/2005 02:06 AM

Please respond to
[hidden email]

To
[hidden email]
cc
Subject
[Jetty-support] Re: web app can't load class in system classpath






Eric,

If Class.forName does not work, then I suspect that the driver is
not on the system classpath - or more probably the system classpath is
not what you think it is.

Where is the driver actually located?

How have you put that location on the classpath?

How do you start Jetty?

regards


[hidden email] wrote:
>
> Hello,
>
> I have a servlet that loads a db2 driver from a db2 library in the
> system classpath (set using the jetty.class.path system property).
>
> I have recently upgraded from Jetty version 5.0 to version 5.1.4.
>
> I now get a ClassNotFoundException when trying to load the db2 driver
> from the servlet.
>
> I see from the logs that the context classloader is only looking for the
> driver in the context classpath and not in the system classpath.
>
> My understanding is that the parent classloader (system) is used after
> the context classloader
> (see class loading problems FAQ:
> http://www.mortbay.org/jetty/faq?s=250-Configuration&t=200classloading),
> so this should work.
>
> How do I access the system classloader from a web app?
> I've directly tried:  Class.forName("COM.ibm.db2.app.DB2Driver", true,
> ClassLoader.getSystemClassLoader())
> in the servlet and that does not work either.
>
> Regards,
>
> Eric
>
> ------------------------------------------------------------------------
>
> * This e-mail and any attachments are intended only for the individual
> or company to which it is addressed and may contain information which is
> privileged, confidential and prohibited from disclosure or unauthorized
> use under applicable law. If you are not the intended recipient of this
> e-mail, you are hereby notified that any use, dissemination, or copying
> of this e-mail or the information contained in this e-mail is strictly
> prohibited by the sender. If you have received this transmission in
> error, please return the material received to the sender and delete all
> copies from your system. *
>



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support