GWT RPC not working behind Apache and Tomcat

656 views
Skip to first unread message

mukarev

unread,
Feb 25, 2012, 12:25:24 PM2/25/12
to Google Web Toolkit
Hi folks,

I'try to serve two gwt webapps via one apache from one tomcat with JK
and I'm always running in the same error. Apache sends a 404 and tells
me that it's not able to find the servlet if I try to communcate via
RPC.

I have two virtual hosts pointing at the directories within tomcat
webapps. The webapps are running successfully as long as I don't try
to communicate via RPC. It seems that Apache isn't able to resolve the
requested service.

Need help, I'm sitting here around hopeless.

Thanks!

Markus

Alan Chaney

unread,
Feb 25, 2012, 1:55:05 PM2/25/12
to google-we...@googlegroups.com
Hi Markus

Firstly, there is no reason why this should not work, but it can be
tricky to get such a system working.

Step 1:
Have you tried just talking directly to the tomcat? Typically the tomcat
will be running at port 8080, so you should try bypassing tomcat
entirely and accessing it there.

Step 2:

Look at the logs - what are you seeing? check tomcat logs, apache logs,
and the mod_jk logs.

Step 3:

Send us your web.xml, remote service servlet and mod_jk setup, otherwise
we can't help you.

HTH

Alan


>
> Thanks!
>
> Markus
>

Lukasz Plotnicki

unread,
Feb 26, 2012, 11:05:40 AM2/26/12
to google-we...@googlegroups.com
Hi,

our GWT App is running in this particular setting without any problems. Apache forwards anything with */OurApp to tomcat via AJP protocol (apache tomcat AJP connector).

Are you also using AJP or mod_rewrite?

Cheers,
Lukasz

mukarev

unread,
Feb 27, 2012, 12:45:54 PM2/27/12
to Google Web Toolkit
web.xml in web-inf from first app
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">

<!-- Servlets -->
<servlet>
<servlet-name>rpc</servlet-name>
<servlet-class>de.class.server.RPCServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>rpc</servlet-name>
<url-pattern>/app1/rpc</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Base.html</welcome-file>
</welcome-file-list>

</web-app>

web.xml from second app

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<filter>
<filter-name>Filter</filter-name>
<filter-class>com.app.server.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Servlets -->
<servlet>
<servlet-name>mail</servlet-name>
<servlet-class>com.app.server.MailServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>mail</servlet-name>
<url-pattern>/app2/mail</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>home.html</welcome-file>
</welcome-file-list>

</web-app>

the virtual host for first app

<VirtualHost *:80>

ServerName app1.de
ServerAlias www.app1.de
ServerAdmin ad...@domain.de

DocumentRoot /var/lib/tomcat6/webapps/app1

