I have setup PHP/Java Bridge with working examples in netbeans tomcat directory.
What doesnt work is using custom JAR
Here is my code:
package com.micha;
public class Hello1Bean {
public Hello1Bean()
{}
String hi() {return "This is my hello message";}
String hello(String name) {return "Hello" + name;}
}
And the php code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
require_once ("java/Java.inc");
$world = new Java("com.micha.Hello1Bean");
echo java_values($world->hi());
echo "Hello Working Thingy\n\n";
?>
</body>
</html>
When I check http://localhost:8084/JavaBridge/mytest.php:
javax.servlet.ServletException: java.lang.RuntimeException: PHP Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[o:Hello1Bean]]->hi. Cause: java.lang.NoSuchMethodException: hi(). Candidates: [] VM: 1.6.0_25@http://java.sun.com/" at:
#-6 php.java.bridge.JavaBridge.checkM(JavaBridge.java:1085)
#-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1024)
#-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 C:\Users\Micha\.netbeans\7.1.2\apache-tomcat-7.0.22.0_base\webapps\JavaBridge\java\Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(2, 'com.micha.Hello...', 'T', true)
#1 C:\Users\Micha\.netbeans\7.1.2\apache-tomcat-7.0.22.0_base\webapps\JavaBridge\java\Java.inc(360): java_Arg->getResult(true)
#2 C:\Users\Micha\.netbeans\7.1.2\apache-tomcat-7.0.22.0_base\webapps\JavaBridge\java\Java.inc(366): java_Client->getWrappedResult(true)
#3 C:\Users\Micha\.netbean in C:\Users\Micha\.netbeans\7.1.2\apache-tomcat-7.0.22.0_base\webapps\JavaBridge\java\Java.inc on line 195
php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:499)
php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:521)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
Before I had a ClassNotFoundException so it knows there is a a class but for some odd reason I cant call the function. ( if I replace "com.micha.Hello1Bean" with some class
that doesnt exist then I get that exception)