|
我用java写了一个远程调用的程序,通过url携带参数的方式访问远程服务器,以获取服务器的响应,在eclipse下编译通过也能正常访问远程服务器了。我把编译好的包含绝对路径的Class文件放到虚拟用户目录下,有三个需要的第三方jar包,我也同样放到了虚拟用户的目录下了。使用如下代码进行调用。
import lrapi.lr;
import com.lt.test.*;
import com.lt.testauth.*;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
lr.rendezvous("申请任务!");
new AuthUtil().main((String[])null);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
可是为什么会报出空指针异常呢?异常信息如下:
Virtual User Script started
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Actions.
Rendezvous 申请任务!
Error: System.err: java.lang.ExceptionInInitializerError Error
System.err: at com.lt.testauth.AuthUtil.authtoken(AuthUtil.java:25) Error
System.err: at com.lt.testauth.AuthUtil.main(AuthUtil.java:78) Error
System.err: at Actions.action(Actions.java:21) Error
Error: System.err: Caused by: java.lang.NullPointerException Error
System.err: at sun.misc.URLClassPath$3.run(URLClassPath.java:323) Error
System.err: at java.security.AccessController.doPrivileged(Native Method) Error
System.err: at sun.misc.URLClassPath.getLoader(URLClassPath.java:320) Error
System.err: at sun.misc.URLClassPath.getLoader(URLClassPath.java:297) Error
System.err: at sun.misc.URLClassPath.findResource(URLClassPath.java:144) Error
System.err: at java.net.URLClassLoader$2.run(URLClassLoader.java:362) Error
System.err: at java.security.AccessController.doPrivileged(Native Method) Error
System.err: at java.net.URLClassLoader.findResource(URLClassLoader.java:359) Error
System.err: at java.lang.ClassLoader.getResource(ClassLoader.java:978) Error
System.err: at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1168) Error
System.err: at org.apache.commons.logging.LogFactory$3.run(LogFactory.java:597) Error
System.err: at java.security.AccessController.doPrivileged(Native Method) Error
System.err: at org.apache.commons.logging.LogFactory.getResourceAsStream(LogFactory.java:593) Error
System.err: at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:237) Error
System.err: at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351) Error
System.err: at org.apache.commons.httpclient.HttpMethodBase.<clinit>(HttpMethodBase.java:104) Error
System.err: ... 3 more Error
Error: java.lang.ExceptionInInitializerError
Error: at com.lt.testauth.AuthUtil.authtoken(AuthUtil.java:25)
at com.lt.testauth.AuthUtil.main(AuthUtil.java:78)
at Actions.action(Actions.java:21)
Caused by: java.lang.NullPointerException
at sun.misc.URLClassPath$3.run(URLClassPath.java:323)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:320)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:297)
at sun.misc.URLClassPath.findResource(URLClassPath.java:144)
at java.net.URLClassLoader$2.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findResource(URLClassLoader.java:359)
at java.lang.ClassLoader.getResource(ClassLoader.java:978)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1168)
at org.apache.commons.logging.LogFactory$3.run(LogFactory.java:597)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.commons.logging.LogFactory.getResourceAsStream(LogFactory.java:593)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:237)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.apache.commons.httpclient.HttpMethodBase.<clinit>(HttpMethodBase.java:104)
Abort was called from an action.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated. |
|