From: <php...@li...> - 2014-08-04 11:36:25
|
I have done the tomcat settings and all the examples given in PhpJavaBridge are working fine.Now i want to add a class to this and call it from a php page something like this. Hello.java: public class Hello { public Hello(){}; public String hello(){ return "Hi This Is Suchit Kumar"; } } BridgeTest.php <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php require_once ("../JavaBridge/java/Java.inc"); $world = new Java("Hello"); echo java_values($world->hello()); echo "Hello Working Thingy\n\n"; ?> </body> </html> I have put my java file in some other directory and have run javac Hello.java then have created Jar file using jar cvmf MANIFEST.txt Hello.jar Hello.class Hello.java and then i have run the command java -jar Hello.jar Then i placed this jar file in the lib of /var/lib/tomcat7/webapps/JavaBridge/WEB-INF/lib/Hello.java Now when i am running the BridgeTest.php i am getting the following error. *type* Exception report *message* *description* *The server encountered an internal error () that prevented it from fulfilling this request.* *exception* javax.servlet.ServletException: java.lang.RuntimeException: PHP Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new Hello. Cause: java.lang.ClassNotFoundException: Hello VM: 1.6.0_31@http://java.sun.com/" at: #-10 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701) #-9 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546) #-8 java.lang.Class.forName0(Native Method) #-7 java.lang.Class.forName(Class.java:270) #-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 /var/lib/tomcat7/webapps/JavaBridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(1, NULL, 'T', false) #1 /var/lib/tomcat7/webapps/JavaBridge/java/Java.inc(360): java_Arg->getResult(false) #2 /var/lib/to in /var/lib/tomcat7/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) php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126) *root cause* java.lang.RuntimeException: PHP Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new Hello. Cause: java.lang.ClassNotFoundException: Hello VM: 1.6.0_31@http://java.sun.com/" at: #-10 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701) #-9 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546) #-8 java.lang.Class.forName0(Native Method) #-7 java.lang.Class.forName(Class.java:270) #-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 /var/lib/tomcat7/webapps/JavaBridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(1, NULL, 'T', false) #1 /var/lib/tomcat7/webapps/JavaBridge/java/Java.inc(360): java_Arg->getResult(false) #2 /var/lib/to in /var/lib/tomcat7/webapps/JavaBridge/java/Java.inc on line 195 php.java.servlet.fastcgi.FastCGIServlet.parseBody(FastCGIServlet.java:409) php.java.servlet.fastcgi.FastCGIServlet.execute(FastCGIServlet.java:433) php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:481) 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) php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126) It may be an easy one for others but to solve this i have tried a lot but unsuccessful in the end i am asking for some help.Please tell me where is the mistake or tell the steps considering that i am on ubuntu in tomcat7. Thank You. On Mon, Aug 4, 2014 at 4:06 PM, Suchit Kumar <su...@ge...> wrote: > > > -- > Thanks and Regards. > Suchit Kumar > -- Thanks and Regards. Suchit Kumar |