0

I use 'PHP 5.4 with Zend Server 6.1' Cartridges in OpenShift.
I need use java bridge.

index.php

<?php
java_require('./Test.jar');
$java = new java('com.lanyus.Test');
echo $java->Get();

Test.java

package com.lanyus;

public class Test {
    public static void main(String[] argv) {
        System.out.printf("Test");
    }

    public String Get() {
        return "Hello";
    }
}

Fatal error: Uncaught exception 'JavaException' with message 'Java Exception java.lang.ClassNotFoundException: com.lanyus.Test java.lang.ClassNotFoundException: com.lanyus.Test at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:195) ' in /var/lib/openshift/55dcc55f89f5cf3459000240/app-root/runtime/repo/php/test/index.php:9 Stack trace: #0 /var/lib/openshift/55dcc55f89f5cf3459000240/app-root/runtime/repo/php/test/index.php(9): No Class!->jbridge('com.lanyus.Test') #1 {main} thrown in /var/lib/openshift/55dcc55f89f5cf3459000240/app-root/runtime/repo/php/test/index.php on line 9

Thanks!

9
  • I'm not sure what you're asking here; the wording is a little unclear. It sounds like you're trying to figure out what's causing the error described by the stack trace. Have you made sure that the JAR is in the location specified by java_require? This looks like you just have the wrong path string. Commented Aug 27, 2015 at 15:15
  • index.php and Test.jar is in a directory Commented Aug 27, 2015 at 15:18
  • java_require('/var/lib/openshift/55dcc55f89f5cf3459000240/app-root/runtime/repo/php/test/Test.jar') is Fatal error,too. Commented Aug 27, 2015 at 15:20
  • I'm almost positive that this is an issue with the path to the jar. I think it's relative to some directory setting in Java Bridge by default, and using HTTP as a fallback. I just can't figure out where to find the default directory that java_require is relative to. Commented Aug 27, 2015 at 15:46
  • 1
    The php file is auto add ,but the jar file not is.Sorry. Commented Aug 27, 2015 at 16:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.