Wednesday, May 4, 2011

Portlet request dispatcher inclusion error MXParserFactory not found

I would like to share one more experience which I have had with Web services API used with portal environment (using portlets). In this, I prepared a Java Client (Stub) using Axis2 1.5 tool which contains Java classes and XML files. While compiling this code, I faced some issues. At first, I found an error which is,



4/21/11 20:08:58:000 IST] 00000052 PortletReques E com.ibm.ws.portletcontainer.
core.impl.PortletRequestDispatcherImpl internal include EJPPC0172E: Error occurred during portlet request dispatcher inclusion
                                 java.lang.NoClassDefFoundError: javax.xml.stream.XMLStreamException
    at java.lang.J9VMInternals.verifyImpl(Native Method)
    at java.lang.J9VMInternals.verify(J9VMInternals.java:68)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:129)
    at com.yash.ews.connection.EWSBaseConnector.(EWSBaseConnector.java:113)
The resolution of the error is to set JSR173_API.jar in lib directory of your application. Your compile time issues will get resolved. Once you run this application, you will get another error which is,
[4/21/11 20:12:58:232 IST] 00000055 PortletReques E com.ibm.ws.portletcontainer.
core.impl.PortletRequestDispatcherImpl internal include EJPPC0172E: Error occurred during portlet request dispatcher inclusion
                                 javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
    at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
    at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
    at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
    at org.apache.axiom.om.util.StAXUtils$7.run(StAXUtils.java:505)
    at java.security.AccessController.doPrivileged(AccessController.java:197)
    at org.apache.axiom.om.util.StAXUtils.newXMLInputFactory(StAXUtils.java:495)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory_perClassLoader(StAXUtils.java:566)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:172)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:137)
    at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:224)
    at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:218)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:596)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:581)

This error is related with XML parser. In java, we are aware of SAX parser however there is another parser StAX which is now used in latest programs and has the option of pausing and resuming the parsing process. Also works in similar streaming fashion. You can find this parser in sjsxp.jar which resolve this issue.
You can get more knowledge for the same in StAX.