Hi Richard,

In OpenLiberty, we have our own subclass of the ExtensionManagerBus - and
we pass in the classloader to it's constructor. See [1].

>From the looks of it, you could create your own ExtensionManagerBus
instance in your CxfNonSpringServlet's subclass by overriding the
loadBus(ServletConfig) method.  That method should create a new instance of
the ExtensionManagerBus (with your classloader).

Another alternative might be to set the thread's context classloader to
your classloader.  The default classloader for the ExtensionManagerBus is
the current thread's context classloader.

Hope this helps,

Andy

[1]
https://github.com/OpenLiberty/open-liberty/blob/integration/dev/com.ibm.ws.jaxrs.2.0.common/src/com/ibm/ws/jaxrs20/bus/LibertyApplicationBus.java

On Thu, Oct 19, 2017 at 7:04 AM, Richard Stollar <[email protected]>
wrote:

> Hello,
>
>     Out system uses a custom class-loader but, because of the stack-trace
> (below) we receive in some circumstances, I suspect that CXF does not use
> our ClassLoader which should be the default by the time we initialize CXF.
> We have a *CxfWebServiceServlet* which extends the *CXFNonSpringServlet*
> for deploying JaxWS websevices and looking at the source it uses the BUS to
> get a ClassLoader derived from the BusExtensions.
>
>     How can I ensure that our ClassLoader is always used?  Can I push our
> ClassLoader into the BUS before we start initializing the servlet? Do I
> need to configure/create a BusExtension for this and if so, how? Do you
> have any examples or can you point me at some useful documentation?
>
>
>     Here is the exception:
>
>    [13:51:13.810+0300] SYSERR  javax.xml.ws.WebServiceException:
>    java.lang.reflect.UndeclaredThrowableException
>    [13:51:13.811+0300] SYSERR      at
>    org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:375)
>    [13:51:13.811+0300] SYSERR      at
>    org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255)
>    [13:51:13.811+0300] SYSERR      at
>    org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpo
> int(ProviderImpl.java:136)
>    [13:51:13.811+0300] SYSERR      at
>    javax.xml.ws.Endpoint.publish(Endpoint.java:240)
>    [13:51:13.812+0300] SYSERR      at
>    com.foo.server.jetty.servlet.CxfWebServiceServlet.publishCX
> F(CxfWebServiceServlet.java:77)
>    ... REMOVED LINES GENERATING THE WEB SERVICE CODE AND COMPILE ETC ...
>    [13:51:13.813+0300] SYSERR      at
>    com.foo.server.jetty.JettyContextListener.contextInitialize
> d(JettyContextListener.java:89)
>    [13:51:13.814+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.ContextHandler.callContext
> Initialized(ContextHandler.java:800)
>    [13:51:13.814+0300] SYSERR      at
>    org.eclipse.jetty.servlet.ServletContextHandler.callContext
> Initialized(ServletContextHandler.java:444)
>    [13:51:13.814+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.ContextHandler.startContex
> t(ContextHandler.java:791)
>    [13:51:13.814+0300] SYSERR      at
>    org.eclipse.jetty.servlet.ServletContextHandler.startContex
> t(ServletContextHandler.java:294)
>    [13:51:13.815+0300] SYSERR      at
>    org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppCo
> ntext.java:1349)
>    [13:51:13.815+0300] SYSERR      at
>    org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppC
> ontext.java:1342)
>    [13:51:13.815+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.ContextHandler.doStart(
> ContextHandler.java:741)
>    [13:51:13.815+0300] SYSERR      at
>    org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
>    [13:51:13.815+0300] SYSERR      at
>    com.basis.server.jetty.BBjWebAppContext.doStart(BBjWebAppCo
> ntext.java:229)
>    [13:51:13.815+0300] SYSERR      at
>    org.eclipse.jetty.util.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:68)
>    [13:51:13.816+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.start(
> ContainerLifeCycle.java:132)
>    [13:51:13.816+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.doStart
> (ContainerLifeCycle.java:114)
>    [13:51:13.816+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.AbstractHandler.doStart(
> AbstractHandler.java:61)
>    [13:51:13.816+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.ContextHandlerCollection.d
> oStart(ContextHandlerCollection.java:163)
>    [13:51:13.816+0300] SYSERR      at
>    org.eclipse.jetty.util.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:68)
>    [13:51:13.817+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.start(
> ContainerLifeCycle.java:132)
>    [13:51:13.817+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.doStart
> (ContainerLifeCycle.java:114)
>    [13:51:13.817+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.AbstractHandler.doStart(
> AbstractHandler.java:61)
>    [13:51:13.817+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.ContextHandlerCollection.d
> oStart(ContextHandlerCollection.java:163)
>    [13:51:13.817+0300] SYSERR      at
>    org.eclipse.jetty.util.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:68)
>    [13:51:13.818+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.start(
> ContainerLifeCycle.java:132)
>    [13:51:13.818+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.doStart
> (ContainerLifeCycle.java:114)
>    [13:51:13.818+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.AbstractHandler.doStart(
> AbstractHandler.java:61)
>    [13:51:13.818+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.RequestLogHandler.doStart(
> RequestLogHandler.java:140)
>    [13:51:13.818+0300] SYSERR      at
>    org.eclipse.jetty.util.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:68)
>    [13:51:13.818+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.start(
> ContainerLifeCycle.java:132)
>    [13:51:13.819+0300] SYSERR      at
>    org.eclipse.jetty.server.Server.start(Server.java:387)
>    [13:51:13.819+0300] SYSERR      at
>    org.eclipse.jetty.util.component.ContainerLifeCycle.doStart
> (ContainerLifeCycle.java:114)
>    [13:51:13.819+0300] SYSERR      at
>    org.eclipse.jetty.server.handler.AbstractHandler.doStart(
> AbstractHandler.java:61)
>    [13:51:13.819+0300] SYSERR      at
>    org.eclipse.jetty.server.Server.doStart(Server.java:354)
>    [13:51:13.819+0300] SYSERR      at
>    org.eclipse.jetty.util.component.AbstractLifeCycle.start(
> AbstractLifeCycle.java:68)
>    ... REMOVED LINES - SYSTEM START ...
>    [13:51:13.821+0300] SYSERR  Caused by:
>    java.lang.reflect.UndeclaredThrowableException
>    [13:51:13.821+0300] SYSERR      at
>    com.sun.proxy.$Proxy25.visitLabel(Unknown Source)
>    [13:51:13.821+0300] SYSERR      at
>    org.apache.cxf.jaxws.WrapperClassGenerator.createWrapperCla
> ss(WrapperClassGenerator.java:213)
>    [13:51:13.821+0300] SYSERR      at
>    org.apache.cxf.jaxws.WrapperClassGenerator.generate(Wrapper
> ClassGenerator.java:122)
>    [13:51:13.821+0300] SYSERR      at
>    org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.genera
> tedWrapperBeanClass(JaxWsServiceFactoryBean.java:675)
>    [13:51:13.822+0300] SYSERR      at
>    org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.getExt
> raClass(JaxWsServiceFactoryBean.java:645)
>    [13:51:13.822+0300] SYSERR      at
>    org.apache.cxf.wsdl.service.factory.ReflectionServiceFactor
> yBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:461)
>    [13:51:13.822+0300] SYSERR      at
>    org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildS
> erviceFromClass(JaxWsServiceFactoryBean.java:696)
>    [13:51:13.822+0300] SYSERR      at
>    org.apache.cxf.wsdl.service.factory.ReflectionServiceFactor
> yBean.initializeServiceModel(ReflectionServiceFactoryBean.java:527)
>    [13:51:13.822+0300] SYSERR      at
>    org.apache.cxf.wsdl.service.factory.ReflectionServiceFactor
> yBean.create(ReflectionServiceFactoryBean.java:261)
>    [13:51:13.823+0300] SYSERR      at
>    org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create
> (JaxWsServiceFactoryBean.java:199)
>    [13:51:13.823+0300] SYSERR      at
>    org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.
> createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
>    [13:51:13.823+0300] SYSERR      at
>    org.apache.cxf.frontend.ServerFactoryBean.create(ServerFact
> oryBean.java:168)
>    [13:51:13.823+0300] SYSERR      at
>    org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsSer
> verFactoryBean.java:211)
>    [13:51:13.823+0300] SYSERR      at
>    org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460)
>    [13:51:13.823+0300] SYSERR      at
>    org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338)
>    [13:51:13.823+0300] SYSERR      ... 55 more
>    [13:51:13.824+0300] SYSERR  Caused by:
>    java.lang.NoSuchMethodException:
>    org.objectweb.asm.MethodWriter.visitLabel(org.objectweb.asm.Label)
>    [13:51:13.824+0300] SYSERR      at
>    java.lang.Class.getMethod(Class.java:1786)
>    [13:51:13.824+0300] SYSERR      at
>    org.apache.cxf.common.util.ReflectionInvokationHandler.invo
> ke(ReflectionInvokationHandler.java:85)
>    [13:51:13.824+0300] SYSERR      ... 70 more
>
> JettyContextListener initializes the CxfWebServiceServlet
>
>
> --
> Best regards,
>
> Richard Stollar
>
  • ClassLoader Richard Stollar
    • Re: ClassLoader Andy McCright

Reply via email to