Configuration for Glassfish v2

   Glassfish website

There are 3 main steps for enabling primrose to run within Glassfish.

  1. Install jar file

    Copy primrose.jar into your Glassfish Domain's lib directory (eg GLASSFISH_HOME/domains/YOUR_DOMAIN/lib/ext)

  2. Configure your domain.xml to load primrose:

    Under resources tag in domain.xml, define a pool, and optionally web console. There are two sections to add :
    • Define a pool or two to be loaded

      Note that you only require a single primrose.config file, yet each pool must be configured in domain.xml in order for Glassfish to load them.
      
      
          <!-- Define a pool called 'examplePool' -->
          <custom-resource
          		enabled="true"
          		factory-class="uk.org.primrose.vendor.glassfish.PrimroseDataSourceFactory"
          		jndi-name="jdbc/hcr"
          		object-type="user"
          		res-type="javax.naming.spi.ObjectFactory">
      
            <!-- Define the pool name -->
            <property
            		name="poolName"
            		value="examplePool"/>
      
            <!-- Define where the primrose config file is -->
            <property
            		name="primroseConfigFile"
            		value="C:/java/primrose_3.0/primrose.config"/>
      
          </custom-resource>
      
          <!-- Define a pool called 'anotherPool' -->
          <custom-resource
          		enabled="true"
          		factory-class="uk.org.primrose.vendor.glassfish.PrimroseDataSourceFactory"
          		jndi-name="jdbc/hcr"
          		object-type="user"
          		res-type="javax.naming.spi.ObjectFactory">
      
            <!-- Define the pool name -->
            <property
            		name="poolName"
            		value="anotherPool"/>
      
            <!-- Define where the primrose config file is -->
            <property
            		name="primroseConfigFile"
            		value="C:/java/primrose_3.0/primrose.config"/>
      
          </custom-resource>
      
      				
      Make sure that the primroseConfigFile exists, and is configured correctly (see primroseConfig.html).

    • Define an webconsole to provide web access to all pools (optional)

      Note that I'm not sure how to get Glassfish to actually load the resource on startup. It seems to load it on demand (ie when you lookup the JNDI reference). Therefore if you want the webconsole to actually start, you will need to add some code in your app that looks up the JNDI reference you bound the webconsole custom-resource under, eg :
      new javax.naming.InitialContext().lookup("primrosewebconsole");
      If anyone knows how to load the resource on startup, then please get in contact !

      
          <!-- Define a webconsole to provide web access to all pools (optional) -->
          <custom-resource
          		enabled="true"
          		factory-class="uk.org.primrose.vendor.glassfish.WebConsoleFactory"
          		jndi-name="primrosewebconsole"
          		object-type="user"
          		res-type="javax.naming.spi.ObjectFactory">
      
            <!-- Define some properties required to start the web console -->
            <property
            		name="username"
            		value="admin"/>
            <property
            		name="password"
            		value="admin"/>
            <property
            		name="port"
            		value="8090"/>
            <property
            		name="logFile"
            		value="C:/java/primrose_3.0/webconsole.log"/>
            <property
            		name="logLevel"
            		value="verbose,info,warn,error,crisis"/>
      
      
          </custom-resource>
      				
      Make sure that the logFile directory exists, and can be written to by tomcat.
      Also make sure that the port is available.
      You may password protect the webconsole - if you not wish to, then just leave out the username and password elements.

  3. Configure domain.xml to link the configured pools to your webapps:

    At the end of domain.xml find the server tags, add the following tag :
          <resource-ref enabled="true" ref="jdbc/examplePool"/>
          <resource-ref enabled="true" ref="jdbc/anotherPool"/>
    				

    That section should look something like :
      <servers>
        <server config-ref="server-config" lb-weight="100" name="server">
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="adminapp" virtual-servers="__asadmin"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="admingui" virtual-servers="__asadmin"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="JBIFramework"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="WSTXServices"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="WSTCPConnectorLCModule"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="MEjbApp" virtual-servers="server"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="__ejb_container_timer_app" virtual-servers="server"/>
          <application-ref disable-timeout-in-minutes="30" enabled="true" lb-enabled="false" ref="__JWSappclients" virtual-servers="server"/>
          <resource-ref enabled="true" ref="jdbc/__TimerPool"/>
          <resource-ref enabled="true" ref="jdbc/__CallFlowPool"/>
          <resource-ref enabled="true" ref="jdbc/__default"/>
    				
          <resource-ref enabled="true" ref="jdbc/examplePool"/>
          <resource-ref enabled="true" ref="jdbc/anotherPool"/>
          <resource-ref enabled="true" ref="primrosewebconsole"/> <!-- Only required if you wish to define a Web Console -->
    				
        </server>
      </servers>
    				
Tomcat should now be configured successfully to run primrose.