Rails and Tomcat

#1
I am using Litespeed Web Server 3.3.14. I am attempting to configure a virtual host to serve bothrails apps and jsp pages. I have setup a Rails context for the virtual host with a URI of "/" and a location of "$VH_ROOT/". This works well, and I can serve static pages under the public directory as well as rails applications defined under the app directory.

I am running Tomcat 6.0.18 on the same server and can access the Tomcat server with http://localhost:8080/. The example servlets and jsp examples that come with Tomcat work just fine.

I have had difficulty trying to access the Tomcat server through the Litespeed server. Under the virtual host I have have defined an External App of type "Servlet Engine" named "Tomcat 6" with address equal to "localhost:8009". I have also defined a Script Handler of type "Servlet Engine" for suffix "jsp" to be handled by "Tomcat 6".

I defined a Java Web App context for the "Tomcat 6" handler. The URI was set to "/examples/" and the Location was set to "/usr/local/tomcat/webapps/examples/". I am able to access the examples page from the web browser if I use the url "http://www.myhost.com/examples/index.html". However, if I try to access this index page by using the url "http://www.myhost.com/examples/", the Litespeed server responds with a 404 File Not Found error, and displays the "404.html" page from the Rails app's public directory.

When I try to access any of the JSP examples on the Tomcat server, Litespeed responds with a 403 Forbidden error.

When I attempt to access a JSP file, sample.jsp, located in the Rails public directory, the Litespeed server responds with a 403 Forbidden error.

I tried replacing the Java Web App context with a Servlet context. This context also used the "Tomcat 6" handler that I had defined. The URI was "/examples/". When I attempted to access the examples page (on the Tomcat server, via Litespeed) using the url "http://www.myhost.com/examples/index.html", the Litespeed server responded with a 403 Forbidden error.

So, here are my questions:

Are there any known problems between Litespeed and Tomcat 6.0.x?

Is it possible to set up a virtual host that uses both a Rails context and a Java Web App and or Servlet context? Can the Rails context be setup for URI "/", or is that what is causing some of the problems here?

How should one configure Litespeed using a Java Web App context so that index files are displayed when a directory uri is used?

What might be causing the 403 errors I am seeing? I checked file permissions, and the JSP files are set the same as the html files that are being served correctly.

I appreciate any assistance you can provide.
 

mistwang

LiteSpeed Staff
#2
looks like your servlet engine has not been configured properly, so LiteSpeed denies any request handled by it.
Please check lsws/logs/error.log for related errors, and turn debug logging should help.
For "http://www.myhost.com/examples/" return 404 problem, you need to add "index.html" as one of the directory index file.
 
#4
Under the General tab in the Virtual Hosts settings, the Index Files setting is set to "index.html". I also tried setting this under the Java Web App context. Still getting the 404 response whenever I leave off "index.html" from the end of the url.
 
#5
In lsws/logs/error.log, with debugging turned on, there are numerous lines including:

Failed to execute 'mpstat' command: No such file or directory
Failed to execute 'vmstat' command: No such file or directory

By the way, my server is a PowerMac G5 running Leopard, Mac OS X 10.5.4. The java runtime is standard edition, 1.5.0_13-119
 
#6
I set up a second virtual host, but did not configure a Rails context for it. I set up the same External App, Script Handler, and Java Web context configuration as the other virtual host. For this second host, the index.html file was returned when accessing the "/examples/" URI. So I think the problem in the first virtual host was a conflict between the Rails context and the Java Web App context.

This second virtual host setup still fails to handle the JSP and servlet examples in Tomcat. Still getting a 403 response when I try the HelloWorld servlet example. Note that this servlet runs fine when I access Tomcat directly with "http://localhost:8080/".
 

mistwang

LiteSpeed Staff
#7
The index.html problem is caused by the rewrite rules under the rails context.
add a rewrite rule

RewriteRule ^examples - [L]

should fix it.
 
#9
I reinstalled Tomcat 6 and JSPs worked again. When I compared this installation with the previous, I realized that I had modified Tomcat's server.xml file, adding this configuration:

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1,0:0:0:0:0:0:0:1%0,::1" />

This is applied to the Catalina engine, and allows only localhost access to the Tomcat server. This was interfering with communication between Litespeed and Tomcat. Once this valve setting was removed, I could access the example JSP and servlet pages on Tomcat through a Litespeed Java Web App context. It's better to limit access to the Tomcat server using the server's firewall.

I applied the rewrite rule for the Rails context that you provided me didn't work at first. That was because I had added it after other rewrite rules already there. Once I moved it to the top of the rules list, it worked great. Index files are now returned when the uri ends with a directory. I need to learn more about rewrite rules.

JSP files in the Rail's public directory are still not being executed. Tomcat returns a 404 File not found result. I guess I need to place any JSP files that need to be executed under Tomcat's webapp directory, and link to there through a Java Web App context, rather than put them with other files being served in the Rails context.

Thank you for all your help and quick response. Much appreciated.
 
Top