RE: RE: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found

Jamie Sammons, modified 3 Years ago. New Member Posts: 9 Join Date: 8/30/22 Recent Posts

Hi,

 

We are in the process of upgrading liferay from 6.2 to 7.4.3, After DB upgrade if we are trying to bring up the portlet we are encountering with following errors

1. Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found

2. 2022-08-18 16:16:51.896 ERROR [com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][WabBundleProcessor:244] Catastrophic initialization failure! Shutting down null WAB due to: null
java.lang.NullPointerException: null
    at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor._initContext(WabBundleProcessor.java:463) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:140) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:167) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:93) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:115) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:68) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:50) ~[?:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.BundleTracker.open(BundleTracker.java:159) ~[org.eclipse.osgi.jar:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.lambda$activate$0(WabFactory.java:146) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_332]
    at java.lang.Thread.run(Thread.java:750) [?:1.8.0_332]
2022-08-18 16:16:51.915 ERROR [Framework Event Dispatcher: Equinox Container: 5bf816c5-a6eb-4534-8012-6f6195e50386][Framework:56] FrameworkEvent ERROR
org.osgi.framework.ServiceException: Exception in com.liferay.portal.osgi.web.servlet.context.helper.internal.ServletContextHelperRegistrationServiceFactory.getService()
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:222) ~[org.eclipse.osgi.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) ~[org.eclipse.osgi.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) ~[org.eclipse.osgi.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:524) ~[org.eclipse.osgi.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:464) ~[org.eclipse.osgi.jar:?]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:624) ~[org.eclipse.osgi.jar:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor._initContext(WabBundleProcessor.java:459) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:140) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:167) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:93) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:115) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:68) ~[?:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:50) ~[?:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) ~[org.eclipse.osgi.jar:?]
    at org.osgi.util.tracker.BundleTracker.open(BundleTracker.java:159) ~[org.eclipse.osgi.jar:?]
    at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.lambda$activate$0(WabFactory.java:146) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_332]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_332]
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source) ~[?:1.8.0_332]
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:854) ~[log4j-1.2-api.jar:2.17.1]
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778) ~[log4j-1.2-api.jar:2.17.1]
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526) ~[log4j-1.2-api.jar:2.17.1]
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127) ~[log4j-1.2-api.jar:2.17.1]
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:66) ~[?:?]
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270) ~[slf4j-api.jar:1.7.26]
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156) ~[jcl-over-slf4j.jar:1.2]
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:671) ~[commons-logging.jar:1.2]
    at org.springframework.web.servlet.DispatcherServlet.<clinit>(DispatcherServlet.java:246) ~[?:?]
    at org.springframework.web.servlet.ViewRendererServlet.<clinit>(ViewRendererServlet.java:54) ~[?:?]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_332]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_332]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_332]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_332]
    at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_332]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.definition.WebXMLDefinitionLoader._getServletInstance(WebXMLDefinitionLoader.java:1094) ~[?:?]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.definition.WebXMLDefinitionLoader._setServlet(WebXMLDefinitionLoader.java:1132) ~[?:?]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.definition.WebXMLDefinitionLoader.endElement(WebXMLDefinitionLoader.java:352) ~[?:?]
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1781) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2966) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:601) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) ~[?:1.8.0_332]
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:642) ~[?:1.8.0_332]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.definition.WebXMLDefinitionLoader.loadWebXMLDefinition(WebXMLDefinitionLoader.java:511) ~[?:?]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.definition.WebXMLDefinitionLoader.loadWebXML(WebXMLDefinitionLoader.java:456) ~[?:?]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.ServletContextHelperRegistrationImpl.<init>(ServletContextHelperRegistrationImpl.java:111) ~[?:?]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.ServletContextHelperRegistrationServiceFactory.getService(ServletContextHelperRegistrationServiceFactory.java:50) ~[?:?]
    at com.liferay.portal.osgi.web.servlet.context.helper.internal.ServletContextHelperRegistrationServiceFactory.getService(ServletContextHelperRegistrationServiceFactory.java:32) ~[?:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) ~[org.eclipse.osgi.jar:?]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_332]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) ~[org.eclipse.osgi.jar:?]
    ... 20 more
2022-08-18 16:16:52.940 INFO  [com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][PortletHotDeployListener:305] 2 portlets for liferay-framework-portlets are available for use

Did anyone face this issue, or please let me know if I am going wrong anywhere.

 

 