JkMount /app1.ro/* worker2

</VirtualHost>

virtual host for second app

<VirtualHost *:80>

ServerName app2.de
ServerAlias www.app2.de
ServerAdmin ad...@doamin.de

# DirectoryIndex index.php index.html index.htm index.shtml index.cgi
index.pl index.xhtml
DirectoryIndex app2.html
DocumentRoot /var/lib/tomcat6/webapps/app2

LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined

ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 503 /error/503.html

ScriptAlias /cgi-bin/ /home/admin/users/username/example.com/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
<Location /cgi-bin>
Options +ExecCGI
</Location>

<Directory /home/admin/users/username/example.com/public>
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<IfModule mod_jk.c>
JkMount /app tomcat6
JkMount /app/* tomcat6
</IfModule>

</VirtualHost>

I am new to deploy with mod_jk and serving tomcat via apache - so
please excuse the errors I made. Maybe you can help me a little.

here jk.conf:

<IfModule jk_module>

# We need a workers file exactly once
# and in the global server
# JkWorkersFile /etc/libapache2-mod-jk/workers.properties

# Our JK error log
# You can (and should) use rotatelogs here
JkLogFile /var/log/apache2/mod_jk.log

# Our JK log level (trace,debug,info,warn,error)
JkLogLevel info

# Our JK shared memory file
JkShmFile /var/log/apache2/jk-runtime-status

# Define a new log format you can use in any CustomLog in order
# to add mod_jk specific information to your access log.
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-
Agent}i\" \"%{Cookie}i\" \"%{Set-Cookie}o\" %{pid}P %{tid}P %
{JK_LB_FIRST_NAME}n %{JK_LB_LAST_NAME}n ACC %{JK_LB_LAST_ACCESSED}n
ERR %{JK_LB_LAST_ERRORS}n BSY %{JK_LB_LAST_BUSY}n %{JK_LB_LAST_STATE}n
%D" extended_jk

# This option will reject all requests, which contain an
# encoded percent sign (%25) or backslash (%5C) in the URL
# If you are sure, that your webapp doesn't use such
# URLs, enable the option to prevent double encoding attacks.
# Since: 1.2.24
# JkOptions +RejectUnsafeURI

# After setting JkStripSession to "On", mod_jk will
# strip all ";jsessionid=..." from request URLs it
# does *not* forward to a backend.
# This is useful, if all links in a webapp use
# URLencoded session IDs and parts of the static
# content should be delivered directly by Apache.
# Of course you can also do it with mod_rewrite.
# Since: 1.2.21
# JkStripSession On

# Start a separate thread for internal tasks like
# idle connection probing, connection pool resizing
# and load value decay.
# Run these tasks every JkWatchdogInterval seconds.
# Since: 1.2.27
JkWatchdogInterval 60

# Configure access to jk-status and jk-manager
# If you want to make this available in a virtual host,
# either move this block into the virtual host
# or copy it logically there by including "JkMountCopy On"
# in the virtual host.
# Add an appropriate authentication method here!
<Location /jk-status>
# Inside Location we can omit the URL in JkMount
JkMount jk-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<Location /jk-manager>
# Inside Location we can omit the URL in JkMount
JkMount jk-manager
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

# If you want to put all mounts into an external file
# that gets reloaded automatically after changes
# (with a default latency of 1 minute),
# you can define the name of the file here.
# JkMountFile conf/extra/uriworkermap.properties

# Example for Mounting a context to the worker "balancer"
# The URL syntax "a|b" instantiates two mounts at once,
# the first one is "a", the second one is "ab".
# JkMount /myapp|/* balancer

# Example for UnMounting requests for all workers
# using a simple URL pattern
# Since: 1.2.26
# JkUnMount /myapp/static/* *

# Example for UnMounting requests for a named worker
# JkUnMount /myapp/images/* balancer

# Example for UnMounting requests using regexps
# SetEnvIf REQUEST_URI "\.(htm|html|css|gif|jpg|js)$" no-jk

# Example for setting a reply timeout depending on the requets URL
# Since: 1.2.27
# SetEnvIf Request_URI "/transactions/" JK_REPLY_TIMEOUT=600000

# Example for disabling reply timeouts for certain request URLs
# Since: 1.2.27
# SetEnvIf Request_URI "/reports/" JK_REPLY_TIMEOUT=0

# IMPORTANT: Mounts and virtual hosts
# If you are using VirtualHost elements, you
# - can put mounts only used in some virtual host into its
VirtualHost element
# - can copy all global mounts to it using "JkMountCopy On" inside
the VirtualHost
# - can copy all global mounts to all virtual hosts by putting
# "JkMountCopy All" into the global server
# Since: 1.2.26

</IfModule>

mukarev

unread,
Feb 27, 2012, 12:47:38 PM2/27/12
to Google Web Toolkit
Hi!

Thanks for your reply.

We are using AJP. WIth one App in ROOT it is working fine - but for
two apps with two domains it doesn't work.

Thanks for your help.

Greetz,
Markus

On 26 Feb., 17:05, Lukasz Plotnicki <l.plotni...@googlemail.com>
wrote:
> Hi,
>
> our GWT App is running in this particular setting without any problems.
> Apache forwards anything with **/OurApp* to tomcat via *AJP* protocol

mukarev

unread,
Feb 29, 2012, 1:22:43 PM2/29/12
to Google Web Toolkit
Hi again,

a friend of mine solved the problem during the night. I will force him
to write the solution here.

Thanks for your thoughts.

Greetz Markus

yaron vazana

unread,
Oct 19, 2013, 9:43:52 AM10/19/13
to google-we...@googlegroups.com
Hi
Please provide an answer.
I have a GWT app on external tomcat 7 server.
All the regular servlets are fine, but i have a js error with the RPC servlet, saying it can't be found (404).
Is it mandatory to define the servlets also in the gwt.xml file, and the web xml


On Tuesday, July 17, 2012 10:53:28 PM UTC+3, Mads Ravn wrote:
From the lack of extra information, I gather you weren't successful in forcing your friend.

Thad Humphries

unread,
Oct 19, 2013, 7:58:13 PM10/19/13
to google-we...@googlegroups.com, muk...@googlemail.com
You servlet-mapping is

  <servlet-mapping> 
    <servlet-name>rpc</servlet-name> 
    <url-pattern>/app1/rpc</url-pattern> 
  </servlet-mapping> 

In your de.class.server.RPCService.java interface, do you have "app1" in the annotation? For example:

@RemoteServiceRelativePath("app1")
public interface RPCService extends RemoteService {...
Reply all
Reply to author
Forward
0 new messages