exec-maven-plugin: Exception since release 3.1.0: `Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found`

Works with: org.codehaus.mojo:exec-maven-plugin:3.0.0:java Does not Work with: org.codehaus.mojo:exec-maven-plugin:3.1.0:java

No code change on our side.

Thanks a lot, Christophe

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:java (default-cli) on project azure-insights-probes: An exception occurred while executing the Java class. Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:java (default-cli) on project azure-insights-probes: An exception occurred while executing the Java class. Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occurred while executing the Java class. Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
    at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:349)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
    at javax.xml.parsers.SAXParserFactory.newInstance (Unknown Source)
    at ch.qos.logback.core.joran.event.SaxEventRecorder.buildSaxParser (SaxEventRecorder.java:79)
    at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents (SaxEventRecorder.java:57)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure (GenericConfigurator.java:151)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure (GenericConfigurator.java:110)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure (GenericConfigurator.java:53)
    at ch.qos.logback.classic.util.ContextInitializer.configureByResource (ContextInitializer.java:64)
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig (ContextInitializer.java:134)
    at org.slf4j.impl.StaticLoggerBinder.init (StaticLoggerBinder.java:84)
    at org.slf4j.impl.StaticLoggerBinder.<clinit> (StaticLoggerBinder.java:55)
    at org.slf4j.LoggerFactory.bind (LoggerFactory.java:150)
    at org.slf4j.LoggerFactory.performInitialization (LoggerFactory.java:124)
    at org.slf4j.LoggerFactory.getILoggerFactory (LoggerFactory.java:417)
    at org.slf4j.LoggerFactory.getLogger (LoggerFactory.java:362)
    at org.slf4j.LoggerFactory.getLogger (LoggerFactory.java:388)
    at fr.tf1.data.monitoring.probes.FiveMinutesProbesApp.<clinit> (FiveMinutesProbesApp.java:9)
    at sun.misc.Unsafe.ensureClassInitialized (Native Method)
    at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue (DirectMethodHandle.java:330)
    at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue (DirectMethodHandle.java:327)
    at java.lang.ClassValue.getFromHashMap (ClassValue.java:227)
    at java.lang.ClassValue.getFromBackup (ClassValue.java:209)
    at java.lang.ClassValue.get (ClassValue.java:115)
    at java.lang.invoke.DirectMethodHandle.checkInitialized (DirectMethodHandle.java:351)
    at java.lang.invoke.DirectMethodHandle.ensureInitialized (DirectMethodHandle.java:341)
    at java.lang.invoke.DirectMethodHandle.internalMemberNameEnsureInit (DirectMethodHandle.java:291)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:279)
    at java.lang.Thread.run (Thread.java:748)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 21 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@rmannibucau thanks. Confirmed that #337 fixes my issue.

Proposing https://github.com/mojohaus/exec-maven-plugin/pull/337, do you want to give a try with this patch?

I’m having a very similar problem. Same thing happened, worked on 3.0.0 and stopped working on 3.1.0

I created a test project to see if I could find the bug and it seems it happens when adding a dependency which has a lot of (very old) transitive dependencies

javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found
    at javax.xml.parsers.DocumentBuilderFactory.newInstance (Unknown Source)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure (DOMConfigurator.java:849)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure (DOMConfigurator.java:773)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure (OptionConverter.java:483)
    at org.apache.log4j.LogManager.<clinit> (LogManager.java:127)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger (Log4jLoggerFactory.java:64)
    at org.slf4j.LoggerFactory.getLogger (LoggerFactory.java:253)
    at org.slf4j.LoggerFactory.getLogger (LoggerFactory.java:265)
    at com.mycompany.app.App.<clinit> (App.java:8)
    at sun.misc.Unsafe.ensureClassInitialized (Native Method)
    at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue (DirectMethodHandle.java:330)
    at java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue (DirectMethodHandle.java:327)
    at java.lang.ClassValue.getFromHashMap (ClassValue.java:227)
    at java.lang.ClassValue.getFromBackup (ClassValue.java:209)
    at java.lang.ClassValue.get (ClassValue.java:115)
    at java.lang.invoke.DirectMethodHandle.checkInitialized (DirectMethodHandle.java:351)
    at java.lang.invoke.DirectMethodHandle.ensureInitialized (DirectMethodHandle.java:341)
    at java.lang.invoke.DirectMethodHandle.internalMemberNameEnsureInit (DirectMethodHandle.java:291)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:279)
    at java.lang.Thread.run (Thread.java:748)

UPDATE: I managed to replicate the bug with the attached files and running mvn exec:java -Dexec.mainClass=com.mycompany.app.App

I can seem to make it work running mvn exec:exec instead as a workaround

mvn_exec_test.zip