Page 1 of 1

ClassCastException in WebLogic 12c

PostPosted: Sat Sep 07, 2013 6:26 am
by lost
I am migrating an app to WebLogic 12c from Glassfish and ran into the below issue. Any help would be greatly appreciated.

Code: Select all
####<Sep 6, 2013 2:42:57 PM EDT> ... <<WLS Kernel>> xxxx.DocxManipulator getMainDocumentPart
SEVERE: null
org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
   at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:699)
   at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
   at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
   at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
   at xxxx.getMainDocumentPart(DocxManipulator.java:829)
Caused by: java.lang.ClassCastException: org.docx4j.openpackaging.contenttype.CTTypes cannot be cast to javax.xml.bind.JAXBElement
   at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:674)
   ... 11 more>


I did use Eclipse Link to 2.5 per http://www.docx4java.org/forums/weblogic-f25/how-to-update-to-eclipselink-2-5-in-web-t1574.html. I replaced racle_common\modules\oracle.toplink_12.1.2\eclipselink.jar because deploying it as a Shared Library kept giving me referenced library not found regardless of what I did (and my weblogic.xml and eclipselink ear manifest match)


**EDIT: WL 12c (12.1.2.0.0) actually came with a later Eclipse Link 4.2, which was released on July 4 2013, after 2.5 was released on May 28, 2013.

Re: ClassCastException in WebLogic 12c

PostPosted: Sat Sep 07, 2013 5:19 pm
by jason
Please try a nightly build eg http://www.docx4java.org/docx4j/docx4j- ... 130905.jar

Current sources contain a fix for this, not present in docx4j 2.8.1.

Re: ClassCastException in WebLogic 12c

PostPosted: Mon Sep 09, 2013 3:35 pm
by lost
Thanks Jason. Got past that error message, but now getting:

Code: Select all
<Sep 09, 2013 12:31:04 AM org.docx4j.utils.ResourceUtils getResource
INFO: Not using MOXy, since no resource: org/docx4j/wml/jaxb.properties>
<Sep 09, 2013 12:31:04 AM org.docx4j.jaxb.Context <clinit>
WARNING: null>
####<Sep 9, 2013 12:31:04 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701064492> <BEA-000000> <Sep 09, 2013 12:31:04 AM org.docx4j.utils.ResourceUtils getResource
INFO: Not using MOXy, since no resource: org/docx4j/wml/jaxb.properties>
####<Sep 9, 2013 12:31:04 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701064492> <BEA-000000> <Sep 09, 2013 12:31:04 AM org.docx4j.jaxb.Context <clinit>
WARNING: null>
####<Sep 9, 2013 12:31:04 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701064493> <BEA-000000> <Sep 09, 2013 12:31:04 AM org.docx4j.jaxb.Context <clinit>
INFO: Using Java 6/7 JAXB implementation>
####<Sep 9, 2013 12:31:04 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701064493> <BEA-000000> <Sep 09, 2013 12:31:04 AM org.docx4j.jaxb.Context <clinit>
INFO: loading Context jc>
####<Sep 9, 2013 12:31:13 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701073841> <BEA-000000> <Sep 09, 2013 12:31:13 AM org.docx4j.jaxb.Context <clinit>
INFO: MOXy JAXB implementation is in use!>
####<Sep 9, 2013 12:31:14 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701074238> <BEA-000000> <Sep 09, 2013 12:31:14 AM org.docx4j.jaxb.Context <clinit>
SEVERE: Cannot initialize context
javax.xml.bind.JAXBException: Provider org.eclipse.persistence.jaxb.JAXBContextFactory could not be instantiated: javax.xml.bind.JAXBException
- with linked exception:
[Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The context path org.plutext.jaxb.xmldsig contains no ObjectFactory or jaxb.index, no external metadata was found in properties Map, and sessions.xml was found or was invalid.
Internal Exception: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The sessions.xml resource [sessions.xml] was not found on the resource path.  Check that the resource name/path and classloader passed to the SessionManager.getSession are correct.  The sessions.xml should be included in the root of the applications deployed jar, if the sessions.xml is deployed in a sub-directory in the applications jar ensure that the correct resource path using "/" not "\" is used.]   
- with linked exception:
[javax.xml.bind.JAXBException
- with linked exception:
[Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The context path org.plutext.jaxb.xmldsig contains no ObjectFactory or jaxb.index, no external metadata was found in properties Map, and sessions.xml was found or was invalid.
Internal Exception: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The sessions.xml resource [sessions.xml] was not found on the resource path.  Check that the resource name/path and classloader passed to the SessionManager.getSession are correct.  The sessions.xml should be included in the root of the applications deployed jar, if the sessions.xml is deployed in a sub-directory in the applications jar ensure that the correct resource path using "/" not "\" is used.]]
   at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:161)
   at javax.xml.bind.ContextFinder.find(ContextFinder.java:349)
   at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)
   at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)
   at org.docx4j.jaxb.Context.<clinit>(Context.java:141)
   at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:671)
   at org.docx4j.openpackaging.io3.Load3.get(Load3.java:137)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:335)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:275)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:225)
   at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:208)
   at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:162)
   at *.DocxManipulator.getMainDocumentPart(DocxManipulator.java:829)
   at *.DocxManipulator.getDocument(DocxManipulator.java:180)
   at *.ThreadGetDocument.run(ThreadGetDocument.java:86)
   at java.lang.Thread.run(Thread.java:724)
Caused by: javax.xml.bind.JAXBException
- with linked exception:
[Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The context path org.plutext.jaxb.xmldsig contains no ObjectFactory or jaxb.index, no external metadata was found in properties Map, and sessions.xml was found or was invalid.
Internal Exception: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The sessions.xml resource [sessions.xml] was not found on the resource path.  Check that the resource name/path and classloader passed to the SessionManager.getSession are correct.  The sessions.xml should be included in the root of the applications deployed jar, if the sessions.xml is deployed in a sub-directory in the applications jar ensure that the correct resource path using "/" not "\" is used.]
   at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:826)
   at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:174)
   at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:129)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:187)
   at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:147)
   ... 15 more
Caused by: Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The context path org.plutext.jaxb.xmldsig contains no ObjectFactory or jaxb.index, no external metadata was found in properties Map, and sessions.xml was found or was invalid.
Internal Exception: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The sessions.xml resource [sessions.xml] was not found on the resource path.  Check that the resource name/path and classloader passed to the SessionManager.getSession are correct.  The sessions.xml should be included in the root of the applications deployed jar, if the sessions.xml is deployed in a sub-directory in the applications jar ensure that the correct resource path using "/" not "\" is used.
   at org.eclipse.persistence.exceptions.JAXBException.noObjectFactoryOrJaxbIndexInPath(JAXBException.java:137)
   at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:822)
   ... 23 more
Caused by: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The sessions.xml resource [sessions.xml] was not found on the resource path.  Check that the resource name/path and classloader passed to the SessionManager.getSession are correct.  The sessions.xml should be included in the root of the applications deployed jar, if the sessions.xml is deployed in a sub-directory in the applications jar ensure that the correct resource path using "/" not "\" is used.
   at org.eclipse.persistence.exceptions.ValidationException.noSessionsXMLFound(ValidationException.java:869)
   at org.eclipse.persistence.sessions.factories.XMLSessionConfigLoader.loadDocument(XMLSessionConfigLoader.java:341)
   at org.eclipse.persistence.sessions.factories.XMLSessionConfigLoader.loadDocument(XMLSessionConfigLoader.java:320)
   at org.eclipse.persistence.sessions.factories.XMLSessionConfigLoader.load(XMLSessionConfigLoader.java:234)
   at org.eclipse.persistence.sessions.factories.SessionManager.getSession(SessionManager.java:402)
   at org.eclipse.persistence.sessions.factories.SessionManager.getSession(SessionManager.java:337)
   at org.eclipse.persistence.oxm.XMLContext$XMLContextState.buildSession(XMLContext.java:745)
   at org.eclipse.persistence.oxm.XMLContext$XMLContextState.<init>(XMLContext.java:691)
   at org.eclipse.persistence.oxm.XMLContext$XMLContextState.<init>(XMLContext.java:676)
   at org.eclipse.persistence.oxm.XMLContext.<init>(XMLContext.java:144)
   at org.eclipse.persistence.oxm.XMLContext.<init>(XMLContext.java:113)
   at org.eclipse.persistence.jaxb.JAXBContext$ContextPathInput.createContextState(JAXBContext.java:817)
   ... 23 more>
####<Sep 9, 2013 12:31:14 AM EDT> <Notice> <StdErr> <system> <myserver> <Thread-13> <<WLS Kernel>> <> <> <1378701074281> <BEA-000000> <Sep 09, 2013 12:31:14 AM org.docx4j.XmlUtils <clinit>
INFO: Using com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl>


I'm not really sure how to proceed with creating sessions.xml to satisfy EclipseLink, even after reading this example http://wiki.eclipse.org/EclipseLink/Examples/MOXy/NativeOxmJaxbContext#Creating_the_Sessions_Configuration_file.

Re: ClassCastException in WebLogic 12c

PostPosted: Mon Sep 09, 2013 6:15 pm
by jason
Sorry, I was focused on your ClassCastException, and didn't twig that you need the MOXy dependent build.

Please try http://www.docx4java.org/docx4j/docx4j- ... 130909.jar

For Weblogic specific configuration, please see http://stackoverflow.com/questions/1742 ... server-12c

Re: ClassCastException in WebLogic 12c

PostPosted: Tue Sep 10, 2013 2:41 am
by lost
Thanks so much again.

I reverted to EclipseLink 2.4.2.v20130514-5956486 and was able to use docx4j 0905 jar. That was the EclipseLink that came with WL 12c (12.1.2.0.0).

I'll try EclipseLink 2.5 with the docx4j 0909 JAR file.

Re: ClassCastException in WebLogic 12c

PostPosted: Sat Nov 09, 2013 12:31 am
by julien
We had the same problem using docx4j with weblogic12. Building a docx4j-Jar using MOXy like described in http://www.docx4java.org/forums/docx-java-f6/moxy-t1242.html solved the ClassCastException Problem, but then other porblems/errors occured (i.e. NPE while processing a word document, although our code worked fine with docx4j-2.8.1 and weblogic 10.3).

However, we found another solution for making docx4j work with weblogic12, also described here: http://docs.oracle.com/middleware/1212/wls/WSGET/jax-ws-datatypes.htm#CIHBHDGI
To summarize: you can configure your application to use the Glassfish RI JAXB Implementation, which was used by weblogic versions prior to 12, by adding 2 configuration files and some lines to weblogic-applicatiion.xml of yout application EAR.

This way, our application works fine using docx4j-2.81.

Re: ClassCastException in WebLogic 12c

PostPosted: Tue Nov 12, 2013 9:41 am
by jason
Thank you Julien for an alternative I'm sure other WebLogic users will find valuable.

julien wrote:but then other porblems/errors occured (i.e. NPE while processing a word document,


Please report such problems (including stack trace) so we can fix them.

MOXy behaves a bit differently to the reference implementation; see for example http://stackoverflow.com/questions/1637 ... -behaviour

As a result, there will be places where docx4j has to take these differences into account