title: access web container through Apache webserver Port 80 using mod_jk?
body: <p>I installed GlassFish 3.1.1 and set it up to work with Apache Webserver 2.2.x using mod_jk. Everything works great when using port 8080. For example, an <a href="http://docs.oracle.com/cd/E19798-01/821-1757/geyvr/index.html" rel="nofollow">example hello.war application</a> deployed on GlassFish runs fine from:</p>
  
  <pre><code>http://www.mydomain.com:8080/hello/
  </code></pre>
  
  <p>My question is, what do I need to change (or add) such that I can access the hello.war application using an address like this (and using port 80; so I can eventually close port 8080):</p>
  
  <pre><code>http://www.mydomain.com/hello/
  </code></pre>
  
  <p>The goal is to have all external traffic pass through Apache webserver port 80 to access GlassFish. Using <a href="http://www.codefactorycr.com/glassfish-behind-apache.html" rel="nofollow">this site's instructions</a> as inspiration, I modified httpd.conf to include the following lines (inside the pre-existing VirtualHost tags for www.mydomain.com)</p>
  
  <pre><code>JkMount /hello/* worker1
  JkMount /hello worker1
  </code></pre>
  
  <p>Then I restart Apache webserver and go to:</p>
  
  <pre><code>http://www.mydomain.com/hello
  </code></pre>
  
  <p>and the website hangs (spinning wheel for 30s). What could be the problem? There's no firewall between Apache and Glassfish, no loadbalance, and no clustering. It's a new CentOS 6.2 server with all fresh installs. </p>
  
  <p>For reference, my httpd.conf file includes the following (among other things):</p>
  
  <pre><code>LoadModule jk_module /etc/httpd/modules/mod_jk.so
  JkWorkersFile /etc/httpd/conf/workers.properties
  JkLogFile /etc/httpd/logs/mod_jk.log
  JkLogLevel debug
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
  JkRequestLogFormat "%w %V %T"
  ...
  Listen 0.0.0.0:80
  </code></pre>
  
  <p>and the glassfish-jk.properties file is:</p>
  
  <pre><code>worker.list=worker1
  worker.worker1.type=ajp13
  worker.worker1.host=localhost
  worker.worker1.port=8009
  </code></pre>
  
  <p>UPDATE: 2/11/2012 8:30pm I fixed the original problem posted above. The problem occurred because (1) there was a GlassFish bug (see Kevin's answer below for this discovery), and (2) I had somehow managed inadvertently to setup multiple http listeners that were listening to the same port 8009. When I deleted all of the listeners and then created the one listener I wanted, I was able to solve the original intent of this posting. However upon viewing the server.log, I see another problem...</p>
  
  <p>When I bring up the GlassFish server, I issue the following commands (note: port 4850 is simply an administration web-console provided by GlassFish; it needs to be there for some commands (not sure exactly which ones) but it doesn't seems to hurt anything by being there for all of them):</p>
  
  <pre><code># ./asadmin
  asadmin&gt; asadmin start-domain --port 4850
  asadmin&gt; deploy /path/to/file/hello.war --port 4850
  asadmin&gt; create-http-listener --listenerport 8009 --listeneraddress 0.0.0.0 --defaultvs server gf_listener --port 4850 
  asadmin&gt; create-network-listener --protocol http-listener-1 --listenerport 8009 --jkenabled true jk-connector --port 4850
  asadmin&gt; set server-config.network-config.network-listeners.network-listener.jk-connector.jk-configuration-file=/home/glassfish/glassfish3/glassfish/domains/domain1/config/glassfish-jk.properties --port 4850
  asadmin&gt; restart-domain --port 4850
  </code></pre>
  
  <p>The above commands are taken directly from the <a href="http://docs.oracle.com/cd/E18930_01/html/821-2416/" rel="nofollow">GlassFish Administration Guide</a> (click on PDF link, turn to page 150. This starts the section "To enable mod_jk", specifically see steps 5 and 6 on page 151). </p>
  
  <p>I've included a snippet from the GlassFish server log below showing one type of SEVERE error and a WARNING for max threads too low.</p>
  
  <pre><code>[#|2012-02-11T20:23:23.666-0800|INFO|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=14;_ThreadName=Thread-2;|Grizzly Framework 1.9.36 started in: 43ms - bound to [0.0.0.0:8080]|#]
  [#|2012-02-11T20:23:23.666-0800|INFO|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-2;|Grizzly Framework 1.9.36 started in: 6ms - bound to [0.0.0.0:3700]|#]
  [#|2012-02-11T20:23:23.666-0800|INFO|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=12;_ThreadName=Thread-2;|Grizzly Framework 1.9.36 started in: 24ms - bound to [0.0.0.0:4850]|#]
  [#|2012-02-11T20:23:23.668-0800|INFO|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=15;_ThreadName=Thread-2;|Grizzly Framework 1.9.36 started in: 2ms - bound to [0.0.0.0:7676]|#]
  [#|2012-02-11T20:23:23.691-0800|INFO|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.admin.adapter|_ThreadID=10;_ThreadName=Thread-2;|The Admin Console is already installed, but not yet loaded.|#]
  [#|2012-02-11T20:23:23.781-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]|#]
  [#|2012-02-11T20:23:23.788-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]|#]
  [#|2012-02-11T20:23:23.793-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0169: Created HTTP listener [admin-listener] on host/port [0.0.0.0:4850]|#]
  [#|2012-02-11T20:23:23.803-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0170: Apache mod_jk/jk2 attached to virtual-server [server]  listening on port [8,009]|#]
  [#|2012-02-11T20:23:23.806-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0170: Apache mod_jk/jk2 attached to virtual-server [server]  listening on port [8,009]|#]
  [#|2012-02-11T20:23:23.826-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0171: Created virtual server [server]|#]
  [#|2012-02-11T20:23:23.828-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0171: Created virtual server [__asadmin]|#]
  [#|2012-02-11T20:23:24.316-0800|INFO|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|WEB0172: Virtual server [server] loaded default web module []|#]
  [#|2012-02-11T20:23:24.416-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker.worker1 worker|#]
  [#|2012-02-11T20:23:24.416-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker.worker1 worker|#]
  [#|2012-02-11T20:23:24.416-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker worker|#]
  [#|2012-02-11T20:23:24.416-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker.worker1 worker|#]
  [#|2012-02-11T20:23:24.417-0800|INFO|glassfish3.1.1|org.apache.jk.common.ChannelSocket|_ThreadID=10;_ThreadName=Thread-2;|JK: ajp13 listening on /0.0.0.0:8009|#]
  [#|2012-02-11T20:23:24.426-0800|WARNING|glassfish3.1.1|org.apache.tomcat.util.threads.ThreadPool|_ThreadID=10;_ThreadName=Thread-2;|threadpool.max_threads_too_low|#]
  [#|2012-02-11T20:23:24.428-0800|INFO|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|Jk running ID=0 time=0/25  config=null|#]
  [#|2012-02-11T20:23:24.434-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker.worker1 worker|#]
  [#|2012-02-11T20:23:24.434-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker.worker1 worker|#]
  [#|2012-02-11T20:23:24.435-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker worker|#]
  [#|2012-02-11T20:23:24.435-0800|SEVERE|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|No class name for worker.worker1 worker|#]
  [#|2012-02-11T20:23:24.435-0800|INFO|glassfish3.1.1|org.apache.jk.common.ChannelSocket|_ThreadID=10;_ThreadName=Thread-2;|JK: ajp13 listening on /0.0.0.0:8009|#]
  [#|2012-02-11T20:23:24.436-0800|WARNING|glassfish3.1.1|org.apache.tomcat.util.threads.ThreadPool|_ThreadID=10;_ThreadName=Thread-2;|threadpool.max_threads_too_low|#]
  [#|2012-02-11T20:23:24.436-0800|INFO|glassfish3.1.1|org.apache.jk.server.JkMain|_ThreadID=10;_ThreadName=Thread-2;|Jk running ID=0 time=0/3  config=null|#]
  and so on...
  </code></pre>
  
  <p>Anyone know how to eliminate the SEVERE errors for <code>No class name for worker.worker1 worker</code>, and how to eliminate <code>threadpool.max_threads_too_low</code> WARNING?</p>
  
  <p>Which thread pool are they referring to? For example, when I type: asadmin> list-threadpools server, I get the following:</p>
  
  <pre><code>admin-thread-pool
  http-thread-pool
  thread-pool-1
  </code></pre>
  
  <p>I changed the http-thread-pool size from the default of 5 to a value of 200, then restarted GlassFish and looked at the server.log file and... nothing changes (still get same error message above). The max threads for admin-thread-pool is 50 and for thread-pool-1 is 200. Any ideas how to fix this?</p>