权限被拒绝:设置classpath以运行testng.xml

时间:2017-07-27 15:33:30

标签: java selenium testing testng

朋友我正在尝试在我的Linux环境中运行testng.xml,遇到以下问题,我已经让root访问权限无法正常工作。

[root@ip-Ec2-serverwebsite ]# sudo java -version
openjdk version "1.8.0_131"

OpenJDK Runtime Environment (build 1.8.0_131-b11)

OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)


bash: allJarFiles/apache-mime4j-0.6.jar: Permission denied
[root@ip-Ec2-serverwebsite]# ls -ltr
total 230324
drwxrwxrwx 6 jenkins jenkins     4096 Jul 25 13:52 bin

drwxrwxrwx 2 jenkins jenkins     4096 Jul 25 13:52 utility

drwxrwxrwx 7 jenkins jenkins     4096 Jul 25 13:52 src

drwxrwxrwx 2 jenkins jenkins     4096 Jul 25 14:44 allJarFiles

-rw-r--r-- 1 jenkins jenkins     1178 Jul 25 14:44 testng.xml

-rw-r--r-- 1 jenkins jenkins      144 Jul 25 14:44 bash.sh

drwxrwxrwx 2 jenkins jenkins     4096 Jul 26 07:14 inputFiles

[root@ip-Ec2-serverwebsite ]# set classpath= /var/lib/jenkins/workspace/WebSite/bin;

[root@ip-Ec2-serverwebsite ]# set classpath= /var/lib/jenkins/workspace/allJarFiles/*;

[root@ip-Ec2-serverwebsite]# java org.testng.TestNG testng.xml
Error: Could not find or load main class org.testng.TestNG

[root@ip-Ec2-serverwebsite  ]# sudo java org.testng.TestNG testng.xml
Error: Could not find or load main class org.testng.TestNG

[root@ip-Ec2-serverwebsite  ]# set classpath=/var/lib/jenkins/workspace/allJarFiles/*;

[root@ip-Ec2-serverebsite ]# set classpath=/var/lib/jenkins/workspace/bin;

[root@ip-Ec2-serverwebsite ]# java org.testng.TestNG testng.xml

Error: Could not find or load main class org.testng.TestNG

[root@ip-Ec2-serverwebsite ]# set classpath=/var/lib/jenkins/workspace/bin;/var/lib/jenkins/workspace/allJarFiles/*;

bash: /var/lib/jenkins/workspace/allJarFiles/apache-mime4j-0.6.jar: Permission denied
[root@ip-Ec2-serverwebsite ]#

2 个答案:

答案 0 :(得分:1)

看起来您正在设置本地变量类路径,但您没有在java命令中指定它。

答案 1 :(得分:-1)

尝试授予apache-mime4j-0.6.jar和其他lib jar文件"执行"允许。