Page 1 of 1

NPE in CustomXMLBinding with old JAXB

PostPosted: Fri Aug 03, 2012 6:31 pm
by anil_ah
Hi Jason,
I am also facing the same issue,is it possible to skip the class loader for the JAXB in context.java
Code: Select all
try {
          Class.forName("com.sun.xml.bind.marshaller.MinimumEscapeHandler");
          log.info("JAXB: Using RI");

       } catch (ClassNotFoundException cnfe) {
          // JAXB Reference Implementation not present
         log.info("JAXB: RI not present.  Trying Java 6 implementation.");
and try the Java 6 implementation,as our deployment environment is on java6 .

if its possible could you give me the new build of doc4j with this change

Re: NPE in CustomXMLBinding with old JAXB 2.1.2

PostPosted: Sat Aug 04, 2012 9:20 pm
by jason
Hi Anil

More info please:

- What is your stack trace, exactly?
- Which Java 6 are you using, exactly?
- Which version of docx4j?

cheers .. Jason

Re: NPE in CustomXMLBinding with old JAXB 2.1.2

PostPosted: Tue Aug 07, 2012 3:25 pm
by anil_ah
java version is 1.6.0.
scriopt output shared by infra team is
[wasadmin@hlixgr275 bin]$ /opt/IBM/WebSphere/70/java/bin/java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460sr8fp1ifix-20110208_01(SR8 FP1++IZ81201+IZ80998+IZ83034+IZ83273+IZ94423))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr8ifx-20100923_65174 (JIT enabled, AOT enabled)
J9VM - 20100923_065174
JIT - r9_20100401_15339ifx6
GC - 20100308_AA)
JCL - 20110208_01


Code: Select all
[2012-08-07 09:55:28,499][org.docx4j.jaxb.Context][INFO][WebContainer : 5] [JAXB: Using RI]
[2012-08-07 09:55:28,499][org.docx4j.jaxb.Context][INFO][WebContainer : 5] [loading Context jc]
[2012-08-07 09:55:31,539][org.docx4j.jaxb.Context][INFO][WebContainer : 5] [loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl .. loading others ..]
[2012-08-07 09:55:31,665][org.docx4j.jaxb.Context][INFO][WebContainer : 5] [.. others loaded ..] [/quote]

Code: Select all
[8/7/12 11:11:01:546 SGT] 00000069 SystemErr     R java.lang.NullPointerException
[8/7/12 11:11:01:546 SGT] 00000069 SystemErr     R    at org.docx4j.wml.Id.hashCode(Id.java:129)
[8/7/12 11:11:01:546 SGT] 00000069 SystemErr     R    at java.util.HashMap.putImpl(HashMap.java:620)
[8/7/12 11:11:01:546 SGT] 00000069 SystemErr     R    at java.util.HashMap.put(HashMap.java:605)
[8/7/12 11:11:01:546 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.AssociationMap.addInner(AssociationMap.java:78)
[8/7/12 11:11:01:546 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.recordInnerPeer(UnmarshallingContext.java:988)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.startElement(StructureLoader.java:147)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:369)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:347)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:35)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:101)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:224)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:261)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:230)
[8/7/12 11:11:01:547 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:107)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:90)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:83)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:140)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com.sun.xml.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:111)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.unmarshal(MainDocumentPart.java:291)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.unmarshal(MainDocumentPart.java:87)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.io.LoadFromZipNG.getRawPart(LoadFromZipNG.java:551)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.io.LoadFromZipNG.getPart(LoadFromZipNG.java:427)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.io.LoadFromZipNG.addPartsFromRelationships(LoadFromZipNG.java:350)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:243)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:225)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:210)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:184)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com.soareport.ljo.SoaReportProcessor.getwordMLPackage(SoaReportProcessor.java:22)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com..soareport.ljo.SoaReportPreProcessor.createReport(SoaReportPreProcessor.java:57)
[8/7/12 11:11:01:548 SGT] 00000069 SystemErr     R    at com.soareport.ljo.SoaLJO.generateReport(SoaLJO.java:81)


doc4jx version we are using is 2.7.1

also find the attached log file for detail logs

