[ https://issues.apache.org/jira/browse/CXF-7905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16699885#comment-16699885 ]
Freeman Fang commented on CXF-7905: ----------------------------------- I ran into similar issue like {code} java.lang.IllegalArgumentException: interface com.sun.xml.bind.marshaller.CharacterEscapeHandler is not visible from class loader at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:581) at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557) at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230) at java.lang.reflect.WeakCache.get(WeakCache.java:127) at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419) at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719) at org.apache.cxf.common.util.ProxyHelper.getProxyInternal(ProxyHelper.java:49) at org.apache.cxf.common.util.ProxyHelper.getProxy(ProxyHelper.java:126) at org.apache.cxf.common.jaxb.JAXBUtils.createEscapeHandler(JAXBUtils.java:1597) at org.apache.cxf.common.jaxb.JAXBUtils.createMininumEscapeHandler(JAXBUtils.java:1575) at org.apache.cxf.jaxb.JAXBDataBinding.setContext(JAXBDataBinding.java:257) at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:361) at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:470) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:695) at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:530) at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:543) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:331) at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:838) at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:591) at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:703) at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360) at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:190) at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:716) at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:413) at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:278) at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:299) at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:268) at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:264) at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:254) at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500) at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433) at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725) at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463) at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422) at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1179) at org.apache.felix.framework.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:730) at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:485) at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4579) at org.apache.felix.framework.Felix.startBundle(Felix.java:2174) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) at org.apache.karaf.bundle.command.Restart.doExecute(Restart.java:51) at org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:56) at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84) at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68) at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86) at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497) at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) {code} When having multiple jaxb-impl bundle versions inside Karaf container. I think the problem you saw in JBoss EAP is similar, somehow you have multiple modules/jars both contains interface org.apache.cxf.endpoint.Client , however they are loaded by different clasloaders. You should resolve it in your container. Anyway, add a NPE guard in CXF is what we can do best inside CXF. > JAXBUtils fails to setEscapeHandler due to null escapeHandler > ------------------------------------------------------------- > > Key: CXF-7905 > URL: https://issues.apache.org/jira/browse/CXF-7905 > Project: CXF > Issue Type: Bug > Components: Core > Affects Versions: 3.2 > Reporter: Thorsten Hersam > Assignee: Freeman Fang > Priority: Major > Fix For: 3.3.0, 3.2.8 > > > I am having the following issue with a SOAP request of my software deployed > in Wildfly 13.0.0.Final. Wildfly makes use of CXF core in version > 3.2.4-jbossorg-1. Of this version I was unable to find sources but my issue > persists with any or the 3.2 versions of CXF. > The same software was previously deployed without any issues on Wildfly > 10.0.1.Final which uses CXF 3.1.6. > Upon authentification at a SOAP web service I now receive the following > exception: > > {code:java} > 12:26:29,314 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default > task-1) Interceptor for > {http://endpoint.soap.webservice.logicaldoc.com/}SoapAuthServiceService#{http://ws.logicaldoc.com}login > has thrown exception, unwinding now: java.lang.NullPointerException > at > com.sun.xml.bind.v2.runtime.MarshallerImpl.setProperty(MarshallerImpl.java:518) > at > org.apache.cxf.common.jaxb.JAXBUtils.setEscapeHandler(JAXBUtils.java:1567) > at > org.apache.cxf.jaxb.io.DataWriterImpl.lambda$createMarshaller$0(DataWriterImpl.java:138) > at > org.apache.cxf.jaxb.JAXBDataBinding.applyEscapeHandler(JAXBDataBinding.java:271) > at > org.apache.cxf.jaxb.io.DataWriterImpl.createMarshaller(DataWriterImpl.java:138) > at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:239) > at > {code} > jaxb MarschallerImpl fails when org.apache.cxf.common.jaxb.JAXBUtils tries to > set an EscapeHandler of null. > > +Possible Solution+ > Adding a null check at org.apache.cxf.common.jaxb.JAXBUtils.setEscapeHandler > as indicated below, solves the issue. > {code:java} > public static void setEscapeHandler(Marshaller marshaller, Object > escapeHandler) { > try { > String postFix = getPostfix(marshaller.getClass()); > if (postFix != null && escapeHandler != null) { > marshaller.setProperty("com.sun.xml" + postFix + > ".bind.characterEscapeHandler", escapeHandler); > } > } catch (PropertyException e) { > LOG.log(Level.INFO, "Failed to set MinumEscapeHandler to jaxb > marshaller", e); > } > } > {code} > > While a PropertyException seems to be okay for CXF a null escapeHandler > Object leads to escapeHandler.getClass().getName() called by jaxb > MarshallerImpl just as it was trying to throw a PropertyException. > > +Why is the EscapeHandler null+ > A null EscapeHandler can occur when > org.apache.cxf.common.jaxb.createEscapeHandler()'s actual return delegate > ProxyHelper.getProxy() throws an Exception. > In my case a the following Exception is thrown: > {code:java} > Caused by: java.lang.IllegalArgumentException: interface > org.apache.cxf.endpoint.Client is not visible from class loader at > java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:581) at > java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557) at > java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230) at > java.lang.reflect.WeakCache.get(WeakCache.java:127) at > java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419) at > java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719) at > org.apache.cxf.common.util.ProxyHelper.getProxyInternal(ProxyHelper.java:49) > at org.apache.cxf.common.util.ProxyHelper.getProxy(ProxyHelper.java:126) at > org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:176) > at > org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) > at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:493) at > org.jboss.wsf.stack.cxf.client.ProviderImpl$JBossWSServiceImpl.createPort(ProviderImpl.java:580) > at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:359) at > org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:350) at > javax.xml.ws.Service.getPort(Service.java:99) at > com.logicaldoc.webservice.soap.endpoint.SoapAuthServiceService.getSoapAuthServicePort(SoapAuthServiceService.java:68) > {code} > > org.apache.cxf.endpoint.Client does not seem to be visible of the combined > classloader constructed in ProxyHelper.getProxyInternal(). > I am not utterly familiar with ClassLoaders but I find it strange that > org.apache.cxf classes - which are calling a ProxyHelper which constructs a > ClassLoader for "com.sun.xml.bind.marshaller.CharacterEscapeHandler" - fail > because another org.apache.cxf interface is not visible. > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)