3

G' Day,

I have a requirement, where need to invoke java function in PHP script. I have been gone through PHP JAVA Bridge concept but not able to call from PHP script. May be my Process was wrong. Please find the below process what i have been implemented.

  1. step -1 C:\xampp\htdocs\tomcat\webapp Need to pest JavaBridge.war in this webapp.
  2. step - 2 Extract this (JavaBridge.war) file. then go to JavaBridge/WEB-INF/lib/ and copy below three files and pest into C:\xampp\htdocs\tomcat\webapp\bin

    php-script.jar php-servlet.jar servlet_api.jar

  3. Step -3 Edit the Tomcat conf/web.xml. Add the following 9 lines marked with a +:

        + <listener><listener-class>php.java.servlet.ContextLoaderListener</listener-class></listener>
        + <servlet><servlet-name>PhpJavaServlet</servlet-name><servlet-class>php.java.servlet.PhpJavaServlet</servlet-class>
        + </servlet>
        + <servlet><servlet-name>PhpCGIServlet</servlet-name><servlet-class>php.java.servlet.fastcgi.FastCGIServlet</servlet-class>
        + <init-param><param-name>prefer_system_php_exec</param-name><param-value>On</param-value></init-param>
        + <init-param><param-name>php_include_java</param-name><param-value>Off</param-value></init-param>
        + </servlet>
        + <servlet-mapping><servlet-name>PhpJavaServlet</servlet-name><url-pattern>*.phpjavabridge</url-pattern>
    

    + PhpCGIServlet*.php ...

  4. step - 4 Start Tomcat again. Now you can add PHP scripts to tomcat.

  5. step - 5 Add a PHP test file

    <?php require_once("java/Java.inc");
    echo java("java.lang.System")->getProperties(); ?> 
    

    to some web context, for example "examples", and browse to http://yourHost.com:8080/examples/test.php.

Its working fine but when i am run this file in htdocs (http://yourHost.com/test.php) its throwing exceptions.

Please suggest me if i have been implemented wrong process or let me know if any new interface will work through this problem.

I do appreciate for Adv help.

3
  • 1
    What are the exceptions? Commented Oct 10, 2013 at 5:34
  • Thank you @MattWilson I will get you soon Commented Oct 10, 2013 at 5:35
  • Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\test\testjava.php on line 2 Warning: require_once(localhost:8080/JavaBridge/java/Java.inc): failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\test\testjava.php on line 2 Fatal error: require_once(): Failed opening required 'localhost:8080/JavaBridge/java/Java.inc' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\test\testjava.php on line 2 Commented Oct 10, 2013 at 5:58

1 Answer 1

3

I think you need to set your php.ini to allow url includes. The docs.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I am working on that, once it will work fine let you know

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.