Legacy Knowledge Base
Published Sep. 10, 2025

java.lang.Error: factory already defined when starting up 2024.Q2 with JDK 17

Written By

Daniel Couso

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • Start up an environment with Liferay DXP 2024.Q2 and JDK 17.
  • The following error message appears:

ERROR [io.undertow.servlet.request] (ServerService Thread Pool -- 78) UT015005: Error invoking method contextDestroyed on listener class jdk.proxy10.$Proxy40: java.lang.reflect.UndeclaredThrowableException

        at jdk.proxy10/jdk.proxy10.$Proxy40.contextDestroyed(Unknown Source)

…

Caused by: java.lang.reflect.InvocationTargetException

        ... 22 more

Caused by: java.lang.NullPointerException: Cannot invoke "com.liferay.portal.kernel.dao.db.DB.getDBType()" because "this._db" is null

        ... 28 more

 

2024-06-19 12:27:40,383 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 78) MSC000001: Failed to start service jboss.deployment.unit."ROOT.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."ROOT.war".undertow-deployment: java.lang.RuntimeException: java.lang.reflect.UndeclaredThrowableException

        at org.wildfly.extension.undertow..

Caused by: java.lang.RuntimeException: java.lang.reflect.UndeclaredThrowableException

        ... 8 more

Caused by: java.lang.reflect.UndeclaredThrowableException

        at jdk.proxy10/jdk.proxy10.$Proxy40.contextInitialized(Unknown Source)

        ... 10 more

Caused by: java.lang.reflect.InvocationTargetException

        ... 21 more

Caused by: java.lang.RuntimeException: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.internal.framework.SystemBundleActivator.start() of bundle org.eclipse.osgi.

        at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:210)

        ... 27 more

Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.osgi.internal.framework.SystemBundleActivator.start() of bundle org.eclipse.osgi.

        at …

        ... 27 more

Caused by: java.lang.Error: factory already defined

        at …

        ... 38 more

Environment

  • Quarterly Release: 2024.Q2

Resolution

  • Add the following JVM parameter to your application server:
    --add-opens=java.base/java.net=ALL-UNNAMED
  • This parameter was optional for JDK 8 and JDK 11, but it is mandatory for JDK 17 and higher.

 

 

Did this article resolve your issue ?

Legacy Knowledge Base