Given the following pair of build files: build.xml <?xml version="1.0"?> <project name="jasper problem" default="jasper"> <property name="tomcat" location="jakarta-tomcat-5.0.25"/> <property name="tomcat.bin" location="${tomcat}/bin"/> <property name="tomcat.lib" location="${tomcat}/common/lib"/> <path id="jasper.path"> <fileset dir="${tomcat.lib}"> <include name="*.jar"/> </fileset> <fileset dir="${tomcat.bin}"> <include name="*.jar"/> </fileset> </path> <target name="jasper"> <taskdef classname="org.apache.jasper.JspC" name="jasper2"> <classpath refid="jasper.path"/> </taskdef> <jasper2 uriroot="war" outputDir="build" /> </target> </project> buildall.xml <?xml version="1.0"?> <project name="master build" default="jasper"> <target name="jasper"> <ant dir="." target="jasper" antfile="build.xml"/> <ant dir="." target="jasper" antfile="build.xml"/> </target> </project> "ant -f build.xml" succeeds, but "ant -f buildall.xml" fails, reporting buildall.xml:5: The following error occurred while executing this line: java.lang.ExceptionInInitializerError It is possible to work around this by 1. defining the taskdef in the buildall.xml file and specifying a loaderref, 2. passing the created reference in the <ant> tasks, and 3. using the same reference as the loaderref in the build.xml file. It's a bit obtuse, though. The problem exists also with ant 1.6.1 and jasper 5.0.19, and does not appear to be particular to OSX as I can reproduce it on Solaris. The failure, with the -v options follows: $ ant -v -f buildall.xml Apache Ant version 1.6.2beta1 compiled on July 2 2004 Buildfile: buildall.xml Detected Java version: 1.4 in: /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home Detected OS: Mac OS X parsing buildfile /Users/andy/work/bugs/ant-tomcat/buildall.xml with URI = file:///Users/andy/work/bugs/ant-tomcat/buildall.xml Project base dir set to: /Users/andy/work/bugs/ant-tomcat Build sequence for target `jasper' is [jasper] Complete build sequence is [jasper, ] jasper: Project base dir set to: /Users/andy/work/bugs/ant-tomcat [ant] calling target jasper in build file /Users/andy/work/bugs/ant-tomcat/build.xml parsing buildfile /Users/andy/work/bugs/ant-tomcat/build.xml with URI = file:///Users/andy/work/bugs/ant-tomcat/build.xml Project base dir set to: /Users/andy/work/bugs/ant-tomcat [ant] Entering /Users/andy/work/bugs/ant-tomcat/build.xml... Build sequence for target `jasper' is [jasper] Complete build sequence is [jasper, ] jasper: [ant] Exiting /Users/andy/work/bugs/ant-tomcat/build.xml. Project base dir set to: /Users/andy/work/bugs/ant-tomcat [ant] calling target jasper in build file /Users/andy/work/bugs/ant-tomcat/build.xml parsing buildfile /Users/andy/work/bugs/ant-tomcat/build.xml with URI = file:///Users/andy/work/bugs/ant-tomcat/build.xml Project base dir set to: /Users/andy/work/bugs/ant-tomcat [ant] Entering /Users/andy/work/bugs/ant-tomcat/build.xml... Build sequence for target `jasper' is [jasper] Complete build sequence is [jasper, ] jasper: [ant] Exiting /Users/andy/work/bugs/ant-tomcat/build.xml. BUILD FAILED /Users/andy/work/bugs/ant-tomcat/buildall.xml:5: The following error occurred while executing this line: java.lang.ExceptionInInitializerError at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539) at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:388) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeTarget(Project.java:1214) at org.apache.tools.ant.Project.executeTargets(Project.java:1062) at org.apache.tools.ant.Main.runBuild(Main.java:673) at org.apache.tools.ant.Main.startAnt(Main.java:188) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) Caused by: java.lang.ExceptionInInitializerError at org.apache.tools.ant.Project.executeTarget(Project.java:1223) at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:386) ... 10 more Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457) at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeTarget(Project.java:1214) ... 11 more Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395) at org.apache.jasper.JspC.<clinit>(JspC.java:90) ... 20 more Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525) ... 24 more Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:412) ... 25 more --- Nested Exception --- java.lang.ExceptionInInitializerError at org.apache.tools.ant.Project.executeTarget(Project.java:1223) at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:386) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeTarget(Project.java:1214) at org.apache.tools.ant.Project.executeTargets(Project.java:1062) at org.apache.tools.ant.Main.runBuild(Main.java:673) at org.apache.tools.ant.Main.startAnt(Main.java:188) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457) at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeTarget(Project.java:1214) ... 11 more Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395) at org.apache.jasper.JspC.<clinit>(JspC.java:90) ... 20 more Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525) ... 24 more Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:412) ... 25 more --- Nested Exception --- java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457) at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeTarget(Project.java:1214) at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:386) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeTarget(Project.java:1214) at org.apache.tools.ant.Project.executeTargets(Project.java:1062) at org.apache.tools.ant.Main.runBuild(Main.java:673) at org.apache.tools.ant.Main.startAnt(Main.java:188) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395) at org.apache.jasper.JspC.<clinit>(JspC.java:90) ... 20 more Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525) ... 24 more Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:412) ... 25 more Total time: 4 seconds
Can you provide an example of the workaround?
Created attachment 12133 [details] an example of a work around
Hello Andy, what you are saying boils down to : "the use of the loaderRef attribute is compulsory in order to be able to use the tomcat jasper task multiple times in one run of ant." <taskdef classname="org.apache.jasper.JspC" name="jasper2" loaderRef="jasper"> <classpath refid="jasper.path"/> </taskdef>
I am saying a more than that. Not only is the loaderRef compulsory, but all must refer to the _same_ loader reference. In the zip'd example, if you change the "bad" target in buildall.xml to: <target name="bad"> <ant dir="." target="good" antfile="build.xml"/> <ant dir="." target="good" antfile="build.xml"/> </target> "ant -f buildall.xml bad" will still fail, even though the tomcat taskdef uses loaderRef. Sharing a single loader reference among a hierarchy of build.xml files that call one another is at best awkward.
I tried ant 1.6.2 and tomcat 5.0.27. The behaviour is still the same, but the "caused by" error message in the "ant -v" output is now different: Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
Updating version to 5.0.27 and changing OS to All. So what do you suggest as the fix? Have Jasper not use Commons-Logging? Or perhaps this is a Commons-Logging bug?
*Do* you have more than one version of org.apache.commons.logging.Log on the classpath?
No, I don't believe there is more than one copy of Log in the classpath. I have no global classpath. The class does not appear to be part of ant. I modified the build file to list only the required jasper jar files. They are, from common/lib, jasper-compiler, jasper-runtime, servlet-api, jsp-api, commons-el and from bin, commons-logging-api. Only the last contains the Log class, and without it, the build fails because org.apache.commons.logging.LogFactory is missing. The behavior isn't changed by explicitly including the 6 jar files in the build.xml file, rather than including "*.jar".
I believe we've got this now ;) *** This bug has been marked as a duplicate of 32330 ***