I've never seen this at all.

Most likely the "runnable" that is stuck on the executor, or the executor 
itself, is not recording the thead context classloader or similar.   Do you 
have control over the creation of that runnable?   (I've never looked at the 
procrun stuff)   If so, could you grab the context classloader at runnable 
creation time (on the original thread) and then in the first line of the run 
method set the context classloader to it on that background thread?    I'm not 
really sure if that will help, but it might.  Alternatively, in the run 
method, try calling Thread.currentThread().setContextClassloader(null) to 
force it null to try using the system classpath.  The spi.FactoryFinder stuff 
pretty much all use the context classloader so if that isn't "correct", it 
might cause a problem.

Dan



On Thu February 11 2010 5:11:16 am Alexander Schutz wrote:
> Hi,
> 
> I implemented a basic web service (standalone, embedded into jetty, Java
> 1.6.0_18 , CXF 2.2.6) and now want to deploy it as a Windows service.
> To this end I'm trying to use procrun/commons daemon to install and run
> the windows service, which then calls out to a Java class that launches
> the web service.
> 
> When I use the Windows service start button, or run the procrun/prunsrv
> exectuable from the command line to start the Windows service, I can see
> a bit logging for initialisation going on, but when the code enters the
> line
> 
>   Endpoint.create(..)
> 
>  the process exits with
> 
>   Exception in thread "pool-1-thread-1"
> java.lang.ExceptionInInitializerError
> 
>  and
> 
>   Caused by: javax.xml.bind.JAXBException
>    - with linked exception:
>   [java.lang.ClassNotFoundException: com/sun/xml/bind/v2/ContextFactory]
> 
>  (see stack trace given further below)
> 
> I have put some additional logging to check the resources on the class
> path, and just before
>   Endpoint.create(..)
>  is called, ContextFactory _is_ found by the Class Loader (as are any
> other possible CXF dependencies):
> 
>   Class clazz = Class.forName("com.sun.xml.bind.v2.ContextFactory");
>   logger.log(Level.INFO, "##### " + clazzs + " found ##### " +
> clazz.getPackage());
> 
>   INFO: ##### com.sun.xml.bind.v2.ContextFactory found ##### package
> com.sun.xml.bind.v2, Java Architecture for XML Binding, version 2.1
> 
> When I start the application from the command line not using
> procrun/prunsrv, by calling
>   java -jar ...
> everything works fine.
> 
> 
> The way the launcher class works is by invoking a
> java.util.concurrent.ExecutorService which starts the Runnable that
> starts the web service.
> 
> I had a look through the past 6 months of archives, and could only find
> posts that were remotely - if at all - related to my problem.
> 
> Has anyone come across this?
> 
> Thanks,
> Alex
> 
> Stack trace from above:
> 
> Exception in thread "pool-1-thread-1"
> java.lang.ExceptionInInitializerError
>       at java.lang.Class.forName0(Native Method)
>       at java.lang.Class.forName(Unknown Source)
>       at javax.xml.ws.spi.FactoryFinder.safeLoadClass(Unknown Source)
>       at javax.xml.ws.spi.FactoryFinder.newInstance(Unknown Source)
>       at javax.xml.ws.spi.FactoryFinder.find(Unknown Source)
>       at javax.xml.ws.spi.Provider.provider(Unknown Source)
>       at javax.xml.ws.Endpoint.publish(Unknown Source)
>       at
> com.avaya.cc8.ebws.EbwsPortType_EbwsSOAPportHttp_Server.<init>(EbwsPortT
> ype_EbwsSOAPportHttp_Server.java:101)
>       at com.avaya.cc8.soawrapper.Starter.run(Starter.java:85)
>       at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
>       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)
>       at java.lang.Thread.run(Unknown Source)
> Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext
> for W3CEndpointReference.
>       at com.sun.xml.internal.ws.spi.ProviderImpl$2.run(Unknown
> Source)
>       at com.sun.xml.internal.ws.spi.ProviderImpl$2.run(Unknown
> Source)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at
> com.sun.xml.internal.ws.spi.ProviderImpl.getEPRJaxbContext(Unknown
> Source)
>       at com.sun.xml.internal.ws.spi.ProviderImpl.<clinit>(Unknown
> Source)
>       ... 12 more
> Caused by: javax.xml.bind.JAXBException
>  - with linked exception:
> [java.lang.ClassNotFoundException: com/sun/xml/bind/v2/ContextFactory]
>       at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
>       at javax.xml.bind.ContextFinder.find(Unknown Source)
>       at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
>       at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
>       ... 17 more
> Caused by: java.lang.ClassNotFoundException:
> com/sun/xml/bind/v2/ContextFactory
>       at java.lang.Class.forName0(Native Method)
>       at java.lang.Class.forName(Unknown Source)
>       at javax.xml.bind.ContextFinder.safeLoadClass(Unknown Source)
>       ... 21 more

-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to