Tomcat – Apache + tomcat + jnlp

apache-2.2javamod-jktomcat

We have an instance of Tomcat behind an Apache. We use mod_jk.

The module config is:

LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
  JkWorkersFile conf/workers.properties
  JkLogFile     logs/mod_jk.log
  JkLogLevel    info
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
</IfModule>

And here the VirtualHost config:

<VirtualHost *:9090>
...
  JkMount  /Web/* worker-Web
  JkMount  /Web worker-Web
</VirtualHost>

The workers.properties file:

worker.list=worker-Web
worker.worker-omiapWeb.port=8209
worker.worker-omiapWeb.host=localhost
worker.worker-omiapWeb.type=ajp13

This config works great for jsp, html… but we have a JNLP file:

<?xml version="1.0" encoding="utf-8"?>
  <jnlp spec="1.0" codebase="$$codebase">
    <information>
      <title>Gestor Impresiones</title>
      <vendor>.</vendor>
    </information>
    <resources locale="es">
      <jar href="gestorImpresiones.jar"/>
      <jar href="jasperreports-1.2.5.jar"/>
      <jar href="commons-httpclient-3.1-beta1.jar"/>
      <jar href="commons-logging-1.1.jar"/>
      <jar href="commons-codec-1.3.jar"/>
      <jar href="commons-javaflow-20060411.jar"/>
      <jar href="commons-collections-3.1.jar"/>
      <jar href="poi-3.0.1-FINAL-20070705.jar"/>
      <jar href="jdic.jar"/>
    </resources>
    <resources os="Windows">
      <jar href="windows/jdic_stub.jar"/>
      <nativelib href="windows/jdic-native.jar"/>
    </resources>
    <resources os="Linux">
      <jar href="linux/jdic_stub.jar"/>
      <nativelib href="linux/jdic-native.jar"/>
    </resources>
    <resources locale="es">
      <j2se version="1.3+" href="http://java.sun.com/products/autodl/j2se"/>
    </resources>
    <security>
      <all-permissions/>
    </security>
    <application-desc main-class="stacks.printing.cliente.GestorImpresionLauncher"/>
  </jnlp>

The problem is that downloading the JNLP resources fails randomly (It fails more if the connection speed are poor).

If we access directly to Tomcat, everything works fine.

Any ideas?

Edited 1:

Apache log error:

[Thu Jul 01 09:51:45 2010] [868:5096] [info] jk_connect.c (566): connect to 127.0.0.1:8209 failed (errno=61)
[Thu Jul 01 09:51:45 2010] [868:5096] [info] jk_ajp_common.c (869): Failed opening socket to (127.0.0.1:8209) (errno=61)
[Thu Jul 01 09:51:45 2010] [868:5096] [error] jk_ajp_common.c (1359): (worker-omiapWeb) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=61)
[Thu Jul 01 09:51:45 2010] [868:5096] [info] jk_ajp_common.c (2186): (worker-omiapWeb) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Thu Jul 01 09:51:45 2010] [868:5096] [error] jk_ajp_common.c (2204): (worker-omiapWeb) Connecting to tomcat failed. Tomcat is probably not started or is listening on the wrong port
[Thu Jul 01 09:51:45 2010] [868:5096] [info] mod_jk.c (2364): Service error=-3 for worker=worker-omiapWeb

Edited 2:

server.xml AJP section:

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8209" 
       maxThreads="300" connectionTimeout="600000"
       enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

Best Answer

Why do you serve the JNLP application from tomcat? WebStart uses plain HTTP GET requests to acces the JNLP file and then the .jar files. You could place these outside of Tomcat, and let Apache do the work alone.