mojohaus / exec-maven-plugin

Exec Maven Plugin
https://www.mojohaus.org/exec-maven-plugin/
Apache License 2.0
163 stars 96 forks source link

XML DocumentBuilderFactory error after upgrade from 3.0.0 to 3.1.0 #397

Open eballetbaz opened 7 months ago

eballetbaz commented 7 months ago

After upgrading from 3.0.0 to 3.1.0, I have a blocking error:

javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found

When running with -Djaxp.debug=true we can see the difference :

Version 3.1.0:

[INFO] --- exec:3.1.0:java (default-cli) @ pdp-database ---
JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
JAXP: loaded from fallback value: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

Version 3.0.0:

[INFO] --- exec:3.0.0:java (default-cli) @ pdp-database ---
JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
JAXP: loaded from fallback value: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl using ClassLoader: null

Full error stack with version 3.1.0

javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
    at javax.xml.parsers.DocumentBuilderFactory.newInstance (Unknown Source)
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder (XmlConfiguration.java:185)
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init> (XmlConfiguration.java:91)
    at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration (XmlConfigurationFactory.java:46)
    at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration (ConfigurationFactory.java:533)
    at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration (ConfigurationFactory.java:457)
    at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration (ConfigurationFactory.java:318)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure (LoggerContext.java:690)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure (LoggerContext.java:711)
    at org.apache.logging.log4j.core.LoggerContext.start (LoggerContext.java:253)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext (Log4jContextFactory.java:155)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext (Log4jContextFactory.java:47)
    at org.apache.logging.log4j.LogManager.getContext (LogManager.java:196)
    at org.apache.commons.logging.LogAdapter$Log4jLog.<clinit> (LogAdapter.java:155)
    at org.apache.commons.logging.LogAdapter$Log4jAdapter.createLog (LogAdapter.java:122)
    at org.apache.commons.logging.LogAdapter.createLog (LogAdapter.java:89)
    at org.apache.commons.logging.LogFactory.getLog (LogFactory.java:67)
    at org.apache.commons.logging.LogFactory.getLog (LogFactory.java:59)
    ...

Note: JDK is 1.8

slawekjaranowski commented 7 months ago

can you provide a simple project to reproduce your issue?

pedro-w commented 6 months ago

I have also seen this and I have made a small project here: https://github.com/pedro-w/foptest/tree/main

If I run mvn clean package exec:java I get

[WARNING]
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
    at javax.xml.parsers.DocumentBuilderFactory.newInstance (Unknown Source)
    at org.apache.fop.configuration.DefaultConfiguration.<clinit> (DefaultConfiguration.java:44)
    at org.apache.fop.configuration.DefaultConfigurationBuilder.build (DefaultConfigurationBuilder.java:41)
    at org.apache.fop.apps.FopConfParser.<init> (FopConfParser.java:154)
    at org.apache.fop.apps.FopConfParser.<init> (FopConfParser.java:93)
    at org.apache.fop.apps.FopConfParser.<init> (FopConfParser.java:146)
    at org.apache.fop.apps.FopConfParser.<init> (FopConfParser.java:119)
    at org.apache.fop.apps.FopFactory.newInstance (FopFactory.java:137)
    at com.nowhere.fop.App.main (App.java:39)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:283)
    at java.lang.Thread.run (Thread.java:840)

using exec:3.1.1:java but no error if I change the plugin in the POM to 3.0.0.

I'm using:

> mvn --version
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: C:\Program Files\NetBeans-20\netbeans\java\maven
Java version: 17.0.9, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.9.9-hotspot
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
ctabin commented 4 months ago

Hello,

We are seeing the same problem while using log4j, the system throws an exception on the line LogManager.getContext(false);:

java.lang.NoSuchMethodError: 'void javax.xml.parsers.DocumentBuilderFactory.setFeature(java.lang.String, boolean)'
        at org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:204)
        at org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:196)
        at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:185)
        at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:89)
        at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
        at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:506)
        at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:481)
        at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:402)
        at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:321)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:705)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:735)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:260)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:154)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:46)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:197)

Tested with apache maven 3.9.6 and exec-maven-plugin 3.1.0, 3.1.1 and 3.2.0 on JDK21. We used log4j 2.23.0 and slf4j 2.0.12.

pedro-w commented 4 months ago

@ctabin is that the same problem actually? (I genuinely don't know)

ctabin commented 4 months ago

@pedro-w It is also related to the DocumentBuilderFactory so it probably is related somehow, it might just be another consequence of the disease :face_with_spiral_eyes: