“无法访问jarfile”在linux土地上 [英] "Unable to access jarfile" in linux land

查看:734
本文介绍了“无法访问jarfile”在linux土地上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在JBoss 5下运行的Web应用程序,它定期启动一个'java'进程(使用ProcessBuilder)来编译Linux上的文件。该过程在Windows开发计算机和我们已安装的Ubuntu虚拟机上没有问题。命令如下:

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"

这会产生错误:

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

确认所有路径都是正确的,并且 jar文件路径被双重包围报价的。在两台啤酒和一台巨无霸之后,系统部门确认运行JBoss的用户( jbossadmin )也是该文件的所有者:

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!

编辑:Andrea Spadaccini提出的一个很好的建议,但似乎我们已经通过路径获得遍历权限:

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/ 

编辑:使用Eva,我们可以确认通过命令行(bash)执行该行是否正常但如果我们执行了该行,则会抛出错误来自ProcessBuilder的行ss,嵌入在jar文件中,在Linux中。就像我们的JBoss一样。参数周围的双引号是这里问题的最可能原因。

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嗨!,我认为问题这里是命令行引号是允许的,因为linux中的进程bash解释了(这是命令行解释)...当在java代码中使用ProcessBuilder类时,引号被解释为路径的一部分。 。显示错误无法访问jarfile。您可以使用命令 ps -adf 查看进程父级,尝试在后台运行您的命令行(&),如下所示:

@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" &

然后调用命令

ps -adf

您将看到bash进程是父进程。 ..如果你在jboss运行时也这样做,你可以看到java执行的进程'父进程是另一个无法解释引号的进程。

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希望这会对你有所帮助:)

I hope that this will help you :)

这篇关于“无法访问jarfile”在linux土地上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