GWT Application gets “404 The requested resource is not available”.

256 views
Skip to first unread message

Ananchai Srirochanakul

unread,
Aug 26, 2017, 1:05:35 PM8/26/17
to GWT Users
Hi there.


I do not know why I keep getting "404 The requested resource is not available", when I am accessing my GWT Application. I am hosting my GWT application, on my TomEE/8.5.6 (7.0.2) at home, currently.

Here is the situation.

  1. I am able to use my GWT application from "TomEE Web Application Manager" as (http)://192.168.1.70:8080/Index

  2. However, when I type (http)://www.zethanath.tk in the browser, I would get (https)://www.zethanath.tk/ with HTTP Status 404.

Here is the details of my configuration.


Ubuntu:/opt/tomcat/webapps$ ls -l
total 20932
drwxrwxr-x 14 tomcat tomcat     4096 Aug  4 11:46 docs
drwxrwxr-x  5 tomcat tomcat     4096 Aug  4 11:46 host-manager
drwxrwxrwx  5 tomcat tomcat     4096 Aug 25 08:46 Index
-rwxrwxrwx  1 tomcat tomcat 21411520 Aug 25 08:46 Index.war
drwxrwxr-x  5 tomcat tomcat     4096 Aug  4 11:46 manager
drwxrwxr-x  3 tomcat tomcat     4096 Aug  8 17:30 ROOT

sudo nano 000-default.conf

<VirtualHost *:80 > Protocols h2 http/1.1 ServerAdmin erick9.hi5@gmail.com ServerName www.zethanath.tk ServerAlias servlet.zethanath.tk zethanath.tk DocumentRoot "/opt/tomcat/webapps/Index" ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined RewriteEngine on RewriteCond %{SERVER_NAME} =www.zethanath.tk RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

sudo nano default-ssl.conf

