cancel
Showing results for 
Search instead for 
Did you mean: 

How to deploy Explorer WAR in Glassfish 3 with Container Datasources

jim_doyle
Champ in-the-making
Champ in-the-making
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.
2 REPLIES 2

jim_doyle
Champ in-the-making
Champ in-the-making
Oops - In Step 4 - you are REMOVING this def of 'dataSource' and REPLACING it with a Spring JNDI lookup.  So, this is what goes away:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="defaultAutoCommit" value="false" />
  </bean>

As a matter of further discussion, you could make the Activiti deploys more portable across the container landscape by using exclusively JNDI lookups of the mail and datasource resources.   To keep it Tomcat friendly - you have the option of defining the resources either in
META-INF/context.xml  within the WAR,  or in $TOMCAT_HOME/conf/server.xml for Global Resources. See below for an example of using Context.xml tricks.

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" antiResourceLocking="true" path="/activiti-explorer" reloadable="true">
  <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" maxActive="2" maxIdle="3" maxWait="10000" name="jdbc/activiti-demo" password="activitipw" type="javax.sql.DataSource" url="jdbcSmiley Surprisedracle:thin:@192.168.11.2:1521/XE" username="activiti"/>
  <Resource auth="Container" mail.smtp.auth="true"
            mail.smtp.host="Your SMTP Provider, i.e. smtp.gmail.com"
            mail.smtp.port="465"
            mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
            mail.smtp.starttls.enable="true"
            mail.smtp.user="…. foobar at gmail.com ….. "
            name="mail/Session"
            password="….private password goes here…."
            type="javax.mail.Session"/>
</Context>

stepanovsu
Champ in-the-making
Champ in-the-making
jim_doyle:
thanks. it was very helpfull.
But i was try to  do that for weblogic 10.3.5. and had exception:
<pre>
Smiley Surprisedrg.springframework.beans.NotWritablePropertyException:Invalid property 'lazyInit' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'lazyInit' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
</pre>
Could you advice me anything?
Thanks