axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edward Blazer <5.10madn...@gmail.com>
Subject Re: ClassLoader NPE
Date Mon, 16 Jan 2006 00:54:04 GMT
Dims,

Great idea. I did just that and it worked for the most part, but I also had
to tweak ClassLoaders.java around line 46.

public ClassLoader get(int idx) {
        ClassLoader cl = (ClassLoader)classLoaders.elementAt(idx);
        try {
            cl.toString();
            return cl;
        } catch (NullPointerException e) {
            return Thread.currentThread
().getContextClassLoader().getParent();
        }
    }

It seems that the vector of ClassLoader's had a reference to the ClassLoader
that was used for the containers first deployment, but when the container
was stopped, that classLoader should have been thrown away. So, on
redeployment, this method would return that old classloader which wasn't
null, but also didn't work. i.e. (cl == null) would return false, but
cl.toString() would throw the NPE for the 'dead' reference (is there a
better term for this?). Anyway, it's not pretty, but it works for my needs.

Thanks!

On 1/15/06, Davanum Srinivas <davanum@gmail.com> wrote:
>
> Please get the latest sources for commons-discovery and build it
> yourself to see if that works. I remember some check-ins, but don't
> remember if there was a release after that.
>
> thanks,
> dims
>
> On 1/15/06, Edward Blazer <5.10madness@gmail.com> wrote:
> > Hi,
> >
> > I've googled the topic to death but can't find a solution to the
> infamous
> > NullPointerException caused by Axis/Commons-Discovery during a servlet
> > restart (error occurs for many different vendors; jboss, jetty, others?)
> My
> > application has an embedded server (jetty) for serving Axis WebServices,
> but
> > also acts as a client of web-services. I've discovered that if I remove
> the
> > Axis libraries from the applications classpath that it can restart
> without
> > error, however this causes a problem when the application tries to
> consume
> > web-services since Axis isn't in the classpath.
> >
> > Any ideas?
> >
> > Thanks
> >
> > java.lang.NullPointerException
> >     at
> > org.mortbay.http.ContextLoader.getResource(ContextLoader.java:257)
> >     at
> > org.apache.commons.discovery.jdk.JDK12Hooks.getResources
> > (JDK12Hooks.java :149)
> >     at
> >
> org.apache.commons.discovery.resource.DiscoverResources$1.getNextResources
> (DiscoverResources.java:153)
> >     at
> >
> org.apache.commons.discovery.resource.DiscoverResources$1.getNextResource(
> DiscoverResources.java
> > :129)
> >     at
> > org.apache.commons.discovery.resource.DiscoverResources$1.hasNext(
> DiscoverResources.java:116)
> >     at
> >
> org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassNames
> (DiscoverNamesInFile.java
> > :186)
> >     at
> >
> org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassName
> (DiscoverNamesInFile.java:170)
> >     at
> >
> org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.hasNext(
> DiscoverNamesInFile.java
> > :157)
> >     at
> >
> org.apache.commons.discovery.resource.names.NameDiscoverers$1.getNextIterator
> (NameDiscoverers.java:143)
> >     at
> > org.apache.commons.discovery.resource.names.NameDiscoverers$1.hasNext(
> NameDiscoverers.java
> > :126)
> >     at
> >
> org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.getNextResource
> (ResourceClassDiscoverImpl.java:159)
> >     at
> >
> org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.hasNext
> > (ResourceClassDiscoverImpl.java:147)
> >     at
> > org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(
> EngineConfigurationFactoryFinder.java:120)
> >     at java.security.AccessController.doPrivileged(Native
> > Method)
> >     at
> >
> org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(
> EngineConfigurationFactoryFinder.java:113)
> >     at
> > org.apache.axis.transport.http.AxisServletBase.getEngineEnvironment(
> AxisServletBase.java
> > :273)
> >     at
> > org.apache.axis.transport.http.AxisServletBase.getEngine(
> AxisServletBase.java:172)
> >     at
> > org.apache.axis.transport.http.AxisServletBase.getOption(
> AxisServletBase.java:396)
> >     at org.apache.axis.transport.http.AxisServletBase.init
> > (AxisServletBase.java:112)
> >     at
> > javax.servlet.GenericServlet.init(GenericServlet.java:168)
> >     at
> > org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java
> :383)
> >     at org.mortbay.jetty.servlet.ServletHolder.start
> > (ServletHolder.java:243)
> >     at
> > org.mortbay.jetty.servlet.ServletHandler.initializeServlets(
> ServletHandler.java:446)
> >     at
> > org.mortbay.jetty.servlet.WebApplicationHandler.initializeServlets(
> WebApplicationHandler.java
> > :321)
> >     at
> > org.mortbay.jetty.servlet.WebApplicationContext.doStart(
> WebApplicationContext.java:509)
> >     at org.mortbay.util.Container.start(Container.java:72)
> >     at org.mortbay.http.HttpServer.doStart(HttpServer.java
> > :708)
> >     at org.mortbay.util.Container.start(Container.java:72)
> >     at JettyTest2.start(JettyTest2.java:35)
> >     at JettyTest2.testDoubleStartStop(JettyTest2.java:30)
> >     at JettyTest2.main(JettyTest2.java:22)
>
>
> --
> Davanum Srinivas : http://wso2.com/blogs/
>

Mime
View raw message