From: Kevin K. <zi...@gm...> - 2005-10-29 07:08:17
|
The servlet seems to be calling php on the commandline (CGI) instead of through Apache. That also seems to be failing, as requests return the file but no php processing. I'm running under Apache2 with both php and the mod_jk connector installed. My java applications function correctly, and I can see the test.php file if I use Apache directly. It indicates that Java is enabled. I've installed the JavaBridge war (opened it in Eclipse, actually), and added my php-cgi.exe and associated .dll files to the WEB-INF/cgi directory. I updated the web.xml to indicate that the file is called php-cgi.exe My requests to .php files seem to be serviced by the PhpJavaServlet, I can place debugging breakpoints there. The requests, being GET requests are serviced by the doGet method. However, I notice that the javadoc for this method believes that it will only be called in a CGI context. It then ultimately does the System.exec(..) CGI approach. I have this information in my php.ini, though it isn't clear to me how the PhpJavaServlet would know how to find it: [java] java.hosts=3D"127.0.0.1:8080" java.servlet=3D"/JavaBridge/PhpJavaServlet" Is there some configuration I need in my web.xml file to tell the Servlet how to connect back through the Apache service? I tried removing the *.php filter, but that didn't seem to change anything -- still got the file back with no processing. -Kevin |
From: Jost B. <jos...@ya...> - 2005-10-29 12:08:17
|
Hi Kevin, > The servlet seems to be calling php on the > commandline (CGI) instead > of through Apache. CGI is only used when the controller servlet (PhpJavaServlet) receives a get or post request. Usually apache listens on the http standard port :80 and php instances are allocated from the apache pool. The php instances in turn connect to the :8080 backend using put requests. mod_jk becomes obsolete if one doesn't have .jsp files anymore. [request to port 80:] > and I can see the > test.php file if I use Apache directly. It > indicates that Java is > enabled. Okay. [development setup] > I've installed the JavaBridge war (opened it in > Eclipse, actually), > and added my php-cgi.exe and associated .dll files > to the WEB-INF/cgi > directory. I updated the web.xml to indicate that > the file is called > php-cgi.exe Okay. [request to :8080] > My requests to .php files seem to be serviced by the > PhpJavaServlet, I > can place debugging breakpoints there. The > requests, being GET > requests are serviced by the doGet method. The doGet invokes the cgi machinery, yes. It is there to help during development, where it is difficult to work with two servers. For a production system, however, it is assumed that all requests go through the standard http port and that a native http server listens on this port. -- The reason is that java cannot drop privileges, so it is not possible to connect a java servlet engine to port 80. > Is there some configuration I need in my web.xml > file to tell the > Servlet how to connect back through the Apache > service? Just use http://localhost/JavaBridge/test.php instead of http://localhost:8080/JavaBridge/test.php Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Jost B. <jos...@ya...> - 2005-10-30 11:30:53
|
Hi again, > > Is there some configuration I need in my web.xml > > file to tell the > > Servlet how to connect back through the Apache > > service? I just noticed that you may want to include the php script, i.e. call out to php from a standard java class or servlet. I think you know about the req.redirect(...), which would redirect the request to the apache port. However, I am currently working on full jsr223 integration: The implementation allocates a php instance from the apache pool by opening a URLconnection passing it the current java continuation (a thread). The allocated php instance in turn connects back to the java continuation passing it the proxy allocated with java_closure(). The allocated script is stored in the javax.script.ScriptEngine when the user calls scriptEngine.eval(<phpScript>). He/she can call out to the php script by using the methods from javax.script.Invocable. I likely have misunderstood your question and the previous answer was sufficient. :) If not, a preview of PHP/Java Bridge version 3.0 will be available next week. Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Kevin K. <zi...@gm...> - 2005-10-31 20:30:15
|
I've configured the mod_jk differently, Apache is the "first handler" for all requests, passing requests in servlet mappings to Tomcat via the AJP connector. Tomcat no longer even runs an HTTP Connector.=20 This appears to be the preferred way to configure mod_jk with Apache2. Regardless of that, I'm confused about the request method. The request is a Get request, as defined by the browser makeing the request. Where and why would it be translated to a Put? I'm also confused about this: "For a production system, however, it is assumed that all requests go through the standard http port and that a native http server listens on this port. -- The reason is that java cannot drop privileges, so it is not possible to connect a java servlet engine to port 80." First: I don't want to run apache on port 80, surely this port isn't hardcoded anywhere? Second: What do you mean that "java cannot drop privileges"? It's quite possible to configure Tomcat to answer requests on port 80, although that's not what I want to do personally. I can't just use the default port--there's nothing running there.=20 Apache is running on port 8080, though, and it leads me to the problem I'm having. What component "should" be changing Get requests from the browser into Put requests for the server? Why is the servlet using CGI for Get? Get is just the method, and is a valid request type for these requests according to the HTTP spec. -Kevin On 10/29/05, Jost Boekemeier <jos...@ya...> wrote: > Hi Kevin, > > > The servlet seems to be calling php on the > > commandline (CGI) instead > > of through Apache. > > CGI is only used when the controller servlet > (PhpJavaServlet) receives a get or post request. > > Usually apache listens on the http standard port :80 > and php instances are allocated from the apache pool. > The php instances in turn connect to the :8080 backend > using put requests. mod_jk becomes obsolete if one > doesn't have .jsp files anymore. > > [request to port 80:] > > and I can see the > > test.php file if I use Apache directly. It > > indicates that Java is > > enabled. > > Okay. > > [development setup] > > I've installed the JavaBridge war (opened it in > > Eclipse, actually), > > and added my php-cgi.exe and associated .dll files > > to the WEB-INF/cgi > > directory. I updated the web.xml to indicate that > > the file is called > > php-cgi.exe > > Okay. > > > [request to :8080] > > My requests to .php files seem to be serviced by the > > PhpJavaServlet, I > > can place debugging breakpoints there. The > > requests, being GET > > requests are serviced by the doGet method. > > The doGet invokes the cgi machinery, yes. It is there > to help during development, where it is difficult to > work with two servers. > > For a production system, however, it is assumed that > all requests go through the standard http port and > that a native http server listens on this port. -- The > reason is that java cannot drop privileges, so it is > not possible to connect a java servlet engine to port > 80. > > > > Is there some configuration I need in my web.xml > > file to tell the > > Servlet how to connect back through the Apache > > service? > > Just use > > http://localhost/JavaBridge/test.php > > instead of > > http://localhost:8080/JavaBridge/test.php > > > Regards, > Jost Boekemeier > > > > > > > > > ___________________________________________________________ > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmeld= en: http://mail.yahoo.de > |
From: Jost B. <jos...@ya...> - 2005-11-01 17:45:01
|
Hi Kevin, > I've configured the mod_jk differently I think we can ignore mod_jk for this discussion, because it is not essential for the PHP/Java Bridge. -- Unless you forward everything to tomcat, which would render Apache, PHP and PHP/Java Bridge useless. > Regardless of that, I'm confused about the request > method. The > request is a Get request, as defined by the browser > makeing the > request. Where and why would it be translated to a > Put? It's an internal operation of the bridge. Essentially you have two pools, the HTTP/PHP pool (usually at :80) and the Tomcat (JavaThread) pool (usually at tcp port :8080). For each php instance request with java code in it, the bridge allocates an instance from each pool. The instances communicate using a cps style (they pass each other's continuation). To make this work, the two pools must be accessible to the bridge, of course. "Accessible" means that they must listen on TCP ports. (The bridge also supports unix domain sockets for the local backend, but this requires that you inject a JNI library called "natcJavaBridge.so" into the java VM). > First: I don't want to run apache on port 80, > surely this port isn't hardcoded anywhere? No, of course not. > Second: What do you mean that "java cannot drop > privileges"? Privilege dropping means that one part of the server runs with suid rights while other parts run with lower privileges. POSIX requires that, when a thread changes its uid, all other threads change their id, too. After that tomcat cannot accept connections on the privileged port 80 anymore. > quite possible to configure Tomcat to answer > requests on port 80, If one wants to expose /etc/passwd and /etc/shadow to everyone on the internet, yes... > Apache is running on port 8080, though, and it leads > me to the problem I'm having. So the apache pool listens on 8080 (I thought that's the tomcat pool). On which TCP port does tomcat listen? Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |