51Testing软件测试论坛

标题: lr执行java Vuser脚本的nullPointException [打印本页]

作者: cflong_a    时间: 2013-10-2 16:19
标题: lr执行java Vuser脚本的nullPointException
我用java写了一个远程调用的程序,通过socket方式访问远程服务器,以获取服务器的响应,在eclipse下编译通过也能正常访问远程服务器并能得到服务器的响应。
我把编译好的包含绝对路径的Class文件和第三方jar包放到虚拟用户的脚本目录下,用测试类测过这样的方式可以调用成功,再使用如下代码调用就出现nullpointexception:

import lrapi.lr;
//import d_20131001.*;
import org.engineClient.*;
public class Actions{
    public int init() throws Throwable {
        return 0;
    }//end of init
    public int action() throws Throwable {
        //HelloWorld.main((String[])null);
        Demo.main((String[])null);
        return 0;
    }//end of action
    public int end() throws Throwable {
        return 0;
    }//end of end
}

对应的java代码:
package org.engineClient;
import org.apache.log4j.Logger;
import org.hibernate.Transaction;
import com.amarsoft.core.object.ResultObject;
import com.amarsoft.socket.SocketObject;

15 public class Trade {
16    Logger logger = Logger.getLogger(Trade.class);
17    private static String sIP = "localhost";
18    private static int iPORT = 7000;
19    private static String sSAVEPATH = "";
20    private static boolean bUseSSL = false;
21    private static int sTIMEOUT = 180;
    ......
异常信息如下:
错误: System.err: java.lang.ExceptionInInitializerError
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at org.engineClient.Trade.<init>(Trade.java:16)
at org.engineClient.TradeTole.<init>(TradeTole.java:21)
at org.engineClient.Demo.main(Demo.java:5)  
at Actions.action(Actions.java:22)
错误: System.err: Caused by: java.lang.NullPointerException   
at sun.net.util.URLUtil.urlNoFragString(URLUtil.java:29)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:292)   
at sun.misc.URLClassPath.findResource(URLClassPath.java:145)
at java.net.URLClassLoader$2.run(URLClassLoader.java:385)   
at java.security.AccessController.doPrivileged(Native Method)  
at java.net.URLClassLoader.findResource(URLClassLoader.java:382)
at java.lang.ClassLoader.getResource(ClassLoader.java:1003)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1193)
at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:96)
at java.security.AccessController.doPrivileged(Native Method)   
at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:89)
at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:250)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:223)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:123)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:694)         
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)  
... 5 more
作者: lsekfe    时间: 2014-5-8 14:42
我用java写了一个远程调用的程序,通过socket方式访问远程服务器,以获取服务器的响应,在eclipse下编译通过 ...
cflong_a 发表于 2013-10-2 16:19



    LZ想问什么?




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2