You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Sam Ruby <ru...@us.ibm.com> on 2001/09/27 18:22:20 UTC

RE: Reverse class loading undocumented, required and deprecated?

I was wrong.  Here's the answer from Conor.  Seems like the he's advocating
the removal of a few lines of code in Velocity.  That makes sense to me...

- Sam Ruby

---------------------- Forwarded by Sam Ruby/Raleigh/IBM on 09/27/2001
12:21 PM ---------------------------

"Conor MacNeill" <co...@cortexebusiness.com.au> on 09/20/2001 07:42:11 PM

Please respond to ant-dev@jakarta.apache.org

To:   <an...@jakarta.apache.org>
cc:
Subject:  RE: Reverse class loading undocumented, required and deprecated?



Sam,

In Ant 1.4, I changed the taskdef classloading so that it delegates to the
parent classloader. This is the proper behaviour. I did put a warning into
WHATSNEW about this. If you recall, the old behaviour is the source of
Linkage errors in xml-fop. This behaviour is not always desirable, however,
since factory objects that exist in the system classpath are unable to load
classes in the classpath given to the task classloader. That is what is
happening below. The SAX factory use by Ant's core cannot see the Xerces
parser.

I asked Geir to change Velocity so that it did not ask for a specific
parser. This would have made this problem go away and Anakia would have
used
Ant's XML parser rather than xerces. That did not happen.

There was another problem with Anakia, however, related to the Velocity
singleton. Basically you can't have two instances of this task when the
velocity classes exist in the system classpath as the singleton gets
created
once with the template path and the second instance cannot reset the
template path. IMHO, singletons are evil :-)

So, since it did not appear that Anakia/velocity were going to change, I
relunctantly added a mechanism to access the Ant 1.3 behaviour, so that
these tasks would continue to function, albeit with some effort. I didn't
really want this attribute to become popular. That is also why it is
deprecated. Nevertheless, until Anakia/Velocity are changed, it will be
required to use these tasks.

In truth, classloading has been gradually grafted onto Ant and it shows up
in overlapping classpaths between the Ant core and its tasks. It needs to
be
changed but will most easily be achieved in Ant2. We need to clearly define
the classloader hierarchy as has been done in servlet containers.

Conor


> -----Original Message-----
> From: Sam Ruby [mailto:rubys@us.ibm.com]
> Sent: Friday, 21 September 2001 2:23 AM
> To: ant-dev@jakarta.apache.org
> Subject: Reverse class loading undocumented, required and deprecated?
>
>
> I'm describing the scenario below using the released version of 1.4.  It
> applies equally to the latest CVS.  It also represents a change
> in behavior
> from Ant 1.3.
>
> Test case:
>
>    Download ant 1.4 distribution.  Unpack.  Set path and ANT_HOME.
>
>    Checkout jakarta-site2.  Cd into the directory.
>
>    Execute "ant" with no arguments.
>
> Results:
>
>    Buildfile: build.xml
>
>    prepare:
>
>    prepare-error:
>
>    docs:
>       [anakia] Transforming into: D:\jakarta\jakarta-site2\docs
>       [anakia] Error: org.jdom.JDOMException: Error in building:
> SAX2 driver class org.apache.xerces.parsers.SAXParser not found
>
>    BUILD FAILED
>
>    D:\jakarta\jakarta-site2\build.xml:44: org.jdom.JDOMException:
> Error in building: SAX2 driver class
> org.apache.xerces.parsers.SAXParser not found
>
>    Total time: 2 seconds
>
> Apply the following patch:
>
>    Index: build.xml
>    ===================================================================
>    RCS file: /home/cvs/jakarta-site2/build.xml,v
>    retrieving revision 1.7
>    diff -u -r1.7 build.xml
>    --- build.xml   2001/07/27 18:54:01     1.7
>    +++ build.xml   2001/09/20 16:11:53
>    @@ -31,7 +31,7 @@
>         <!-- This Target is for output of HTML pages for the web site -->
>         <target name="docs" depends="prepare-error"
> if="AnakiaTask.present"
>          description="Render HTML Pages via Anakia">
>    -        <taskdef name="anakia"
>    +        <taskdef name="anakia" reverseLoader="true"
>                 classname="org.apache.velocity.anakia.AnakiaTask">
>                 <classpath refid="classpath"/>
>             </taskdef>
>
> Try again:
>
>    Buildfile: build.xml
>
>    prepare:
>
>    prepare-error:
>
>    docs:
>      [taskdef] The reverseloader attribute is DEPRECATED. It will
> be removed
>       [anakia] Transforming into: D:\jakarta\jakarta-site2\docs
>       [anakia] Input:  index.xml
>       [anakia] Output: D:\jakarta\jakarta-site2\docs\index.html
>
> - Sam Ruby
>
>




Re: Reverse class loading undocumented, required and deprecated?

Posted by Jon Stevens <jo...@latchkey.com>.
> I asked Geir to change Velocity

Geir is not the only one working on Velocity and there is no reason why
Conor couldn't have submitted a bug report for Velocity.

Placing this entirely on Geir's shoulders is totally not cool.

-jon


Re: Reverse class loading undocumented, required and deprecated?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/27/01 12:22 PM, "Sam Ruby" <ru...@us.ibm.com> wrote:

