PHP-Java桥中的java.lang.ClassNotFoundException [英] java.lang.ClassNotFoundException in PHP-Java bridge

查看:305
本文介绍了PHP-Java桥中的java.lang.ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP-Java Bridge.

I am working on PHP-Java Bridge.

我的php文件中的语法如下:

A syntax from my php file looks as follows:

require_once("java/Java.inc");
$address = new Java('com.odus.apg.cfa.java.address');

我已将包含 com/odus/apg/cfa/java/address.class 文件的文件cfa.jar放在 TOMCAT.HOME/webapps/JavaBridge/WEB-INF中/lib

I have placed the package file cfa.jar which consist com/odus/apg/cfa/java/address.class file in TOMCAT.HOME/webapps/JavaBridge/WEB-INF/lib

我的php文件位于 TOMCAT.HOME/webapps/JavaBridge

设置完成后,我会得到

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new com.odus.apg.cfa.java.address. Cause: java.lang.ClassNotFoundException: com.odus.apg.cfa.java.address VM: 1.7.0_40@http://java.oracle.com/" at: #-18 java.net.URLClassLoader$1.run(Unknown Source) #-17 java.net.URLClassLoader$1.run(Unknown Source) #-16 java.security.AccessController.doPrivileged(Native Method) #-15 java.net.URLClassLoader.findClass(Unknown Source) #-14 java.lang.ClassLoader.loadClass(Unknown Source) #-13 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) #-12 java.lang.ClassLoader.loadClass(Unknown Source) #-11 java.lang.Class.forName0(Native Method) #-10 java.lang.Class.forName(Unknown Source) #-9 php.java.bridge.Util.classForName(Util.java:1518) #-8 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445) #-7 php.java.bridge.Request.handleRequest(Request.java:458) #-6 php.java.bridge.Request.handleRequests(Request.java:500) #-5 php.java.bridge.JavaBridge.handleRequests(JavaBridge.java:150) #-4 php in /usr/share/apache-tomcat-7.0.55/webapps/JavaBridge/java/Java.inc on line 195

此设置是否正确? jar文件和php文件是否位于正确的目录中?该错误如何解决?

Is this set-up even correct? Are the jar files and php files located in correct directories? How can this error be resolved?

推荐答案

我有一个类似的问题,我认为您的php文件已正确编码.您需要做的是这样:

I had a similar problem, I think your php file is correctly coded. What you need to do is this :

sudo chown yourprofile:yourprofile -R TOMCAT.HOME/webapps/JavaBridge/WEB-INF/lib/cfa.jar

此命令后,先使用shutdown.sh然后使用startup.sh重新启动tomcat服务器 另外,使用sudo service apache2 restart

After this command restart your tomcat server using shutdown.sh and then startup.sh Also, restart the apache webserver using sudo service apache2 restart

确保php文件中的命令与jar文件中的类名完全相同,并且路径也正确.

Ensure that the command in the php file is actually exactly in the same case as per the class names in the jar file and path is also correct.

我同意鲍里斯的观点,即$address = new Java('com.odus.apg.cfa.java.address');实际上应该类似于$address = new Java('com.odus.apg.cfa.java.Address');

I agree with Boris that $address = new Java('com.odus.apg.cfa.java.address'); should actually be something like $address = new Java('com.odus.apg.cfa.java.Address');

有时候问题可能出在权限而不是路径,命名等上.

The problem can be sometimes with the permissions rather than the path, naming etc.

这篇关于PHP-Java桥中的java.lang.ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