From: <php...@li...> - 2011-01-14 16:30:23
|
Hello, i dont know solversdk, so my infos may not be 100% correct. I think, if you want to instantiate a java class in php you will have to use the fully qualified class name like this: <?php require_once("http://localhost:8080/JavaBridge/java/Java.inc"); $problem = new Java("com.solver.Problem"); ?> This would instantiate the class Problem from the package com.solver. But of course i dont know if this is the correct package name, because i dont know solversdk. Maybe a stupid question: Do you know how to find out the package name of a java class? If you unpack the solversdk look for the file Problem.class. The package name would be the directories from the root of the jar contents to this file. In the above example it would look like this: <jar-root>/com/solver/Problem.class David On Fri, Jan 14, 2011 at 4:28 PM, < php...@li...> wrote: > Hi, > > Quick bit of support with running what I'm pretty sure is a correctly > installed Tomcat 7.0.5 and PHP-JavaBridge installation environment. I am > running on Mac OS X 10.6.6, using MAMP (PHP 5.3, Apache 2.0 on port 80 etc) > and have Tomcat 7.0.5 (port 8080) installed. I can run any php code > successfully, the Tomcat examples all run successfully and if I deploy > JavaBridge.war, copy the JavaBridge directory over to my local htdocs root > (as per installation instructions if you get the FASTCGI error) then I can > also run all the JavaBridge examples successfully. So a vanilla install is > looking good. I can run the following code php script from my htdocs local > root and it works fine as an example: > > <?php > require_once("http://localhost:8080/JavaBridge/java/Java.inc"); > $i1 = new Java("java.math.BigInteger", "1"); > $i2 = new Java("java.math.BigInteger", "2"); > $i3 = $i1->add($i2); > echo $i3->toString() . "\n"; > ?> > > So I now move onto wanting to instantiate classes from my own jar file > called SolverSDK.jar. As per the installation instructions, I grabbed a copy > of JavaBridge.war, exploded it, add in my jar file to the WEB-INF/lib > directory, re-create the war file using "jar -cvf JavaBridge.war *", > un-deploy the existing JavaBridge app in Tomcat, copy in my new one and > re-start Tomcat. The updated war file deploys fine and I can run the above > sample script again all ok. However, when I try to run the below simple > script: > > <?php > require_once("http://localhost:8080/JavaBridge/java/Java.inc"); > $problem = new Java("SolverPlatform.Problem"); > ?> > > I get the following error: > > Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance > failed: new SolverPlatform.Problem. Cause: java.lang.UnsatisfiedLinkError: > no SolverSDK in java.library.path VM: 1.6.0_22@http://www.apple.com/" at: > #-36 java.lang.ClassLoader.loadLibrary(ClassLoader.java:1754) #-35 > java.lang.Runtime.loadLibrary0(Runtime.java:823) #-34 > java.lang.System.loadLibrary(System.java:1045) #-33 > SolverPlatform.Problem.(Unknown Source) #-32 java.lang.Class.forName0(Native > Method) #-31 java.lang.Class.forName(Class.java:247) #-30 > php.java.bridge.Util.classForName(Util.java:1518) #-29 > php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445) #-28 > php.java.bridge.Request.handleRequest(Request.java:458) #-27 > php.java.bridge.Request.handleOneRequest(Request.java:510) #-26 > php.java.servlet.PhpJavaServlet.handleLocalConnection(PhpJavaServlet.java:202) > #-25 php.java.servlet.PhpJavaServlet.handlePut(PhpJavaServlet.java:250) #-24 > php.java.servlet.PhpJavaServlet.doPut(PhpJavaServlet.java:261) #-23 > javax.servlet.http.HttpServl in > http://localhost:8080/JavaBridge/java/Java.inc on line 195 > > A browser refresh then results in the good old ClassNotFound error due > since I would assume to the need for only one class-loader. > > The SolverSDK.jar file has the correct layout when exploded, i.e. > SolverPlatform directory and then all the classes etc. It relies on a file > called "libSolverSDK.dylib" which is also included within the updated war > file in the same directory. I have tried everything I can think of, > including forcing the classpath in the Tomcat config file, setenv.sh etc. I > have even ensured that DYLD_LIBRARY_PATH is set in a desperate attempt > though I know this should have no effect within Tomcat. I am pretty familiar > with Java and PHP but for the life of me, I can see no reason why I am > getting this simple error. I have, as per the video demo on the site, even > tried using the classes rather than the jar itself, in a newly created > directory WEB-INF/classes but again after redeploying, I get the same error. > > I have trawled through the mailing list archive and the web but not got > anywhere. Any help would be greatly appreciated. > > Regards, > > Marc > > The information contained in this E-mail is confidential. It is intended > only for the stated addressee(s) and access to it by any other person is > unauthorised. If you are not an addressee, you must not disclose, copy, > circulate or in any other way use or rely on the information contained in > this E-mail. Such unauthorised use may be unlawful. If you have received > this E-mail in error, please inform us immediately and delete it and all > copies from your system. > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |