Mr.Stranger Mr.Stranger - 8 months ago 54
PHP Question

Error in Java/PHP bridge API

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,


$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@" at: #-10 org.apache.catalina.loader.WebappClassLoader.loadClass( #-9 org.apache.catalina.loader.WebappClassLoader.loadClass( #-8 java.lang.Class.forName0(Native Method) #-7 java.lang.Class.forName( #-6 #-5 #-4 #-3 #-2 #-1$ #0 http://localhost:8080/jsp/java/ java_ThrowExceptionProxyFactory->getProxy(4, 'java.util.Prope...', 'T', false) #1 http://localhost:8080/jsp/java/ java_Ar in http://localhost:8080/jsp/java/ 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

Answer Source

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/