急!!php使用JavaBridge调用java方法问题
使用JavaBridge调用java,php可以调用java的方法了,但是我调用第三方包之后就报错,下面是错误信息。
Fatal error: Uncaught [[o:Exception]:"
java.lang.Exception: Invoke failed: [[o:Signature]]->sign((o:String)[o:String], (o:String)[o:String], (o:String)[o:String]). Cause:
java.lang.NullPointerException VM: 1.6.0_26@http://java.sun.com/" at: #-10 java.lang.String.<init>(Unknown Source) #-9 com.icbc.b2c.Signature.sign(Signature.java:42) #-8 sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) #-7 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) #-6 java.lang.reflect.Method.invoke(Unknown Source) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1044) #-4 php.java.bridge.Request.handleRequest(Request.java:417) #-3 php.java.bridge.Request.handleRequests(Request.java:500) #-2 php.java.bridge.http.ContextRunner.run(ContextRunner.java:145) #-1 php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:60) #0 http://localhost:8080/JavaBridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(2, 'com.icbc.b2c.Si...', 'T', true) #1 http://localhost:8080/JavaBridge/java/Java.inc(360): java_Arg->getR in http://localhost:8080/JavaBridge/java/Java.inc on line 195
下面是我的java包代码:
package com.icbc.b2c;
/**
* @author YaoDeZhi
*
*/
import cn.com.infosec.icbc.ReturnValue;
import java.io.*;
import java.lang.*;
public class Signature
{
private static ReturnValue rv = new ReturnValue();
/*
static{
Security.addProvider(new InfosecProvider());
}*/
/**
* Constructor for Signature.
*/
public Signature()
{
super();
}
public static String sign(String srcStr, String keyPath, String privatePasswd) throws Exception{
FileInputStream fileKey=null;
try{
byte[] byteSrc = srcStr.getBytes();
fileKey = new FileInputStream(keyPath);
//byte[] PriK = new byte[fileKey.available()-2];
//fileKey.skip(2);
byte[] PriK = new byte[fileKey.available()];
fileKey.read(PriK);
fileKey.close();
char[] keyPass = privatePasswd.toCharArray();
byte[] sign = rv.sign(byteSrc,byteSrc.length,PriK,keyPass);
byte[] tmpSign = rv.base64enc(sign);
return new String(tmpSign);
}catch(
IOException ex){
if(fileKey!=null)
fileKey.close();
throw ex;
}
}
php代码:
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
$a = new Java("com.icbc.b2c.Signature");
$b=$a->sign("APIName=B2B&APIVersion=001.001.001.001&Shop_code=0200EC10000019&MerchantURL=http://trans2.315.com.cn/account/Validate&Serial_no=HFK208&PayStatusZHCN=0&TranErrorCode=0&Tr