Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7905

JAXBUtils fails to setEscapeHandler due to null escapeHandler

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.2.8, 3.3.0
    • Component/s: Core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      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:

       

      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 
      

      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.

      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); 
           } 
      }
      

       

      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:

      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)
      

       

      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.

       

       

        Attachments

          Activity

            People

            • Assignee:
              ffang Freeman Fang
              Reporter:
              thorsten.hersam Thorsten Hersam
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: