Monday, February 27, 2012

Re: GWT RPC not working behind Apache and Tomcat

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 admin@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 admin@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>
On 25 Feb., 19:55, Alan Chaney <a...@mechnicality.com> wrote:
> Hi Markus
> On 2/25/2012 9:25 AM, mukarev wrote:
>
> > 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.
>
> 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

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment