You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Morgan Kinne <ki...@us.ibm.com> on 2008/10/27 21:57:18 UTC

java.security.PrivilegedActionException in Jython scriptdef

Hi,
I'm a newbie here and a newbie to Jython and scripting in Ant. In that 
vein:

I've created a scriptdef task which I wrote in Jython. I'm using BSF as 
the manager. My intent was to delete files within this task. Everything 
works right up to the point where a file is to be deleted, when I get this 
exception:

eraseZipFiles:
[delete-in-each-child-dir] Processing ap
Oct 27, 2008 4:15:59 PM org.apache.bsf.BSFManager exec
SEVERE: Exception :
java.security.PrivilegedActionException: org.apache.bsf.BSFException: 
exception
from Jython:

Traceback (innermost last):
  File "<string>", line 25, in ?
        at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:624)

        at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:570)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)

That's when I smacked my forehead and said to myself, "Self, you're 
working in a sandbox you idiot."
Of course I can solve this issue any number of ways, but I was wondering 
if there was some way to "disable" the security manager? Would I have the 
same issue if I used javax. as the manager? I hope so because I've found 
scripting with Jython to be very effective.
Morgan

Re: java.security.PrivilegedActionException in Jython scriptdef

Posted by Steve Loughran <st...@apache.org>.
Morgan Kinne wrote:
> Thanks Steve. You were correct of course. I was evidently trying to delete 
> files in a directory that didn't exist! Who would have thought that would 
> result in a security related exception. Bad on me for jumping to the 
> conclusion I jumped to. All is working properly now.

well, there's still a security manager getting in the way -it is 
security related problem. Otherwise you'd have seen the error message/

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Re: java.security.PrivilegedActionException in Jython scriptdef

Posted by Morgan Kinne <ki...@us.ibm.com>.
Thanks Steve. You were correct of course. I was evidently trying to delete 
files in a directory that didn't exist! Who would have thought that would 
result in a security related exception. Bad on me for jumping to the 
conclusion I jumped to. All is working properly now.

Re: java.security.PrivilegedActionException in Jython scriptdef

Posted by Steve Loughran <st...@apache.org>.
Morgan Kinne wrote:
> Hi,
> I'm a newbie here and a newbie to Jython and scripting in Ant. In that 
> vein:
> 
> I've created a scriptdef task which I wrote in Jython. I'm using BSF as 
> the manager. My intent was to delete files within this task. Everything 
> works right up to the point where a file is to be deleted, when I get this 
> exception:
> 
> eraseZipFiles:
> [delete-in-each-child-dir] Processing ap
> Oct 27, 2008 4:15:59 PM org.apache.bsf.BSFManager exec
> SEVERE: Exception :
> java.security.PrivilegedActionException: org.apache.bsf.BSFException: 
> exception
> from Jython:
> 
> Traceback (innermost last):
>   File "<string>", line 25, in ?
>         at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:624)
> 
>         at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:570)
> 
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> java:39)
> 
> That's when I smacked my forehead and said to myself, "Self, you're 
> working in a sandbox you idiot."
> Of course I can solve this issue any number of ways, but I was wondering 
> if there was some way to "disable" the security manager? Would I have the 
> same issue if I used javax. as the manager? I hope so because I've found 
> scripting with Jython to be very effective.
> Morgan

Ant has a very minimal sandbox that is designed to stop you calling 
system.exit() and nothing else. So I'm pretty surprised by this. Maybe 
its BSF Manager at play

1. Looking at the stack trace, you've just tried to create a directory 
that isnt there
             } else if (!fsDir.isDirectory()) {
                 handle("Directory does not exist:" + fsDir);   //here

2. Is there a version of Jython for the Java6 scripting engine? Ant can 
work with that instead.

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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