Re: NPE in CustomXMLBinding with old JAXB 2.1.2

PostPosted: Wed Aug 08, 2012 8:24 pm
by anil_ah
Hi jason,
Please help on this issue,waiting for your reply

Re: NPE in CustomXMLBinding with old JAXB

PostPosted: Fri Aug 10, 2012 1:07 pm
by jason
I think/hope/expect your problem is just a matter of configuring JAXB correctly in websphere on IBM J9 VM.

For hints on this, please see docx-java-f6/domino-configuration-t1114.html

There is also docx-java-f6/trouble-with-lotus-domino-xpages-t1100.html

Please let us know what works for you.

Re: NPE in CustomXMLBinding with old JAXB

PostPosted: Fri Aug 10, 2012 3:01 pm
by anil_ah
Hi jason,
My Application is part of portal Application.changing any thing on server level is not feasible in our enviroment,it would be very cumborsome and coordination of many team and lot of approvals.

is it possible to skip following code in context.java
Code: Select all
doc4jx try {
       Class.forName("com.sun.xml.bind.marshaller.MinimumEscapeHandler");
          log.info("JAXB: Using RI");
       }
     catch (ClassNotFoundException cnfe) {

and context.java always look for Using Java 6 implementation

Re: NPE in CustomXMLBinding with old JAXB

PostPosted: Fri Aug 10, 2012 4:53 pm
by jason
docx4j uses whatever JAXB is available on the class loader given by getClass().getClassLoader().

The only thing it sets specifically is the namespace prefix mapper.

In your case, the JAXB on that class loader is old/broken (given the error you noted was the same as in data-binding-java-f16/npe-in-customxmlbinding-with-old-jaxb-2-1-2-t459.html )

So:
(1) which class loader in your environment would load a sufficiently modern JAXB
(2) how do we tell docx4j to use that class loader
(2a) would calling JAXBContext.newInstance without specifying a class loader, default to that class loader?

If you can get that far, then the namespace prefix mapper needs to be set to match the JAXB implementation.

Re: NPE in CustomXMLBinding with old JAXB

PostPosted: Sat Aug 11, 2012 1:57 pm
by anil_ah
Hi Jason,
In my development environment,
i am using java 1.6.0.21
Server Tomcat5
No jaxb jar file
so my code works fine here in dev environment as following code from context.java does not execute
Code: Select all
try {
       Class.forName("com.sun.xml.bind.marshaller.MinimumEscapeHandler");
       log.info("JAXB: Using RI");

       }



but when code promoted to SIT
there server is IBM WAS 6.0 , WAS have JAXB Jar so above code able to load MinimumEscapeHandler from JAXB jar of WAS Server

so i was thinking if we can comment this code in context.java it will load the MinimumEscapeHandler from following code
Code: Select all
   try {
            Class.forName("com.sun.xml.internal.bind.marshaller.MinimumEscapeHandler");
        log.info("JAXB: Using Java 6 implementation.");
          } catch (ClassNotFoundException e) {
            log.info("JAXB: neither Reference Implementation nor Java 6 implementation present?");
          }


in this Scenario MinimumEscapeHandler is part of rt.jar in jre6, so i hope problem will get solved.

so i am expecting if you can comment the code in conext.java and share me doc4j2.7.1 jar ,that will fix the problem
i am not able to compile the source code on my machine.

if you can help me commenting the code and share me docx4j2.7.1 that will be a great help to me.

regards
Anil

Re: NPE in CustomXMLBinding with old JAXB

PostPosted: Sat Aug 11, 2012 2:35 pm
by jason
Why would commenting out that code make any difference at all? All it does is display diagnostic info about version of JAXB being used.

As I've tried to explain, what matters is what follows:

1. the JAXBContext.newInstance statements, which use whatever JAXB happens to be on the relevant classloader

2. that the namespace prefix mapper is set appropriately for that JAXB implementation

So you have 3 possible approaches:
1. best: fix your websphere configuration
2. speculative: try to access a classloader which has the correct JAXB
3. workaround the NPE in org.docx4j.wml.Id (and what else)?

I'd encourage you to get docx4j building on your machine. Feel free to start a new topic if you need help with this.