Unable to execute and checkPermission NPE

This is a very strange problem and I am unsure if this is the correct forum.

I have a java program that uses

Runtime.getRuntime().exec("<command>")

in order to launch another program.

On Solaris 8 it works fine. In our Solaris 10 production environment it doesn抰 work. However, in a relatively fresh, non-tampered with, Solaris 10 environment it does work.

When it doesn抰 work I get a java.io.IOException: <command> : cannot execute error.

As the user I am running java program as, I am able to run the command from the shell. The command I am trying to exec has the read and execute bits set for the user and group (550). My user抯 group is the same as the command抯. I get the same error even if I run the java program as root. So I am pretty sure the problem isn't the command's permissions.

I tried to check the command抯 file permission in java before trying to execute it, using this.

System.out.println("creating file permission object");

FilePermission fp =new FilePermission("<command>","execute");

System.out.println("Checking the permission, which is " + fp);

security.checkPermission(fp);

The last line of that always throws a null point exception, even though fp is never null.

As a last resort I tried changing the permission of the command to 555. After that, everything worked, but the crazy thing is, I still get the NPE when I check the permissions.

Does anybody know what could cause this, or where else I can look for clues? I don抰 think leaving the 555 permission will be acceptable.

[1777 byte] By [dstanfie3a] at [2007-11-26 14:29:50]
# 1

> I tried to check the command抯 file permission in

> java before trying to execute it, using this.

That's not how you do it. The execute permission you require isn't known to Java or the security manager. You can't check execute permissions in Java except by trying to execute.

> The last line of that always throws a null point

> exception, even though fp is never null.

Maybe 'security' is null, but it's irrelevant as the permissions you require aren't known to Java or the security manager.

> As a last resort I tried changing the permission of

> the command to 555. After that, everything worked,

> but the crazy thing is, I still get the NPE when I

> check the permissions.

See above.

You'll have to set the execute permissions in some way that works and that is acceptable. That has nothing to do with Java, security managers, or this forum.

ejpa at 2007-7-8 2:24:19 > top of Java-index,Security,Other Security APIs, Tools, and Issues...