> I was wrong.  Here's the answer from Conor.  Seems like the he's advocating
> the removal of a few lines of code in Velocity.  That makes sense to me...
> 
> - Sam Ruby
> 
> ---------------------- Forwarded by Sam Ruby/Raleigh/IBM on 09/27/2001
> 12:21 PM ---------------------------
> 
> "Conor MacNeill" <co...@cortexebusiness.com.au> on 09/20/2001 07:42:11 PM
> 
> Please respond to ant-dev@jakarta.apache.org
> 
> To:   <an...@jakarta.apache.org>
> cc:
> Subject:  RE: Reverse class loading undocumented, required and deprecated?
> 
> 
> 
> Sam,
> 
> In Ant 1.4, I changed the taskdef classloading so that it delegates to the
> parent classloader. This is the proper behaviour. I did put a warning into
> WHATSNEW about this. If you recall, the old behaviour is the source of
> Linkage errors in xml-fop. This behaviour is not always desirable, however,
> since factory objects that exist in the system classpath are unable to load
> classes in the classpath given to the task classloader. That is what is
> happening below. The SAX factory use by Ant's core cannot see the Xerces
> parser.
> 
> I asked Geir to change Velocity so that it did not ask for a specific
> parser. This would have made this problem go away and Anakia would have
> used
> Ant's XML parser rather than xerces. That did not happen.

No, because the problem went away, so I figured you 'fixed' ant :)

I tried to play with that suggestion, letting JDOM find it's own parser
(that's where the problem is - not in Velocity, but where Anakia gets a
builder from JDOM), but that didn't fly.  I moved one as it wasn't a
pressing issue.

> 
> There was another problem with Anakia, however, related to the Velocity
> singleton. Basically you can't have two instances of this task when the
> velocity classes exist in the system classpath as the singleton gets
> created
> once with the template path and the second instance cannot reset the
> template path. IMHO, singletons are evil :-)

I agree - singletons are evil - however, they do exist and I think Ant
should support them.  However, I am just one ant user among millions...

Anakia doesn't use the velocity singleton - it creates its own separate
instance, BTW.

Texen, on the other hand, still is Singleton based. We should fix that
sometime.  I took a look when I did the change to let velocity have separate
Runtimes, but it didn't seem obvious, and I really don't know Texen or how
people use it.

 
> So, since it did not appear that Anakia/velocity were going to change, I
> relunctantly added a mechanism to access the Ant 1.3 behaviour, so that
> these tasks would continue to function, albeit with some effort. I didn't
> really want this attribute to become popular. That is also why it is
> deprecated. Nevertheless, until Anakia/Velocity are changed, it will be
> required to use these tasks.

I am surprised that this hasn't come up more often.
 
> In truth, classloading has been gradually grafted onto Ant and it shows up
> in overlapping classpaths between the Ant core and its tasks. It needs to
> be
> changed but will most easily be achieved in Ant2. We need to clearly define
> the classloader hierarchy as has been done in servlet containers.
> 
> Conor

Thx

geir
 
> 
>> -----Original Message-----
>> From: Sam Ruby [mailto:rubys@us.ibm.com]
>> Sent: Friday, 21 September 2001 2:23 AM
>> To: ant-dev@jakarta.apache.org
>> Subject: Reverse class loading undocumented, required and deprecated?
>> 
>> 
>> I'm describing the scenario below using the released version of 1.4.  It
>> applies equally to the latest CVS.  It also represents a change
>> in behavior
>> from Ant 1.3.
>> 
>> Test case:
>> 
>>    Download ant 1.4 distribution.  Unpack.  Set path and ANT_HOME.
>> 
>>    Checkout jakarta-site2.  Cd into the directory.
>> 
>>    Execute "ant" with no arguments.
>> 
>> Results:
>> 
>>    Buildfile: build.xml
>> 
>>    prepare:
>> 
>>    prepare-error:
>> 
>>    docs:
>>       [anakia] Transforming into: D:\jakarta\jakarta-site2\docs
>>       [anakia] Error: org.jdom.JDOMException: Error in building:
>> SAX2 driver class org.apache.xerces.parsers.SAXParser not found
>> 
>>    BUILD FAILED
>> 
>>    D:\jakarta\jakarta-site2\build.xml:44: org.jdom.JDOMException:
>> Error in building: SAX2 driver class
>> org.apache.xerces.parsers.SAXParser not found
>> 
>>    Total time: 2 seconds
>> 
>> Apply the following patch:
>> 
>>    Index: build.xml
>>    ===================================================================
>>    RCS file: /home/cvs/jakarta-site2/build.xml,v
>>    retrieving revision 1.7
>>    diff -u -r1.7 build.xml
>>    --- build.xml   2001/07/27 18:54:01     1.7
>>    +++ build.xml   2001/09/20 16:11:53
>>    @@ -31,7 +31,7 @@
>>         <!-- This Target is for output of HTML pages for the web site -->
>>         <target name="docs" depends="prepare-error"
>> if="AnakiaTask.present"
>>          description="Render HTML Pages via Anakia">
>>    -        <taskdef name="anakia"
>>    +        <taskdef name="anakia" reverseLoader="true"
>>                 classname="org.apache.velocity.anakia.AnakiaTask">
>>                 <classpath refid="classpath"/>
>>             </taskdef>
>> 
>> Try again:
>> 
>>    Buildfile: build.xml
>> 
>>    prepare:
>> 
>>    prepare-error:
>> 
>>    docs:
>>      [taskdef] The reverseloader attribute is DEPRECATED. It will
>> be removed
>>       [anakia] Transforming into: D:\jakarta\jakarta-site2\docs
>>       [anakia] Input:  index.xml
>>       [anakia] Output: D:\jakarta\jakarta-site2\docs\index.html
>> 
>> - Sam Ruby
>> 
>> 
> 
> 
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin