Re: Problems with addClassPath() and access control permissions

Helio Perroni Filho <xperroni-/[email protected]> Sun, 30 Apr 2006 12:56:28 +0000 (GMT)
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
--- Wade Chandler <hwadechandler-beanshell-/[email protected]>
wrote:

>> 1 - When I invoke the addClassPath() method
>> several times in a script, only the first
>> invokation works  -- the following ones just get
>> ignored;
>
> Not sure here. Sounds like a bug the way you
> describe it. Just to aid someone else as I don't
> know:
> 
> Do you mean you are calling like:
> addClassPath("somejar.jar");
> addClassPath("anotherjar.jar");
> 
> and only somejar.jar is being added?

Yes. I've been doing some debugging already, and so
far it seems that BshClassLoader.addURL() is called
only for the first JAR file -- even though, at the
script level, addClassPath() does get called for the
following ones. I'll continue looking into it and see
if I can figure out why. 

>> 2 - When running from an unsigned applet,
>> instantiating the bsh.Interpreter class throws an
>> AccessControlException, due to insufficient
>> privileges to call the getContextClassLoader()
>> method (I can send an exception trace if anyone is
>> interested).
>
> Nothing to fix here I don't imagine.

Actually I found a way around this, without signing
the applet. The problem is, when Class.forName() is
given an invalid qualified class name argument (say,
"java.lang.bsh"), the Security Manager, if there is
one, throws an AccessControlException even if the
related class file doesn't even exist in the first
place. No AccessControlException is thrown if the name
is valid but does not relate to a known class, or if
the name relates to a known, correctly named class.

Then why the hell does the exception trace points to a
problem with getContextClassLoader()? No idea, but
"swallowing" the exception -- adding an empty
catch(AccessControlException e) block to the end of
the try..catch block on
BshClassManager.plainClassForName() -- did solve it.
At least, I have done some tests here and it seems to
work just fine.

-- 
Ja mata ne.
Helio



		
_______________________________________________________ 
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz. 
http://br.info.mail.yahoo.com/


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642