Configuration for Glassfish v2
There are 3 main steps for enabling primrose to run within Glassfish.
Install jar file
Copy primrose.jar into your Glassfish Domain's lib directory (eg GLASSFISH_HOME/domains/YOUR_DOMAIN/lib/ext)
Configure your domain.xml to load primrose:
Underresourcestag 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.Make sure that the primroseConfigFile exists, and is configured correctly (see primroseConfig.html).<!-- 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> -
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 !Make sure that the logFile directory exists, and can be written to by tomcat.<!-- 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>
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.
-
Configure domain.xml to link the configured pools to your webapps:
At the end of domain.xml find theservertags, 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>


