使用 Php-Java 桥

发布于 2024-10-25 02:11:52 字数 2691 浏览 1 评论 0原文

我在正确设置 Php-Java Bridge 设置时遇到问题。

我将解释我所做的事情。

  • 我的网站是纯 php 的
  • 对于我们的支付交易流程,我们需要设置一个 php-java 桥
  • 我按照此链接设置了桥 PHP-JAVA BRIDGE INSTALATION.
  • 这里我了解到我需要有一个私有jvm来安装桥。
  • 所以我首先使用我的 c-panel 在 Private JVM 中安装了 apache-tomcat-6.0.14。安装后,它要求我将域映射到私有 JVM。所以我将我的域 example.com (这是唯一可用的选项)映射到它。
  • 然后它要求启用从 Apache Web 服务器到我的 Java 应用程序服务器的流量重定向(有一个复选框,我单击了它)
  • 最后它要求我部署 WAR 文件(JavaBridge.WAR 是我的文件),
  • 现在 一切似乎都很好当我访问 http://example.com/JavaBridge/ 我可以看到 javabridge 示例并且它可以工作美好的。

目前为止还不错

现在,当我尝试从 php 访问 java 类文件时,我的问题就开始了。我创建了一个示例 test.php 并将以下代码放入其中。

  <?php
        require_once("http://example.com:portnumber/JavaBridge/java/Java.inc");
        $System = java("java.lang.System");
        echo $System->getProperties(); //This Part echo's correctly and shows the data so it means i can access Java.inc Correctly

        $path_e24class = getcwd(). '/e24PaymentPipe.class'; //This part fails both test.php and java class file e24PaymentPipe.class are in the same directory in publich_html folder
        java_require($path_e24class);
        $pipe = new Java("e24PaymentPipe");
        $pipe->setAction("1");
?>

我的网站内容位于 public_html 文件夹中,WAR 文件部署在私有 jvm 中。

这些是收到的错误消息。

  1) Warning: java_require() not supported anymore. Please use tomcat or jee hot deployment instead 
  Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new e24PaymentPipe. Cause: java.lang.ClassNotFoundException: e24PaymentPipe VM:  1.6.0_22@http://java.sun.com/" at: #-10 
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) #-9 
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) #-8 
 java.lang.Class.forName0(Native Method) #-7 
 java.lang.Class.forName(Class.java:247) #-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 
 http://example.com:portnumber/JavaBridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(3, 'java.util.Prope...', 'T', false) #1

最后我对java了解不多。所以我被困在这里不知道该怎么办。

I am having trouble setting up the Php-Java Bridge setup properly.

I will explain what I have done.

  • My site is in pure php
  • For our payment transaction process we need to set up a php-java bridge
  • I followed this link to setup the bridge PHP-JAVA BRIDGE INSTALATION.
  • Here I learned that I need to have a private jvm to install the bridge.
  • So 1st i installed apache-tomcat-6.0.14 in Private JVM using my c-panel. After instalation it asked me to Map a domain to private JVM. So I mapped my domain example.com (which is the only option available) to it.
  • Then it asked to enable a traffic redirection from Apache web server to my Java application server (there was a check box and i clicked it)
  • Finally it asked me to deploy the WAR File (JavaBridge.WAR was my file) and everthing seems fine
  • Now when i go to http://example.com/JavaBridge/ I could see the javabridge examples and it works fine.

SO FAR SO GOOD

Now my problem starts here when I try to access a java class file from php. A sample test.php is what I create and put the following code into it.

  <?php
        require_once("http://example.com:portnumber/JavaBridge/java/Java.inc");
        $System = java("java.lang.System");
        echo $System->getProperties(); //This Part echo's correctly and shows the data so it means i can access Java.inc Correctly

        $path_e24class = getcwd(). '/e24PaymentPipe.class'; //This part fails both test.php and java class file e24PaymentPipe.class are in the same directory in publich_html folder
        java_require($path_e24class);
        $pipe = new Java("e24PaymentPipe");
        $pipe->setAction("1");
?>

My site contents reside in the public_html folder and the WAR file are deployed in private jvm.

These are the error message am getting.

  1) Warning: java_require() not supported anymore. Please use tomcat or jee hot deployment instead 
  Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new e24PaymentPipe. Cause: java.lang.ClassNotFoundException: e24PaymentPipe VM:  1.6.0_22@http://java.sun.com/" at: #-10 
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) #-9 
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) #-8 
 java.lang.Class.forName0(Native Method) #-7 
 java.lang.Class.forName(Class.java:247) #-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 
 http://example.com:portnumber/JavaBridge/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(3, 'java.util.Prope...', 'T', false) #1

Finally I don't know much about the java. So am stuck here not knowing what to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

最美不过初阳 2024-11-01 02:11:52

这是一个很好的分步教程,您可以遵循,其中显示所需的一切!它有点旧(2007 年),但不久前对我有帮助。

还有另一种选择。您可以安装 Apache Tomcat 并在那里部署您的战争。只要您遵守端口设置,您甚至可以同时拥有多个 tomcat 实例,并在同一台计算机上同时运行 httpd。您甚至可以在它们前面使用 Apache httpd。

Here is a great step by step tutorial you can follow, which shows everything required! It is a little old (2007) but helped me a while ago.

There is also another option. You can install Apache Tomcat and deploy your war there. You can have even multiple tomcat instances simultaneously with your httpd running at the same time on the same machine, as long as you respect the port settings. You can even front them with Apache httpd.

岁月无声 2024-11-01 02:11:52

你可以试试这个:

  1. 将你的代码打包成jar,然后将其复制到java.ext.dirs,你可以在JavaBridge.log中找到它,
  2. 将相关的类库复制到java.ext.dirs,
  3. 重新启动JavaBridge服务,

祝你好运!

<?php require_once("JavaBridge/java/Java.inc"); 
     try {    
     $hd = new java("hdfs.HDFS");    
     $hd->get("hdfs://master:9000/user/hadoop/test-in/logo_cn.png", "/home/hadoop/1.png");
    } catch (JavaException $ex) {  echo "An exception occured: "; echo $ex; echo "<br>\n";}
?>

you can try this:

  1. package your code to jar, and copy it to java.ext.dirs which you can found in JavaBridge.log
  2. copy the related class libraries to java.ext.dirs
  3. restart the service of JavaBridge

good luck!

<?php require_once("JavaBridge/java/Java.inc"); 
     try {    
     $hd = new java("hdfs.HDFS");    
     $hd->get("hdfs://master:9000/user/hadoop/test-in/logo_cn.png", "/home/hadoop/1.png");
    } catch (JavaException $ex) {  echo "An exception occured: "; echo $ex; echo "<br>\n";}
?>
漆黑的白昼 2024-11-01 02:11:52

您可以使用这个github 上的 php 实现,它适用于 php 5.3。

有关详细信息,请参阅 git readme 上的积分。

You can use this php implementation on github that works with php 5.3.

See credits on the git readme for more information.

稀香 2024-11-01 02:11:52

你可以试试这个;将JavaBridge.jar放入tomcat的lib文件夹中,例如apache-tomcat-7.0.12/lib。

重新启动tomcat服务器,然后,

$pipe = new java("com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe");
$pipe->setAction("1");

这样我创建了该对象的php版本。

You can try this; put the JavaBridge.jar in tomcat's lib folder e.g. apache-tomcat-7.0.12/lib.

Restart tomcat server and then,

$pipe = new java("com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe");
$pipe->setAction("1");

This way I created the php version of the object.

缱绻入梦 2024-11-01 02:11:52

为什么不将 e24PaymentPipe 类放入 Java 应用程序的类路径中并跳过下面两行:

// $path_e24class = getcwd(). '/e24PaymentPipe.class';
// java_require($path_e24class);

$pipe = new java("fully.qualified.classpath.e24PaymentPipe");

您正在混合 PHP 端和 Java 端操作。理论上,java_require(已弃用)被设计为在 Java 端工作。您正在指定 PHP 侧路径。

Why don't you put the e24PaymentPipe class in your Java application's classpath and skip the two lines below:

// $path_e24class = getcwd(). '/e24PaymentPipe.class';
// java_require($path_e24class);

$pipe = new java("fully.qualified.classpath.e24PaymentPipe");

You are mixing PHP side and Java side operations. in theory the java_require (which is deprecated) was designed to work on the Java side. You are specifying a PHP side path.

梦巷 2024-11-01 02:11:52

通过使用 e24PaymentPipe 库的纯 PHP 实现,您可以省去很多麻烦。

免责声明

该链接指向我的库的 github 存储库,但不是我编写的。有关原始学分,请参阅自述文件。

You can save yourself a lot of grief by using a pure PHP implementation of the e24PaymentPipe library.

Disclaimer

The link is to my github repo of the library, but I did not write it. See the readme in for original credits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文