3 Replies Latest reply on Feb 17, 2014 5:55 AM by ctomc

    NPE on JAXBAttachmentMarshaller.addSwaRefAttachment

    fcorneli

      I've found a weird bug. I've got two EARs. One of which contains JAXB 2.2.1 under its lib directory.

      If I first use some functionality from the EAR with JAXB, and afterwards I use the other EAR's functionality, which involves sending over SOAP using Swa, I get the following lovely exception:

      Caused by: java.lang.NullPointerException
          at org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller.addSwaRefAttachment(JAXBAttachmentMarshaller.java:84)
          at com.sun.xml.bind.v2.runtime.SwaRefAdapter.marshal(SwaRefAdapter.java:84)
      
        • 1. Re: NPE on JAXBAttachmentMarshaller.addSwaRefAttachment
          ctomc

          Any special reason you bundle jaxb with your application?

          2.2.5 It is already part of app server, if you just remove your jaxb jar from ear, does it work?

          • 2. Re: NPE on JAXBAttachmentMarshaller.addSwaRefAttachment
            fcorneli

            I'm using some exotic feature of JAXB, hence it was included in the EAR/lib. As work-around I indeed removed JAXB from EAR/lib and this no longer results in (classloader) errors. Anyhow, this should not happen I guess.

            • 3. Re: NPE on JAXBAttachmentMarshaller.addSwaRefAttachment
              ctomc

              I would say it is other way around, it jaxb is really low level stuff, and should not be part of deployment.

              Given that it is provided by jdk and app server. When you use web services, WS will use app server provided jaxb which is correct way of doing it.

              But then some of your code uses different jar with same classes that causes your problems.

               

              There are no issues if you want to use some internal exotic jaxb features, just add dependency to jaxb module(com.sun.xml.bind) to your application and you will be able to use internal apis directly.