ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Fyfe <af...@bigtribe.com>
Subject Re: Why does this ant script fail?
Date Thu, 11 Mar 2004 17:39:48 GMT
Thanks for the reply.

To match the "real" scenario better, remove the second <taskdef>
from the build.xml file and create a second ant file, say buildall.xml,
that looks like

<?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>

Then "ant -f buildall.xml" will still show the same failure when the
second task is defined.  It's not a surprise -- I wouldn't expect the
loaderRef to be shared in this case.

However, if buildall.xml also defines the <jasper2> task, uses the
same loaderRef, and the <ant> tasks use either inheritRefs="true"
or a nested <reference ... />, then it works.

I appreciate your help; I should now be able to work around this
in the real build environment.

It's a bit subtle though.... Bug or gotcha?

--Andy

On Mar 11, 2004, at 2:07 AM, Peter Reilly wrote:

The second <typedef> sets up a different ant-class classloader.
For some reason, (most likely a bug? use of static objects?) class  
instances
from the first classloader are still around and mess up the second  
definition.

If you use a loader reference tag on the taskdef, the problem  
disappears:

  <target name="jasper">
    <taskdef classname="org.apache.jasper.JspC" name="jasper2"  
loaderref="jasper">
      <classpath refid="jasper.path"/>
    </taskdef>
    <jasper2 uriroot="war" outputDir="build" />
    <taskdef classname="org.apache.jasper.JspC"
             name="jasper2again" loaderref="jasper">
      <classpath refid="jasper.path"/>
    </taskdef>
    <jasper2 uriroot="war" outputDir="build" />
  </target>

Peter

Andy Fyfe wrote:

> With -verbose, the exception occurs in the second <taskdef> , ant
> the "root" cause of the exception is
>
> 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(LogFac 
> t oryImpl.java:412)
>
> This comes from org.apache.jasper.JspC.<clinit>(JspC.java:135),
> which reads
>
>     private static Log log = LogFactory.getLog(JspC.class);
>
> This in turn is traced back to
> org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:434),
> which reads
>
>                     cl = Class.forName(classname, true, al);
>
> There is no exception if one simply defines two jasper tasks; running
> jasper seems to be required.  But the fault doesn't occur until ant   
> tries
> a second time to load the JspC class.
>
> Could jasper be messing up the logging system?  Or ant's class loader?
>
> --Andy
>
> On Mar 10, 2004, at 11:11 PM, Jan.Materne@rzf.fin-nrw.de wrote:
>
>> Try in -verbose mode. I canĀ“t see any mistake here.
>> But java.lang.ExceptionInInitializerError sounds that something
>> inside <jspc> is wrong. But that would be question on Tomcat.
>>
>> Jan
>>
>>
>>> -----Original Message-----
>>> From: Andy Fyfe [mailto:afyfe@bigtribe.com]
>>> Sent: Wednesday, March 10, 2004 11:03 PM
>>> To: Ant Users List
>>> Subject: Why does this ant script fail?
>>>
>>>
>>> Here's the script:
>>>
>>> <?xml version="1.0"?>
>>> <project name="jasper problem" default="jasper">
>>>      <property name="tomcat" location="jakarta-tomcat-5.0.19"/>
>>>      <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" />
>>>          <taskdef classname="org.apache.jasper.JspC"
>>> name="jasper2again">
>>>              <classpath refid="jasper.path"/>
>>>          </taskdef>
>>>      </target>
>>> </project>
>>>
>>> The only other file is war/index.jsp (so jasper has something to do):
>>>
>>> <%@ page language="java" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD
>>> HTML 4.01
>>> Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
>>> <html>
>>> <head>
>>> <title>Index Page</title>
>>> </head>
>>> <body>
>>> <P>Content free...
>>> </body>
>>> </html>
>>>
>>> When run (ant 1.6.1, and tomcat 5.0.19) I get:
>>>
>>> Buildfile: build.xml
>>>
>>> jasper:
>>>
>>> BUILD FAILED
>>> java.lang.ExceptionInInitializerError
>>>
>>> Total time: 3 seconds
>>>
>>> This example is a much simpler example of a problem I've been having.
>>> In the real code, a master build file calls a pair of other build
>>> files, each
>>> of which attempts to define and use a jasper task.  The
>>> second <taskdef>
>>> fails as above.  Same problem on both solaris and mac osx.
>>>
>>> --Andy Fyfe
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message