ClassLoader issue

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

ClassLoader issue

Sandip Ghayal
I have been trying to use Jetty 5.1.3 with my application.

And for uniformity purpose decided to replace Jetty's classloader with my
classloader.

My classloader extends java.net.URLClassLoader and has its own method for
loading class and find resources etc. But usually relies on URLClassLoader to do
most of the work here. Only in case of URL failing to load the resource my
classloader will load the resource.

When using this I am facing a strange issue.

My entire application runs properly on Windows platform but not on Solaris,

On Solaris I get exception as below when trying to start the context.

On the other hand if I use jetty's classloader everything works properly.

"mydir" present in the stack trace is the actual directory where the jarfiles
and other resources are installed. So I am not sure why this is happening. I
also experienced similar problem during getResourceAsStream. I used to pass the
call to URLClassLoader to find the resource but then doing openStream() on the
returned URL I would get similar error. To fix this issue I ended up loading the
file myself instead of passing it to URL ClassLoader. But in the case below I
have no control. I don't even know what URL is being loaded. as my classloader
didn't even get a call to load anything or find any URL.

Any clues or pointers ? Also I was looking at xerces 2.6 code and this part
where the error currently is happening has been changed quite a bit. I was
wondering has any one tired using 2.6 code for xerces with Jetty ?

2005-06-03 13:33:23.597 ERROR main [ActionServlet] Parsing error processing reso
urce path /WEB-INF/struts-config.xml
2005-06-03 13:33:23.597 ERROR main     Caused by: java.net.UnknownHostException:
 mydir
2005-06-03 13:33:23.597 ERROR main     | at java.net.PlainSocketImpl.connect(Pla
inSocketImpl.java:153)
2005-06-03 13:33:23.597 ERROR main     | at java.net.Socket.connect(Socket.java:
452)
2005-06-03 13:33:23.597 ERROR main     | at java.net.Socket.connect(Socket.java:
402)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.NetworkClient.doConnect(Netw
orkClient.java:139)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.NetworkClient.openServer(Net
workClient.java:118)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.ftp.FtpClient.openServer(Ftp
Client.java:423)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.ftp.FtpClient.<init>(FtpClie
nt.java:692)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.ftp.FtpURLConne
ction.connect(FtpURLConnection.java:175)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.ftp.FtpURLConne
ction.getInputStream(FtpURLConnection.java:257)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.ftp.FtpURLConne
ction.getInputStream(FtpURLConnection.java:257)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.URLJarFile.
retrieve(URLJarFile.java:161)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.URLJarFile.
getJarFile(URLJarFile.java:42)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.JarFileFact
ory.get(JarFileFactory.java:53)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.JarURLConne
ction.connect(JarURLConnection.java:85)
2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.JarURLConne
ction.getInputStream(JarURLConnection.java:107)
2005-06-03 13:33:23.597 ERROR main     | at java.net.URL.openStream(URL.java:913
)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
ger.setupCurrentEntity(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
ger.startEntity(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
ger.startDTDEntity(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
ger.startDTDEntity(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLDTDScanner
Impl.setInputSource(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLDocumentSc
annerImpl$DTDDispatcher.dispatch(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLDocumentFr
agmentScannerImpl.scanDocument(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.DTDConfigu
ration.parse(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.DTDConfigu
ration.parse(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.XMLParser.
parse(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.AbstractSA
XParser.parse(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.commons.digester.Digester
.parse(Digester.java:1548)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.struts.action.ActionServl
et.parseModuleConfigFile(ActionServlet.java:708)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.struts.action.ActionServl
et.initModuleConfig(ActionServlet.java:670)
2005-06-03 13:33:23.597 ERROR main     | at org.apache.struts.action.ActionServl
et.init(ActionServlet.java:329)
2005-06-03 13:33:23.597 ERROR main     | at javax.servlet.GenericServlet.init(Ge
nericServlet.java:168)
2005-06-03 13:33:23.597 ERROR main     | at web.components.WebConsole.action.ini
t(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at web.components.WebConsole.action_DJC
.init(action_DJC.java:150)
2005-06-03 13:33:23.597 ERROR main     | at web.components.WebConsole.action$WC.
init(Unknown Source)
2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.ServletHol
der.initServlet(ServletHolder.java:383)
2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.ServletHol
der.start(ServletHolder.java:243)
2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.ServletHan
dler.initializeServlets(ServletHandler.java:445)
2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.WebApplica
tionHandler.initializeServlets(WebApplicationHandler.java:323)
2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.WebApplica
tionContext.doStart(WebApplicationContext.java:511)
2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.util.Container.start(Con
tainer.java:72)

Thanks for your help,

Cheers,

Sandip



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: ClassLoader issue

Heiner Westphal
Sandip,

either you got an URL 'ftp://mydir/...', or there is
an url  'mydir/...' and the default URL schema somehow
became 'ftp:' instead of 'file:'.

Sorry no real help, but perhaps it points your search into
the right direction.

HTH,

Heiner

Sandip wrote:

> I have been trying to use Jetty 5.1.3 with my application.
>
> And for uniformity purpose decided to replace Jetty's classloader with my
> classloader.
>
> My classloader extends java.net.URLClassLoader and has its own method for
> loading class and find resources etc. But usually relies on URLClassLoader to do
> most of the work here. Only in case of URL failing to load the resource my
> classloader will load the resource.
>
> When using this I am facing a strange issue.
>
> My entire application runs properly on Windows platform but not on Solaris,
>
> On Solaris I get exception as below when trying to start the context.
>
> On the other hand if I use jetty's classloader everything works properly.
>
> "mydir" present in the stack trace is the actual directory where the jarfiles
> and other resources are installed. So I am not sure why this is happening. I
> also experienced similar problem during getResourceAsStream. I used to pass the
> call to URLClassLoader to find the resource but then doing openStream() on the
> returned URL I would get similar error. To fix this issue I ended up loading the
> file myself instead of passing it to URL ClassLoader. But in the case below I
> have no control. I don't even know what URL is being loaded. as my classloader
> didn't even get a call to load anything or find any URL.
>
> Any clues or pointers ? Also I was looking at xerces 2.6 code and this part
> where the error currently is happening has been changed quite a bit. I was
> wondering has any one tired using 2.6 code for xerces with Jetty ?
>
> 2005-06-03 13:33:23.597 ERROR main [ActionServlet] Parsing error processing reso
> urce path /WEB-INF/struts-config.xml
> 2005-06-03 13:33:23.597 ERROR main     Caused by: java.net.UnknownHostException:
>  mydir
> 2005-06-03 13:33:23.597 ERROR main     | at java.net.PlainSocketImpl.connect(Pla
> inSocketImpl.java:153)
> 2005-06-03 13:33:23.597 ERROR main     | at java.net.Socket.connect(Socket.java:
> 452)
> 2005-06-03 13:33:23.597 ERROR main     | at java.net.Socket.connect(Socket.java:
> 402)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.NetworkClient.doConnect(Netw
> orkClient.java:139)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.NetworkClient.openServer(Net
> workClient.java:118)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.ftp.FtpClient.openServer(Ftp
> Client.java:423)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.ftp.FtpClient.<init>(FtpClie
> nt.java:692)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.ftp.FtpURLConne
> ction.connect(FtpURLConnection.java:175)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.ftp.FtpURLConne
> ction.getInputStream(FtpURLConnection.java:257)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.ftp.FtpURLConne
> ction.getInputStream(FtpURLConnection.java:257)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.URLJarFile.
> retrieve(URLJarFile.java:161)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.URLJarFile.
> getJarFile(URLJarFile.java:42)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.JarFileFact
> ory.get(JarFileFactory.java:53)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.JarURLConne
> ction.connect(JarURLConnection.java:85)
> 2005-06-03 13:33:23.597 ERROR main     | at sun.net.www.protocol.jar.JarURLConne
> ction.getInputStream(JarURLConnection.java:107)
> 2005-06-03 13:33:23.597 ERROR main     | at java.net.URL.openStream(URL.java:913
> )
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
> ger.setupCurrentEntity(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
> ger.startEntity(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
> ger.startDTDEntity(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLEntityMana
> ger.startDTDEntity(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLDTDScanner
> Impl.setInputSource(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLDocumentSc
> annerImpl$DTDDispatcher.dispatch(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.impl.XMLDocumentFr
> agmentScannerImpl.scanDocument(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.DTDConfigu
> ration.parse(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.DTDConfigu
> ration.parse(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.XMLParser.
> parse(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.xerces.parsers.AbstractSA
> XParser.parse(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.commons.digester.Digester
> .parse(Digester.java:1548)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.struts.action.ActionServl
> et.parseModuleConfigFile(ActionServlet.java:708)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.struts.action.ActionServl
> et.initModuleConfig(ActionServlet.java:670)
> 2005-06-03 13:33:23.597 ERROR main     | at org.apache.struts.action.ActionServl
> et.init(ActionServlet.java:329)
> 2005-06-03 13:33:23.597 ERROR main     | at javax.servlet.GenericServlet.init(Ge
> nericServlet.java:168)
> 2005-06-03 13:33:23.597 ERROR main     | at web.components.WebConsole.action.ini
> t(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at web.components.WebConsole.action_DJC
> .init(action_DJC.java:150)
> 2005-06-03 13:33:23.597 ERROR main     | at web.components.WebConsole.action$WC.
> init(Unknown Source)
> 2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.ServletHol
> der.initServlet(ServletHolder.java:383)
> 2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.ServletHol
> der.start(ServletHolder.java:243)
> 2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.ServletHan
> dler.initializeServlets(ServletHandler.java:445)
> 2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.WebApplica
> tionHandler.initializeServlets(WebApplicationHandler.java:323)
> 2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.jetty.servlet.WebApplica
> tionContext.doStart(WebApplicationContext.java:511)
> 2005-06-03 13:33:23.597 ERROR main     | at org.mortbay.util.Container.start(Con
> tainer.java:72)
>
> Thanks for your help,
>
> Cheers,
>
> Sandip
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
> a projector? How fast can you ride your desk chair down the office luge track?
> If you want to score the big prize, get to know the little guy.  
> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss