We've been employing the use of docx4j (2.8.0) in our project for quite some time (fantastic tool by the way). Up until now, we've been deploying our application on a Tomcat7 server running OpenJDK 1.6. Everything has worked perfectly.
Recently, we've been trying to move our application to a Weblogic 10.3.6 server running Oracle JDK 1.6. The rest of the application deploys and runs fine, until we try to use some of our routines that invoke docx4j classes. The application invokes docx4j and it runs fine, giving us an appropriate document. However, after that point, if we try to navigate to a page within the site that hasn't been compiled yet, we receive this error:
- Code: Select all
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:129)
at weblogic.jsp.internal.jsp.JspTagLibraryFeature.parseTldFromWebXML(JspTagLibraryFeature.java:892)
at weblogic.jsp.internal.jsp.JspTagLibraryFeature.initFromWebXML(JspTagLibraryFeature.java:866)
at weblogic.jsp.internal.jsp.JspTagLibraryFeature.init(JspTagLibraryFeature.java:454)
at weblogic.jsp.internal.jsp.JspTagLibraryFeature.init(JspTagLibraryFeature.java:253)
at weblogic.jsp.internal.jsp.JspTagLibraryFeature.setCPL(JspTagLibraryFeature.java:44)
at weblogic.jsp.internal.CPL.getFeature(CPL.java:712)
at weblogic.jsp.internal.jsp.JspParser.getTagLibraryFeature(JspParser.java:4549)
at weblogic.jsp.internal.jsp.JspParser.getTagLibInfo(JspParser.java:2955)
at weblogic.jsp.internal.jsp.JspParser.jspParse(JspParser.java:624)
at weblogic.jsp.internal.jsp.JspParser._parse(JspParser.java:535)
at weblogic.jsp.internal.jsp.JspParser.parse(JspParser.java:528)
at weblogic.jsp.internal.jsp.JspAnalyzer.parseFile(JspAnalyzer.java:104)
at weblogic.jsp.internal.jsp.JspAnalyzer.parse(JspAnalyzer.java:92)
at weblogic.jsp.internal.ProxySourceFile.parse(ProxySourceFile.java:106)
at weblogic.jsp.internal.SourceFile.getAst(SourceFile.java:559)
at weblogic.jsp.internal.SourceFile.getAst(SourceFile.java:533)
at weblogic.jsp.internal.SourceFile.check(SourceFile.java:335)
at weblogic.jsp.internal.ProxySourceFile.codeGen(ProxySourceFile.java:224)
at weblogic.jsp.internal.SourceFile.codeGen(SourceFile.java:327)
at weblogic.jsp.internal.client.ClientUtilsImpl$CodeGenJob.run(ClientUtilsImpl.java:599)
at weblogic.jsp.internal.client.Job.performJob(Job.java:83)
at weblogic.jsp.internal.client.ThreadPool$WorkerThread.run(ThreadPool.java:217)
We've tried many different things including:
- Setting prefer-application-packages in weblogic-application.xml as follows:
- Code: Select all
<prefer-application-packages>
<package-name>org.apache.log4j.*</package-name>
<package-name>javax.xml.parsers.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.xalan.*</package-name>
<package-name>com.sun.org.apache.xerces.internal.jaxp.*</package-name>
</prefer-application-packages>
- Setting saxparser-factory, document-builder-factory, and transformer-factory in weblogic-application.xml as follows:
- Code: Select all
<xml>
<parser-factory>
<saxparser-factory>org.apache.xerces.jaxp.SAXParserFactoryImpl</saxparser-factory>
<document-builder-factory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</document-builder-factory>
<transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory>
</parser-factory>
</xml>
- Setting the factory implementations in docx4j.properties as follows:
- Code: Select all
javax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
javax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
javax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
I have a suspicion that the docx4j classes we are using might be setting a system property that causes issues with the rest of the application. For now, we have implemented a "band-aid" solution which was to tell weblogic to precompile all the jsp pages. That seems to work but it's not solving the root of the problem and I have a feeling this will rear it's head again.
Another point of note that may or may not be releated is that we employ the use of xercesImpl.jar. We are using this because it's a hard dependency for AntiSamy.
I've scoured the docx4j forums, these two related topics are probably the best I've found and helped us find the cause of the problem:
- http://www.docx4java.org/forums/docx-java-f6/weblogic-javax-xml-transform-transformerfactory-issue-t1119.html
- http://www.docx4java.org/forums/docx-java-f6/problems-with-wordprocessingmlpackage-t1085.html
We also experience the same deploy/undeploy problems described in the first post above. We have to restart our severs each time. (This is still occurring with the precompile jsp hack in place).