java无法访问jarfile的错误,“无法访问jarfile”在linux土地上

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.

解决方案

@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 :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值