I have a Tomcat 7.0.57
cluster setup behind an Apache2
using mod_proxy
.
Setup:
Apache2: 192.168.2.139
Tomcat Node1: ajp://192.168.2.166:8010 (http connector also defined on port 8082)
Tomcat Node2: ajp://192.168.2.166:8011 (http connector also defined on port 8083)
I have a Java web application (using Jersey
, ExtJS
and some other goodies), which is deployed using Parallel Deployment
. Deployment works fine, and so does calling the application (using the Apache2 as the proxy, meaning http://http_proxy_ip/WebAppContext/app.html
). The ExtJS
front-end shows up fine.
WEB-INF/web.xml
of the application:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<distributable />
<servlet>
<servlet-name>FGJobServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.freightgate.quartz.servlet</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FGJobServlet</servlet-name>
<url-pattern>/scheduler/*</url-pattern>
</servlet-mapping>
</web-app>
mod_proxy.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/
ProxyRequests Off
ProxyPreserveHost On
<Proxy balancer://testcluster>
BalancerMember ajp://192.168.2.166:8010/ route=acd11-node01
BalancerMember ajp://192.168.2.166:8011/ route=acd11-node02
ProxySet lbmethod=byrequests
</Proxy>
# Excluding balancer-manager app to make it available on master
ProxyPass /balancer-manager !
ProxyPass / balancer://testcluster/ stickysession=JSESSIONID|jsessionid
ProxyPassReverse / balancer://testcluster/ stickysession=JSESSIONID|jsessionid
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
<Directory "/var/www/html">
AllowOverride AuthConfig
</Directory>
</VirtualHost>
proxy
definition within the ExtJS Model:
proxy : {
type : 'rest',
url : '/J_reportScheduler/scheduler/remotehost/scheduler',
noCache: false,
reader : {
type : 'json',
successProperty : 'success',
messageProperty : 'message',
},
writer : {
type : 'json',
}
}
Servlet definition in Java
:
@Path("/{system}")
public class FGJobServlet extends HttpServlet {
@POST
@Path("/scheduler")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createJSON(
JSONObject json,
@PathParam("system") String system,
@PathParam("cleanup") String cleanUp) {
// logic goes here
}
}
So, when the button gets clicked it fires a HTTP Post
sending a JSON object to the Java backend using the URL /J_reportScheduler/scheduler/remotehost/scheduler
.
When I run this locally from Eclipse, it just runs fine (and it comes back with the URL of the Tomcat instance). Running it in the Cluster gives me the following 404 Not found
and coming back with the URL from the HTTP server:
Remote Address:192.168.2.139:80
Request URL:http://192.168.2.139/J_reportScheduler/scheduler/remotehost/scheduler
Request Method:POST
Status Code:404 Not Found
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:193
Content-Type:application/json
Host:192.168.2.139
Origin:http://192.168.2.139
Referer:http://192.168.2.139/J_reportScheduler/app.html
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
X-Requested-With:XMLHttpRequest
Request Payloadview source
{jobname: "ui101", description: "awd", startdate: "2015-01-21T00:00:00",…}
Response Headersview source
Connection:Keep-Alive
Content-Length:0
Date:Wed, 14 Jan 2015 23:32:56 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.6 (CentOS)
Calling the application directly on one of the cluster nodes using the http connector
works fine as well. So, I assume this has something to do with my mod_proxy
setup.
I've been struggling around with this for 2 days now, and I can't seem to make it work. Any help is much appreciated!
EDIT#1: Yes, I have checked Apache and Tomcat logs, just Apache showing the 404. Application log doesn't show anything as well.
EDIT#2: Just in case it wasn't obvious: HTTP Get
requests work just fine.