Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-74464

Class loading problems at application server level when another web application with DOM4J dependencies is deployed



      Root cause of the issue

      -LPS-71278-, added in the default system.properties this property:

      # Configure a custom document factory in order to use a thread safe QName
      # cache.

      The problem is, that the referenced class DocumentFactory is part of portal-impl.jar and only visible to the Liferay classloader. Every other WAR which makes (implicit or explicit) use of DOM4J won't see that factory.


      • Liferay applications that are deployed inside Liferay OSGI environment are not affected because kernel classes are exposed using OSGI zero module.
      • If Liferay WAR is loaded after the other WAR application that uses Dom4j, the error is not reproduced, because new liferay dom4j factory is not applied. In order to reproduce the issue, always check Liferay was started successfully before deploying the problematic WAR application
      • Important: After solution of this LPS is commited, If this issue is not reproduced, check also that original LPS-71278 is not reproduced again


      In order to avoid the issue, revert the change added in LPS-71278

      Redefine org.dom4j.factory in system-ext.properties:


      Steps to reproduce (tomcat or any other app server)

      1. Install Liferay in any application server. For example, Tomcat
      2. Start application server and wait until Liferay is completely started
      3. Install any non-liferay WAR in application server. For example, install attached HibernateSampleWebApplication.war that I have downloaded from https://tunatore.wordpress.com/2011/06/14/how-to-create-a-hibernate-web-application-simple-example/from
      4. In Tomcat, simply copy the war file to tomcat-8.0.x/webapps directory
      5. Open http://localhost:8080/HibernateSampleWebApplication in order to execute hibernate logic
        • Expected result: The hibernate configuration from WAR file is loaded successfully
        • Wrong result: The hibernate configuration is not loaded, following error is written to log file
          25-Jan-2018 11:20:24.876 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive D:\Liferay\liferay-portal-master\tomcat-8.0.32\webapps\HibernateSampleWebApplication.war
          25-Jan-2018 11:20:26.899 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive D:\Liferay\liferay-portal-master\tomcat-8.0.32\webapps\HibernateSampleWebApplication.war has finished in 2,023 ms
          25-Jan-2018 11:21:17.663 INFO [http-nio-9080-exec-2] org.hibernate.cfg.annotations.Version.<clinit> Hibernate Annotations 3.3.1.GA
          25-Jan-2018 11:21:17.699 INFO [http-nio-9080-exec-2] org.hibernate.cfg.Environment.<clinit> Hibernate 3.2.5
          25-Jan-2018 11:21:17.708 INFO [http-nio-9080-exec-2] org.hibernate.cfg.Environment.<clinit> hibernate.properties not found
          25-Jan-2018 11:21:17.714 INFO [http-nio-9080-exec-2] org.hibernate.cfg.Environment.buildBytecodeProvider Bytecode provider name : cglib
          25-Jan-2018 11:21:17.732 INFO [http-nio-9080-exec-2] org.hibernate.cfg.Environment.<clinit> using JDK 1.4 java.sql.Timestamp handling
          25-Jan-2018 11:21:17.959 INFO [http-nio-9080-exec-2] org.hibernate.cfg.Configuration.configure configuring from resource: /hibernate.cfg.xml
          25-Jan-2018 11:21:17.959 INFO [http-nio-9080-exec-2] org.hibernate.cfg.Configuration.getConfigurationInputStream Configuration resource: /hibernate.cfg.xml
          SessionFactory initial creation error.org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
      1. Important: After solution of this LPS is commited, If this issue is not reproduced, check also that original LPS-71278 is not reproduced again

      Steps to reproduce (only wildfly)

      1. Install Liferay in a Wildfly application server
      2. Start Wildfly application server and wait until Liferay is completely started
      3. Add the attached jpa.war to the wildfly deployments directory (the WAR contains just a persistence.xml to trigger Hibernates XML parsing which uses DOM4J)
        • Expected¬†result: The WAR file is deployed without any problems
        • Wrong result: The WAR is not deployed due to a NullPointerException
          12:48:34,233 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 383) MSC000001: Failed to start service jboss.persistenceunit."jpa.war#database": org.jboss.msc.service.StartException in service jboss.persistenceunit."jpa.war#database": java.lang.NullPointerException
                  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
                  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
                  at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
                  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                  at java.lang.Thread.run(Thread.java:745)
                  at org.jboss.threads.JBossThread.run(JBossThread.java:320)
          Caused by: java.lang.NullPointerException
                  at org.hibernate.envers.configuration.internal.RevisionInfoConfiguration.generateDefaultRevisionInfoXmlMapping(RevisionInfoConfiguration.java:78)
                  at org.hibernate.envers.configuration.internal.RevisionInfoConfiguration.configure(RevisionInfoConfiguration.java:422)
                  at org.hibernate.envers.boot.internal.EnversServiceImpl.doInitialize(EnversServiceImpl.java:133)
                  at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:117)
                  at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:99)
                  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:288)
                  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
                  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
                  at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
                  at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154)
                  ... 7 more
          12:48:34,249 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "jpa.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"jpa.war#database\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"jpa.war#database\": java.lang.NullPointerException
              Caused by: java.lang.NullPointerException"}}
      1. Important: After solution of this LPS is commited, If this issue is not reproduced, check also that original LPS-71278 is not reproduced again

      Steps to reproduce (only in 6.2)

      1. Follow steps in previous sections
      2. Follow steps explained in LPS-73648 (that LPS is only reproduced in 6.2.x but root cause is the same of this one)


          Issue Links



              felix.zhang Felix Zhang
              starrunner Tobias Liefke
              Participants of an Issue:
              Recent user:
              Csaba Turcsan
              0 Vote for this issue
              4 Start watching this issue


                Days since last comment:
                2 years, 42 weeks, 2 days ago


                  Version Package
                  7.0.0 DXP FP39
                  7.0.0 DXP SP7
                  7.0.5 CE GA6
                  7.1.0 M1