AnsweredAssumed Answered

How to deploy Explorer WAR in Glassfish 3 with Container Datasources

Question asked by jim_doyle on Dec 26, 2013
Latest reply on Dec 29, 2013 by stepanovsu
If you need to deploy Explorer in an EE6 container using formal datasources here's how. It's very easy but will require some minor surgery on the WAR. I'll use Glassfish 3 as an example for you. If you're using Websphere or Weblogic - the steps are very similar BUT you will need to declare a vendor-specific deployment descriptor for your container.

1. In your EE6 Container Admin Console, define a new Connection Pool and a new JNDI Resource for that pool. Make sure you test your connection using the "Ping" features in your console to open the pool and force a database signon.  Note that I've installed a Global JNDI resource named 'jdbc/activiti-demo'.

2. Unpack the Activiti Explorer WAR in a CLEAN, new directory:

   bash$  mkdir explorer ; cd explorer ;  jar xf ../activity-explorer.war

3. Add a deployment descriptor for your container.  In my case, I added WEB-INF/glassfish-web.xml to the unpacked explorer files.  This deployment descriptor adds a <resource-ref> to the global JNDI resource jdbc/activity-demo that we installed in Step 1.  This allows the deployed web app to find the JDBC resource in the local JNDI namescape - so spring can find it.

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.or/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
   <resource-ref>
      <res-ref-name>jdbc/activiti-demo</res-ref-name>
      <jndi-name>jdbc/activiti-demo</jndi-name>
   </resource-ref>
</glassfish-web-app>

4. Edit WEB-INF/activiti-standalone-context.xml
     * REMOVE the <bean id="dataSource" ….>  definition.
     * REPLACE AND ADD the following:

     <jee:jndi-lookup id="dataSource" jndi-name="jdbc/activiti-demo" />
    <bean id="sqlExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
        <property name="dataSource" ref="dataSource"/>
    </bean>

5. Edit WEB-INF/classes/db.properties - remove the username and password entries, leaving behind the vendor selector, i.e.:
    db=oracle

6. Surgery done.  Pack up the modified WAR.  Make sure you do the packing while in the directory that holds WEB-INF, META-INF, lib, api, etc:

    bash$   jar cf ../activiti-explorer-gf.war .
7. Deploy activiti-explorer-gf.war in the admin console.

Outcomes