Problem parsing XML in code run using antrun plugin
---------------------------------------------------
Key: MNG-2459
URL: http://jira.codehaus.org/browse/MNG-2459
Project: Maven 2
Issue Type: Bug
Components: Ant tasks
Affects Versions: 2.0.4
Environment: Red Hat Enterprise Linux WS release 4 (Nahant Update 3)
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
Reporter: Kris Nuttycombe
Attachments: antrun-log4j-xml-test.tgz
I'm not certain whether this is an antrun problem or a log4j problem, but
considering that the same application run from the command line has no
problems, I'm going to point to antrun as the first possible culprit.
This error occurs when I attempt to use the antrun plugin to run a standalone
Java program that is, for deployment, packaged as a jar-with-dependencies jar
using the assembly plugin. I use antrun during development for the purpose of
giving me the benefit of the classpath information from the POM; if there's a
better way of doing this I'd be happy to work around the problem.
The error appears to occur when log4j attempts to parse an XML configuration
file using the DOMConfigurator. It appears that the DocumentBuilderFactory
package name is being prepended with "com.sun." when the application is run
using the antrun plugin. Is there some aspect of Maven or of the antrun plugin
that is altering the XML parsing environment?
[java] javax.xml.parsers.FactoryConfigurationError: Provider
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl could not be
instantiated: java.lang.NullPointerException
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:180)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
[java] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[java] at org.apache.tools.ant.Task.perform(Task.java:364)
[java] at org.apache.tools.ant.Target.execute(Target.java:341)
[java] at
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
[java] at
org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
[java] at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
[java] at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
[java] at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:488)
[java] at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:458)
[java] at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
[java] at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
[java] at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
[java] at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
[java] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
[java] at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
[java] at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
[java] at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
[java] at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[java] Caused by: javax.xml.parsers.FactoryConfigurationError: Provider
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl could not be
instantiated: java.lang.NullPointerExce
ption
[java] at
javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:104)
[java] at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:644)
[java] at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
[java] at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:584)
[java] at
org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:687)
[java] at gov.noaa.eds.sdif.SdifRunner.main(SdifRunner.java:45)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
[java] ... 26 more
The attached test setup can be run using the following call from the command
line:
mvn -DlogConfig=src/test/resources/log4j_conf.xml compile antrun:run
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira