无法使用Java Bridge运行php应用

时间:2018-08-23 04:48:14

标签: java php jsp tomcat8

我的管理端有一个jsp应用程序,用户/客户端有一个php Web应用程序。我需要在tomcat 8上同时运行php和jsp应用程序。我尝试了在tomcat 8上无法正常工作的java bridge。可能是什么问题?我该如何解决?

我将JavaBridge.jar,php_java.jar,php-script.jar,php-servlet.jar上传到tomcatfolder / lib目录

在以下行中添加到tomcatfolder / conf / web.xml

<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>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>PhpCGIServlet</servlet-name>
    <url-pattern>*.php</url-pattern>
  </servlet-mapping>


    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
<welcome-file>index.php</welcome-file>
    </welcome-file-list>

例外

javax.servlet.ServletException: php.java.bridge.http.FCGIConnectException: Could not connect to server
    php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:133)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:748)
Root Cause

php.java.bridge.http.FCGIConnectException: Could not connect to server
    php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58)
    php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:748)
Root Cause

java.io.IOException: java.net.ConnectException: Connection refused (Connection refused)
    php.java.bridge.http.FCGIConnectException.<init>(FCGIConnectException.java:37)
    php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58)
    php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:748)
Root Cause

java.io.IOException: PHP not found. Please install php-cgi. PHP test command was: [php-cgi, -v] 
    php.java.bridge.Util$Process.start(Util.java:1145)
    php.java.servlet.fastcgi.FCGIProcess.start(FCGIProcess.java:68)
    php.java.bridge.http.SocketChannelFactory.doBind(SocketChannelFactory.java:125)
    php.java.bridge.http.FCGIConnectionFactory.runFcgi(FCGIConnectionFactory.java:88)
    php.java.bridge.http.FCGIConnectionFactory$1.run(FCGIConnectionFactory.java:109)

0 个答案:

没有答案