<IfModule mod_ssl.c> <VirtualHost _default_:443> Protocols h2 http/1.1 ServerAdmin erick9.hi5@gmail.com ServerName www.zethanath.tk ServerAlias servlet.zethanath.tk zethanath.tk DocumentRoot "/opt/tomcat/webapps/Index" JKMountCopy On JKMount /* ajp13_worker ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/zethanath.tk/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/zethanath.tk/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> </VirtualHost> </IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

I keep thinking that I need to associate port 8080 with "DocumentRoot "/opt/tomcat/webapps/Index", but I am unsure how.

Here is the details of my UFW. I have similar setup in the router.


sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Apache Full                ALLOW       Anywhere                  
20/tcp                     ALLOW       Anywhere                  
21/tcp                     ALLOW       Anywhere                  
990/tcp                    ALLOW       Anywhere                  
40000:50000/tcp            ALLOW       Anywhere                  
Apache Secure              ALLOW       Anywhere                  
8080                       ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Apache Full (v6)           ALLOW       Anywhere (v6)             
20/tcp (v6)                ALLOW       Anywhere (v6)             
21/tcp (v6)                ALLOW       Anywhere (v6)             
990/tcp (v6)               ALLOW       Anywhere (v6)             
40000:50000/tcp (v6)       ALLOW       Anywhere (v6)             
Apache Secure (v6)         ALLOW       Anywhere (v6)             
8080 (v6)                  ALLOW       Anywhere (v6) 

Help is greatly appreciated.


Jens

unread,
Aug 26, 2017, 3:08:31 PM8/26/17
to GWT Users
Looks like you want to use Apache + Tomcat. In that case you need to configure Apache as reverse proxy to your Tomcat. There are basically two variants:

1.) Your complete GWT app (GWT JavaScript, index.html, all server code) is inside your *.war file. In that case you would proxy any request to your domain to tomcat which usually runs on localhost:8080. So your virtual host in Apache would contain something like ProxyPass / http://localhost:8080/Index 

2.) You let Apache serve all the static files (GWT JavaScript, index.html) and tomcat only has the server code of your app in your *.war file. In that case your Apache virtual host would have a document root pointing to the folder of your GWT app and only requests to tomcat (server requests your app  makes using GWT-RPC, RequestBuilder, REST, whatever you use) would need to be proxied by Apache. So you might end up having more proxy configuration. This is more an optimization solution because you can now tune apache to serve static files and tune tomcat to deliver dynamic content.

You should google for Apache mod_proxy to find some more documentation on reverse proxying using Apache.

-- J.

Ananchai Srirochanakul

unread,
Aug 26, 2017, 6:41:02 PM8/26/17
to GWT Users
Hi Jen,

Thank you so much for your reply. However, I heard that mod_proxy is slower that Mod JK, so I made a switch just a little while ago :)

Here is what the users expect.

1.If the users type (http://)www.zethanath.tk in the browser, mod_rewrite, near the end of http vhost conf,
would redirect the user to (https://www.zethanath.tk). I am using mod_rewrite here.

<
VirtualHost *:80 >

...

RewriteEngine on RewriteCond %{SERVER_NAME} =www.zethanath.tk RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>
 
2. At this point, SSL vhost should use Mod JK to redirect the users to my GWT application on TomEE Server. My GWT application, in this case, is stored at /opt/tomcat/webapps/ with the name Index.war. but I do not know why I keep getting "404 The resource is not available".

<IfModule mod_ssl.c>
  <VirtualHost _default_:443
>
...
  
DocumentRoot
"/opt/tomcat/webapps/Index"

  JKMountCopy On
  JKMount /* ajp13_worker

  ...  

</VirtualHost> </IfModule>

I can see my GWT application working correct as http://192.168.1.70:8080/Index from Firefox, but I do not know why I got 404 error.
I allow 8080 on my firewall and router. I assigned 775 permission on Index.war, as well as the associated Index directory.

Maybe the statement here does not take port 8080 into consideration ? -> "DocumentRoot "/opt/tomcat/webapps/Index"
Maybe I should try get rid of this same line within http vhost config file?

Jens

unread,
Aug 28, 2017, 4:56:22 AM8/28/17
to GWT Users

Thank you so much for your reply. However, I heard that mod_proxy is slower that Mod JK, so I made a switch just a little while ago :)

Oh sorry, somehow missed you are using mod_jk. Never really used it but then I guess you are missing some configuration needed on your production system.

Maybe the statement here does not take port 8080 into consideration ? -> "DocumentRoot "/opt/tomcat/webapps/Index"
Maybe I should try get rid of this same line within http vhost config file?

I think you should have a workers.properties file which is used to tell apache / mod_jk how to access the worker you have named "ajp13_worker". It should have host and port config values. But I guess if these values would be wrong you would get a HTTP 5xx status code and not a 4xx one.

Maybe change mod_jk logging to debug to get more information.

-- J.

Ananchai Srirochanakul

unread,
Aug 28, 2017, 2:15:31 PM8/28/17
to GWT Users
Hi Jen,

I have done what you mentioned as well. Here is the content of /opt/tomcat/conf/server.xml 

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.tomee.catalina.ServerListener" />
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" xpoweredBy="false" server="Apache TomEE" />

   <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
   <Engine name="Catalina" defaultHost="localhost">
   <Realm className="org.apache.catalina.realm.LockOutRealm">
   <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
   </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

Here is the content of "/etc/libapache2-mod-jk/workers.properties".

workers.tomcat_home=/opt/tomcat
workers.java_home=/usr/lib/jvm/java-8-oracle/jre
ps=/
worker.list=ajp13_worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
worker.ajp13_worker.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=ajp13_worker

I found some article online mentioned that I need to create symbolic link for GWT application. I can't figure out if it is true or not, though. It said I need to add something like below to
SSL vhost configuration file.

DocumentRoot "/opt/tomcat/webapps/Index" Alias /Index "/opt/tomcat/webapps/Index" <Directory "/opt/tomcat/webapps/Index"> Options Indexes FollowSymLinks AllowOverride NONE Order allow,deny Allow from all </Directory> <Location "/Index/WEB-INF/"> AllowOverride None Deny from all </Location> JKMountCopy On JKMount /* ajp13_worker

Ananchai Srirochanakul

unread,
Sep 11, 2017, 9:23:39 PM9/11/17
to GWT Users
Help is greatly appreciated.

Thanks.
Reply all
Reply to author
Forward
0 new messages