質問

I'm using PHP/Java bridge for the gain capital API which you can found here. But after connecting using PHP/Java bridge (It is connected properly and i tested that), I'm trying to use the API by creating an object for that and here is the code that i'm using in PHP,

    ini_set('display_errors',1);
    require_once("http://localhost:8080/jsp/java/Java.inc");

    $application    = java_context()->getServletContext();
    $configFile     = new java("java.util.Properties");
    $epaymentpipe   = new java("com.gain.rateservice.*");

But it throws the error as follows.

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new com.gain.rateservice.msg. Cause: java.lang.ClassNotFoundException: com.gain.rateservice.msg VM: 1.6.0_20@http://java.sun.com/" at: #-10 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438) #-9 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284) #-8 java.lang.Class.forName0(Native Method) #-7 java.lang.Class.forName(Class.java:264) #-6 php.java.bridge.Util.classForName(Util.java:1518) #-5 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445) #-4 php.java.bridge.Request.handleRequest(Request.java:458) #-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/jsp/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(4, 'java.util.Prope...', 'T', false) #1 http://localhost:8080/jsp/java/Java.inc(360): java_Ar in http://localhost:8080/jsp/java/Java.inc on line 195 

Since i don't know java, i could not able to fix this error. Any help on this would be greatly appreciated. Here is the screenshot of what i'm getting exactly.

enter image description here

役に立ちましたか?

解決

The error says that Java can't find the class 'com.gain.rateservice.msg'.

It should be included either by:

1) Including it in a classpath that you tell Java about when you run the instance.

2) Including it in the Jar/War you're building and passing to Java.

How to do either depends on exactly how you're invoking or building the Java side of things, but if you're running it from the command line it would be something like:

java -jar HelloWorld.jar -cp /path/to/GainRateserviceFolder/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top