Java – “jarfile cannot be accessed in Linux”

We have a web application running under JBoss 5, which regularly starts a 'Java' process (using processbuilder) to compile files on Linux The process runs normally on the windows development machine and the Ubuntu virtual machine we have 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"

This results in an error:

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

All paths are confirmed to be correct and jar file path is enclosed by double quotes After two beers and a big Mac, the system department confirmed that the user running JBoss (jbossadmin) was 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 doubt it's rights issue, so we asked them to change the permissions to execute, but alas, there is still no satisfaction

The only thing I can think of is whether it is path translation error or whether we have not applied the right rights to the right place!

Editor: Andrea Spadaccini made a good suggestion, but it seems that we have obtained traversal permission 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: Using EVA, we can confirm that it works by executing the line through the command line (bash), but if we execute the line in the processbuilder class embedded in the jar file in Linux, an error will be thrown Just like our JBoss Double quotes around parameters are the most likely cause of this problem

Solution

@ian_ Scho, hi!, I think the problem here is that the command line quotation marks are allowed because the process bash in Linux explains (this is the command line interpretation)... When using the processbuilder class in Java code, the quotation marks are interpreted as part of the path... Because the error "unable to access the jar file" is displayed You can use the command PS - ADF to view the process parent and try to run your command line (&) in the background, 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" &

And then invoke the command.

ps -adf

You will see that the bash process is the parent process... If you perform the same operation when JBoss is running, you can see that the parent process executed by process' Java is another process that cannot interpret quotation marks

I hope this will help you:)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>