thumbnail
Alberto Chaparro, modified 3 Years ago. Liferay Master Posts: 560 Join Date: 4/25/11 Recent Posts

Hi Harish,

The portal is trying to deploy and old extension (it is still war not an OSGi module) so, can you check the custom developments you are deploying?

Thank you

Jamie Sammons, modified 3 Years ago. New Member Posts: 9 Join Date: 8/30/22 Recent Posts

Thank you for response. Yes these are custom portlets upgraded using liferay developer studio. As per documentation we can deploy war file also, if that is not true can you please share any documentation upgrading to OSGi module. Is it a recent change that modules needed to be OSGi not any more old format? When I was trying with 7.4.3.23 (May build) I didn't encounter this issue.

thumbnail
Alberto Chaparro, modified 3 Years ago. Liferay Master Posts: 560 Join Date: 4/25/11 Recent Posts

Hi Harish,

There is no requirement but it is haighly recommended, the WAR format, is not how we are developing in microservices using OSGi, and we keep since 7.0 to keep backward compatibiity so it will be more difficult to diagnose any issue you may have. There is plenty of documentation about how to upgrade your modules to OSGi.

If you still want to keep WARs, the issue is happening here:

https://github.com/liferay/liferay-portal/blob/master/modules/apps/static/portal-osgi-web/portal-osgi-web-wab-extender/src/main/java/com/liferay/portal/osgi/web/wab/extender/internal/WabBundleProcessor.java#L463

Seems servletContextHelperRegistration is null

That means that probably the upgrade did not complete properly, be sure all services are available in osgi, you can execute system:check for that

Jamie Sammons, modified 3 Years ago. New Member Posts: 9 Join Date: 8/30/22 Recent Posts

How big is the change to convert to OSGi modules. Also I have followed all the steps using liferay upgrade tool but I couldn't understand where I am missing. Any pointers or suggestions where to start from.

Jamie Sammons, modified 3 Years ago. New Member Posts: 9 Join Date: 8/30/22 Recent Posts

Does system:check works for war file also? I tried here is the information

Output

Available checkers: [Declarative Service Soft Circular Dependency Checker, Declarative Service Unsatisfied Component Checker, Spring Extender Unavailable Component Checker]
Running "Declarative Service Soft Circular Dependency Checker". You can run this by itself with command "ds:softCircularDependency" in gogo shell.
Declarative Service Soft Circular Dependency Checker check result: No issues were found.
Running "Declarative Service Unsatisfied Component Checker". You can run this by itself with command "ds:unsatisfied" in gogo shell.
Declarative Service Unsatisfied Component Checker check result: No issues were found.
Running "Spring Extender Unavailable Component Checker". You can run this by itself with command "dm na" in gogo shell.
Spring Extender Unavailable Component Checker check result: No issues were found.

Also can you please provide any documentation converting from old format to OSGi module. I tried on liferay documentation but not able to pinpoint. 

Can you also provide any pointers like what is missing in my old format, as I redid the entire upgrade process and I am still getting the same error. I used the upgrade tool to convert the code base.

Basically I am stuck here, my approach was to make the upgrade from 6.2 to 7.4.3 and then once we are at a place that things are working then I can work on converting to OSGi.  Please provide me information why servletContextHelperRegistration is null, is there any problem with web.xml or any dependency is missing or some thing else. Please any pointers over here will really help us overcome the problem.

 

Jamie Sammons, modified 3 Years ago. New Member Posts: 9 Join Date: 8/30/22 Recent Posts

Does liferay 7.4.3 works with openjdk 8?

Jamie Sammons, modified 3 Years ago. New Member Posts: 9 Join Date: 8/30/22 Recent Posts

Here is my dependency list from pom.xml. please let me know if I am missing something?

<dependencies>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>release.portal.api</artifactId>
            <version>7.4.3.23-ga23</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.liferay.portal/com.liferay.portal.kernel -->
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.portal.kernel</artifactId>
            <version>58.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.util.bridges</artifactId>
            <version>9.0.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.util.taglib</artifactId>
            <version>9.2.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.util.java</artifactId>
            <version>17.1.2</version>
            <scope>provided</scope>
        </dependency>
    
        <dependency>
            <groupId>com.liferay.faces.archetype</groupId>
            <artifactId>com.liferay.faces.archetype.primefaces.portlet</artifactId>
            <version>8.0.0</version>
        </dependency>

        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>