Home  >  Q&A  >  body text

java - linux执行jar访问axis接口错误

package test;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class TstCall {

public static void main(String[] args) throws ServiceException, RemoteException {
    //初始化参数
    String chgKind = "1"; // 1:增加;2:变更
    String workNo = "CY_yy" ;
    String workNAme = "白莉";
    String mobile = "15133333333";
    String dealerId = "920301832";
    String chgDate = "20160302";
    String YGZurl = null ;
    //创建服务
    Service YGZservice = new Service();
    //创建调用句柄
    Call YGZcall = (Call) YGZservice.createCall();
    //设置请求地址
    YGZcall.setTargetEndpointAddress(YGZurl);
    YGZcall.setOperationName(new QName(null, "IfService"));
    try 
    { 
        Object o =YGZcall.invoke(new Object[] { "","123","Service","",
                "<request><userlist><user><systemtype note=\"sour\">1</systemtype><kind note=\"chg\">"+chgKind+"</kind>"
                        +"<id note=\"num\">"+workNo+"</id><name note=\"numname\">"+workNAme+"</name><limit note=\"pp\">1</limit>"
                        +"<tel note=\"tel\">"+mobile+"</tel><belongfkid note=\"dealerID\">"+dealerId+"</belongfkid><starttime note=\"chgtime\">"+chgDate+"</starttime>"
                        +"</user></userlist></request>" });
    }catch(Exception e) { 
        e.printStackTrace();  
    }  
}

}

在window下执行都正常,但是在linux下执行报错:
执行语句:
java -jar -Djava.ext.dirs=/home/oracle/xf_everyday_check_p/javajar/lib/ test.jar
报错日志:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope...}Server.userException
faultSubcode:
faultString: java.lang.NullPointerException
faultActor:
faultNode:
faultDetail:

    {http://xml.apache.org/axis/}stackTrace:java.lang.NullPointerException
    at java.security.SecureRandom.nextBytes(SecureRandom.java:292)
    at org.apache.axis.utils.SessionUtils.generateSessionId(SessionUtils.java:62)
    at org.apache.axis.SOAPPart.&lt;init&gt;(SOAPPart.java:164)
    at org.apache.axis.Message.setup(Message.java:377)
    at org.apache.axis.Message.&lt;init&gt;(Message.java:246)
    at org.apache.axis.client.Call.invoke(Call.java:2425)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at test.TstLinux.main(TstLinux.java:56)

    {http://xml.apache.org/axis/}hostname:LN-CRM-APP

java.lang.NullPointerException

    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.client.Call.invoke(Call.java:1828)
    at test.TstLinux.main(TstLinux.java:56)

Caused by: java.lang.NullPointerException

    at java.security.SecureRandom.nextBytes(SecureRandom.java:292)
    at org.apache.axis.utils.SessionUtils.generateSessionId(SessionUtils.java:62)
    at org.apache.axis.SOAPPart.<init>(SOAPPart.java:164)
    at org.apache.axis.Message.setup(Message.java:377)
    at org.apache.axis.Message.<init>(Message.java:246)
    at org.apache.axis.client.Call.invoke(Call.java:2425)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    ... 1 more
PHP中文网PHP中文网2766 days ago394

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:40:46

    Since java.security.SecureRandom relies on /dev/random on Linux (see here for the Linux random number generation mechanism), run the test script after running the test program on the server in question. The results are as follows: #🎜🎜 #[java] view plain copy

    1. haitao-yao@haitaoyao-laptop:/data/develop/java/jre/lib/security$ jps && lsof /dev/random

    2. 7399 Jps

    3. 7382 TestRandom

    4. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

    5. java 7382 haitao-yao 4r CHR 1,8 0t0 4402 /dev/random

    So it is concluded that it is due to the random number generation strategy.

    Google found this bug of jetty (Jetty HashSessionIdManager hangs on startup). Some people have also raised this issue in the jdk bug database (see here). Here is a brief introduction:

    java.security.SecureRandom dependency Generating random numbers with /dev/random may cause jdk to freeze when using /dev/random due to insufficient system interrupt. Jetty cannot be started, eventually causing the entire namenode to freeze at startup.

    The solution has also been given in sun's bug database, which is to add: -Djava.security.egd=file:/dev/urandom to the java program startup parameters and use /dev/urandom to generate random numbers.

    Please see here for the difference analysis between /dev/random and /dev/urandom, no more details.

    Summary:

    hadoop provides html pages through the http protocol to expose the internal state of the system. This is a very good feature in the design of distributed systems, but due to the integration of jetty, the integrated jetty can be used in hadoop. The configurability is not strong, which exposed this problem. I really don’t understand why Hadoop doesn’t use a separate thread to start the internal jetty. After all, this is not the main function of the namenode, because such ancillary functions affect the core functions of the system, which is not worth the gain.

    reply
    0
  • Cancelreply