Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unable to access jarfile" in linux land

Tags:

java

linux

jar

We have an web application running under JBoss 5 which periodically launches a 'java' process (using ProcessBuilder) to compile files on Linux. The process works without problems on the Windows development machine and on a Ubuntu virtual machine that we've got installed. The command is as follows:

/usr/java/jdk1.6.0_18/bin/java -Xmx256M -DiDesigner.javabin=java -jar "/aplicaciones/jboss/nfs/pmc_tdt/bin/lib/iDesigner.jar" --compiler --obfuscate --in "81.ida" --out "directory:OUTPUT"

Which creates the error:

Unable to access jarfile "/aplicaciones/jboss/nfs/pmc_tdt/bin/lib/iDesigner.jar"

All paths are confirmed to be correct and the jar file path is enclosed by double quotes. After two beers and a Big Mac the Systems Department confirmed that the user (jbossadmin) running JBoss is also the owner of the file:

[root@miv-multicanalidad-01 lib]# pwd
/aplicaciones/jboss/nfs/pmc_tdt/bin/lib
[root@miv-multicanalidad-01 lib]# ls -l iDesigner.jar
-rw-r--r-- 1 jbossadmin jbossadmin 1329162 ene 22  2010 iDesigner.jar

I suspect that it's a rights issue so we asked them to change the permissions to execute but alas, still no gratification.

The only thing I can think of is that it's a path translation error or that we haven't applied the right rights to the right place!

Edit: An excellent suggestion by Andrea Spadaccini, however it seems that we already have the traversal permissions through the path:

drwxr-xr-x 3 root root 4096 abr  6  2010 /aplicaciones/
drwxr-xr-x+ 16 jbossadmin jbossadmin 4096 mar  7 10:13 /aplicaciones/jboss/
drwxrwxr-x+ 5 jbossadmin jbossadmin 4096 ene 25 09:21 /aplicaciones/jboss/nfs/
drwxr-xr-x 4 jbossadmin jbossadmin 4096 abr  6 16:03 /aplicaciones/jboss/nfs/pmc_tdt
drwxr-xr-x 4 jbossadmin jbossadmin 4096 sep  3  2010 /aplicaciones/jboss/nfs/pmc_tdt/bin/
drwxr-xr-x 3 jbossadmin jbossadmin 4096 abr  6 16:03 /aplicaciones/jboss/nfs/pmc_tdt/bin/lib/ 

Edit: With Eva we can confirm that executing the line via the command line (bash) that it works but it throws the error if we execute the line from the ProcessBuilder class, embedded in a jar file, in Linux. Just as our JBoss would do. The double quotes around the parameters are the most likely cause of the issue here.

like image 428
ian_scho Avatar asked Apr 06 '11 16:04

ian_scho


1 Answers

@ian_scho Hi!, I think the problem here is that by command line quotation marks is allowed because is interpreted by the process bash in linux (which is the command line interpret)... When ProcessBuilder class is used inside java code, quotation marks are interpreted as part of the path...for that the error "Unable to access jarfile" is showed. You can see the process parent with the command ps -adf , try to run your comand line in background (&) as follow:

/usr/java/jdk1.6.0_18/bin/java -Xmx256M -DiDesigner.javabin=java -jar "/aplicaciones/jboss/nfs/pmc_tdt/bin/lib/iDesigner.jar" --compiler --obfuscate --in "81.ida" --out "directory:OUTPUT" &

and then call the command

ps -adf

you will see that bash process is the parent... If you do the same when jboss is running you could see that the process' parent of the java execution is another process that can't interpret quotation marks.

I hope that this will help you :)

like image 124
evita Avatar answered Oct 30 '22 15:10

evita