users@glassfish.java.net

Difficulty getting virtual server to work correctly

From: <glassfish_at_javadesktop.org>
Date: Mon, 22 Mar 2010 04:05:45 PDT

I'm having a fair amount of trouble getting virtual servers to behave correctly in Glassfish v3. Making matters worse, if I do the deployment via the admin console, I get errors (parameters are incorrect etc). I've ended up having to edit domain.xml myself and restart the server each time to test it.

I am trying to do the following (I've changed the actual domain names for the example):

- add a listener for port 80
- direct webapp.domain.ca -> webapp
- direct webapp.dev.domain.ca -> webapp_dev

I have the listener working correctly, a virtual server called prod directed to webapp working correctly but can't get the virtual server dev to work correctly - it always brings up the prod app (webapp).

Here's the relevant configuration.

I set up the listener on port 80:

      <network-config>
        <protocols>
          <protocol name="http-listener-1">
            <http default-virtual-server="server" max-connections="250" server-name="">
              <file-cache enabled="false" />
            </http>
          </protocol>
          <protocol security-enabled="true" name="http-listener-2">
            <http default-virtual-server="server" max-connections="250" server-name="">
              <file-cache enabled="false" />
            </http>
            <ssl ssl3-enabled="false" cert-nickname="s1as" />
          </protocol>
          <protocol name="admin-listener">
            <http default-virtual-server="__asadmin" max-connections="250" server-name="">
              <file-cache enabled="false" />
            </http>
          </protocol>
          <protocol name="http-listener-80-protocol">
            <http default-virtual-server="prod" />
          </protocol>
        </protocols>
        <network-listeners>
          <network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool" />
          <network-listener port="8181" protocol="http-listener-2" transport="tcp" name="http-listener-2" thread-pool="http-thread-pool" />
          <network-listener port="4848" protocol="admin-listener" transport="tcp" name="admin-listener" thread-pool="http-thread-pool" />
          <network-listener port="80" protocol="http-listener-80-protocol" transport="tcp" name="http-listener-80" thread-pool="http-thread-pool" />
        </network-listeners>
        <transports>
          <transport name="tcp" />
        </transports>
      </network-config>
      <thread-pools>
        <thread-pool name="http-thread-pool" />
        <thread-pool name="thread-pool-1" max-thread-pool-size="200" />
      </thread-pools>
    </config>
  </configs>

I added 2 virtual servers (prod and dev) each assigned to a particular host, both using port 80. I also assigned the default server for prod just in case they use a different host name to get to that webserver:

  <configs>
    <config name="server-config">
      <jruby-container jruby-home="C:\Program Files (x86)\jruby-1.4.0">
        <jruby-runtime-pool />
      </jruby-container>
      <http-service>
        <access-log />
        <virtual-server id="server" network-listeners="http-listener-1,http-listener-2" />
        <virtual-server id="__asadmin" network-listeners="admin-listener" />
        <virtual-server id="prod" log-file="${com.sun.aas.instanceRoot}/logs/prod.log" hosts="ecoenergy.domain.com" network-listeners="http-listener-80,http-listener-2,http-listener-1" />
        <virtual-server id="dev" log-file="${com.sun.aas.instanceRoot}/logs/dev.log" hosts="ecoenergy.domain.com" network-listeners="http-listener-80,http-listener-2,http-listener-1" />
      </http-service>

Here is the app deployment (JRuby/Rails):

  <applications>
    <application context-root="/" location="file:/D:/ecoEnergy/ecoenergyweb/" directory-deployed="true" name="ecoenergyweb" object-type="user">
      <property name="defaultAppName" value="ecoenergyweb" />
      <property name="jruby.rackEnv" value="production" />
      <property name="jruby.MTSafe" value="true" />
      <property name="jruby.home" value="C:\Program Files (x86)\jruby-1.4.0" />
      <property name="jruby.applicationType" value="rails" />
      <module name="ecoenergyweb">
        <engine sniffer="jruby" />
      </module>
    </application>
    <application context-root="/" location="file:/D:/ecoEnergy/test/ecoenergyweb/" directory-deployed="true" name="ecoenergyweb_dev" object-type="user">
      <property name="defaultAppName" value="ecoenergyweb_dev" />
      <property name="jruby.rackEnv" value="test" />
      <property name="jruby.MTSafe" value="true" />
      <property name="jruby.home" value="C:\Program Files (x86)\jruby-1.4.0" />
      <property name="jruby.applicationType" value="rails" />
      <module name="ecoenergyweb_dev">
        <engine sniffer="jruby" />
      </module>
    </application>
  </applications>

Finally, the application references to the virtual servers:

  <servers>
    <server name="server" config-ref="server-config">
      <application-ref ref="__admingui" virtual-servers="__asadmin" />
      <application-ref ref="ecoenergyweb" virtual-servers="prod, server" />
          <application-ref ref="ecoenergyweb_dev" virtual-servers="dev" />
      <resource-ref ref="jdbc/__TimerPool" />
      <resource-ref ref="jdbc/__default" />
      <resource-ref ref="jdbc/ee" />
      <resource-ref ref="jdbc/ee_login" />
    </server>
  </servers>
[Message sent by forum member 'wischr']

http://forums.java.net/jive/thread.jspa?messageID=393095