I'd support changing Class.forname to the thread context classloader.
We did a bunch of changes (in 1.5 dev) on this topic but not all.
Two tricky points to consider
* "ant test" has to pass. There's some cases in which ant does strange
things (shows up in the texen tests)
* If the Velocity jar is in the app server lib file, but the classes that
are being retrieved are in the web-app lib directory, this still needs to
work.
My suggestion is to replace any calls to Class.forName() with
ClassUtils.getNewInstance(). This has some fall back code that is required.
Best,
WILL
----- Original Message -----
From: "Nathan Bubna" <[EMAIL PROTECTED]>
To: "Velocity Users List" <[email protected]>
Sent: Tuesday, June 07, 2005 9:15 AM
Subject: Re: classloading
good thought. and i'm fairly sure the answer is no, there's not
really much argument for the current state of things. one of the
original developers might have one, but as things have developed over
the years, the consensus has been that these are largely annoyances.
it's just that they apparently have never been annoying enough to
motivate anyone to step up to fix them (yet).
my understanding is that the Class.forName() stuff originated back
when that was the typical practice. the context classloader is
accepted as the right way for almost all situations now, including
velocity, i'm sure. and i don't think it'll cause any backwards
compatibility problems.
as for the overly verbose and dramatic logs, i think there is already
a bug or two filed on those, but i'm not aware of any patches. i
think if you provided a simple and backwards compatible patch to tame
those, Will would probably accept it (i hope). though i should make
one warning: talk of putting various messages in "categories" could
trigger another round of the commons-logging debate. my advice is to
keep the patch to anti-annoyance, and save any major logging
refactoring for later. bundling the two might kill both. :)
On 6/7/05, Max Rydahl Andersen <[EMAIL PROTECTED]> wrote:
On Tue, 07 Jun 2005 17:13:01 +0200, Nathan Bubna <[EMAIL PROTECTED]> wrote:
> patches would help :)
yes - but before doing so just wanted to know if there were any argument
for
how it is done now ,)
-max
>
> On 6/7/05, Max Rydahl Andersen <[EMAIL PROTECTED]> wrote:
>> On Mon, 06 Jun 2005 20:17:38 +0200, Shinobu Kawai
>> <[EMAIL PROTECTED]> wrote:
>>
>> > Hi max,
>> >
>> >> Any particular reason why velocity only do Class.forName() where
>> >> it should first look in thread context classloader and THEN do
>> >> Class.forName() ?
>> >>
>> >> (it gives some issues when running in environments with changing
>> >> classloaders, like
>> >> J2EE and Eclipse)
>> >
>> > Are we talking about the ClasspathResourceLoader? Then it's fixed in
>> > the latest repository.
>> > http://issues.apache.org/bugzilla/show_bug.cgi?id=22419
>> > For the latest in the repository:
>> > http://cvs.apache.org/snapshots/velocity/
>>
>> I'm talking about
>>
>> FieldMethodizer
>> RuntimeInstance
>> LogManager
>> ResourceManagerImpl
>> ResourceLoaderFactory
>> Generator
>>
>> While on the subject of things that "messes" up J2EE/Eclipse
>> environments.
>>
>> Why is so much stuff logged as WARN/ERROR in Velocity ?
>>
>> Like:
>> "ERROR: ResourceManager : unable to find resource
>> 'VM_global_library.vm'
>> in any resource loader."
>>
>> That should at least only be a WARN and it should be in a
>> ResourceManager
>> category so you could disable it.
>>
>> And:
>> "Warning! The iterative is an Iterator in the #foreach() loop at [0,0]
>> in
>> template pojo/javaclass.vm. Because it's not resetable, if used in more
>> than once, this may lead to unexpected results."
>>
>> Again, I undestand why this is there - but it should only be done on
>> objects that is directly in the context (if at all). Printing out this
>> warning
>> for every iterator is simply not very usefull... e.g. printing this
>> warning for a methodcall that does someList.iterator() is just noise.
>>
>> I removed this last one by providing my own UberSpectImpl, but it
>> should
>> not be necessary IMO.
>>
>> /max
>>
>>
>>
>> >
>> > Best regards,
>> > -- Shinobu
>> >
>> > --
>> > Shinobu Kawai <[EMAIL PROTECTED]>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail:
>> > [EMAIL PROTECTED]
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]