[antlr-interest] createUsingCtor

noahsingleton noahsingleton at yahoo.com
Mon Oct 27 14:34:00 PST 2003


Hello everybody,

I just spent an entire day trying to tack down a problem with using 
BEA Weblogic 8.1 and Antlr.  It's somewhat common knowledge that 
Weblogic 8.1 uses 2.7.2 in weblogic.jar (at least a runtime version, 
but if some could verify what is there...many thanks) and using 
antlr in the weblogic environment is supposedly error free.  I 
believe it to be error free if you don't use AST genereation.  

Here's the run down.  When you start up weblogic server, 
weblogic.jar gets loaded into the "system classloader"  (a 
classloader above the system classloader, but they like to call it 
the system classloader).  This is all fine and dandy until you 
deploy an application that uses antlr and AST generation.  The 
problem lies within createUsingCtor, espically in the Class.forName 
statement right after the opening try block. (line 238 in ASTFactory 
v2.7.2).

Since Class.forName is being called from a older ClassLoader, it has 
no way of know of any younger classloader (ones that would be 
associated with EARs, WARs, and RARs) so instantiating any classes 
from withing those libraries will fail.  Placing antlr.jar in the 
WEB-INF or APP-INF/lib directory doesn't seem to fix them problem 
either, due to a classloaders desire to always ask their parents 
first.

One thought I had to fix the problem and hopefully incorporate the 
fix into weblogic.jar is to change the line

    Class.forName(className);

to

    Class.forName(className, true, Thread.getContextClassLoader());

that way the classloader for that thread, hopefully the same one 
that is running through the ear, war, or rar will contain a 
reference to the appropriate library with the ASTs.

Feedback is wellcome, I'm going to try and see if I can make this 
work.

Cheers,
Noah


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list