Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
  1. Download latest ofbiz 9.04 release
  2. Unzip it under desired directory.
  3. Download Jboss 5.1.0.GA
  4. Unzip in desired directory
  5. Go to OFBiz directory. Now compile and build ofbiz with derby database using the following ant command: ant run-install. The command finishes by showing build successful message.
  6. Generate give the following ant command to generate the script for deploying Ofbiz in jboss: java -jar ofbiz.jar -setup jboss422

Note that in OFBiz the Jboss templates are included in the location:
OFBiz_HOME/framework/appserver/templates/jboss422

This is for Jboss 4.2.2 version. Minor modifications are required to deploy this in Jboss 5.1.0. The above command will generate the script files and place the directory named jboss422 under OFBIZ_HOME/setup

Go to OFBIZ_HOME/setup/jboss422

The following files are created under this directory

  • application.xml
  • build.xml
  • deploy.sh
  • run.conf

For Jboss 5.1.0

  1. Navigate to Jboss 5.1.0 home directory and go to server/default/deploy directory. Under this directory make a new directory and name it a ofbiz.ear
  1. Now copy application.xml and build.xml file from OFBIZ_HOME/setup/jboss422/ and paste it under JBOSS_HOME/server/default/deploy/ofbiz.ear
  2. Also copy entityengine.xml file from OFBIZ_HOME/framework/entity/config/ and put it in same location renaming it as entityengine-jboss422.xml
  3. Before deploying the application it is necessary to disable log4j settings as it will conflict with jboss settings. For this navigate to OFBIZ_HOME/framework/base/config/debug.properties file and set disable.log4j.config=true.
    If you are not setting this then after deployment you will get the following exception. Caused by: java.lang.NullPointerException at org.apache.log4j.xml.DOMConfigurator$2.toString
  4. Now navigate to JBOSS_HOME/server/default/deploy/ofbiz.ear directory and then run ant command
  5. The command will deploy all the necessary applications and jar files with derby datasource in the ofbiz.ear directory
  6. Now navigate to JBOSS_HOME/server/default/deploy/ofbiz.ear directory and you can able to see all the necessary war files deployed over there. Now copy derby-ds.xml and derby-ol-ds.xml file and paste it under JBOSS_HOME/server/default/deploy/
  7. Copy the derby directory from OFBiz_HOME/runtime/data and paste in under JBOSS_HOME/server/default/data
  8. Now navigate to OFBIZ_HOME/framework/entity/config/
    There are 2 files available now
  • entityengine.xml
  • entityengine-jboss422.xml

Swap and keep a backup as follows
Rename entityengine.xml to entityengine.xml.bak
Rename entityengine-jboss.xml to entityengine.xml
Now open entityengine.xml file and modify the content accordingly.
Here basically we are setting jndi datasource names and connection manager
Comment the geronimo transaction manager
<!-transaction-factory class="org.ofbiz.geronimo.GeronimoTransactionFactory"/->

Uncomment the following and modify it as given below

Code Block
<transaction-factory class="org.ofbiz.entity.transaction.JNDIFactory">
    <user-transaction-jndi jndi-server-name="default" jndi-name="UserTransaction"/>
    <transaction-manager-jndi jndi-server-name="default" jndi-name="java:/TransactionManager"/>
</transaction-factory>

Navigate down and find the tag <datasource name="localderby" and then comment the following

Code Block
<!--
<inline-jdbc
    jdbc-driver="org.apache.derby.jdbc.EmbeddedDriver"
    jdbc-uri="jdbc:derby:ofbiz;create=true"
    jdbc-username="ofbiz"
    jdbc-password="ofbiz"
    isolation-level="ReadCommitted"
    pool-minsize="2"
    pool-maxsize="250"/>
-->

Uncomment the below line and change the jndi-name according to the name in derby-ds.xml file
<jndi-jdbc jndi-server-name="default" jndi-name="java:/OFBizDS" isolation-level="ReadCommitted"/>

Navigate down and find the tag <datasource name="localderbyolap"
and then comment the following

Code Block
<!--
<inline-jdbc
    jdbc-driver="org.apache.derby.jdbc.EmbeddedDriver"
    jdbc-uri="jdbc:derby:ofbizolap;create=true"
    jdbc-username="ofbiz"
    jdbc-password="ofbiz"
    isolation-level="ReadCommitted"
    pool-minsize="2"
    pool-maxsize="250"/>
-->

Uncomment the below line and change the jndi-name according to the name in derby-ol-ds.xml file
<jndi-jdbc jndi-server-name="localjndi" jndi-name="java:/OFBizOlapDS" isolation-level="ReadCommitted"/>

Now all set to go. Start Jboss by navigating to JBOSS_HOME/bin/ directory with the following command: run.sh

Troubleshooting steps

If you get an exception like the one below

Code Block
Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: The content of element type "web-app" must match 
"(icon, display-name, description, distributable, context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config, mime-mapping*,welcome-file-list, 
error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config, 
security-role*,env-entry*,ejb-ref*,ejb-local-ref*)". 
@ vfsfile:/opt/jboss-5.1.0.GA/server/default/deploy/ofbiz.ear/webtools.war/WEB-INF/web.xml

JBOSS 5.1 version is strict in XML validation. It founds that the content of web.xml of webtools application is not valid.
Go to JBOSS_HOME/server/default/deploy/ofbiz.ear/webtools.war/WEB-INF/web.xml file and scroll down to the last few lines which starts with

Code Block
<context-param>
    <param-name>GeronimoMultiOfbizInstances</param-name>
    <param-value>true</param-value>
    <description>This is only used in case of Geronimo or WASCE using OFBiz multi-instances. It allows to retrieve ofbiz.home value set in JVM env</description>
</context-param>

Comment the above

Code Block
<!--context-param>
    <param-name>GeronimoMultiOfbizInstances</param-name>
    <param-value>true</param-value>
    <description>This is only used in case of Geronimo or WASCE using OFBiz multi-instances. It allows to retrieve ofbiz.home value set in JVM env</description>
</context-param-->

Now save the file and then restart the JBOSS server

If you get an exception like below

Code Block
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[]] (main) Exception starting filter ContextFilter
java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException

This Error is caused by a missing codec jar file in jboss to work with OFBiz: Google for commons-codec-x.jar file. Where x stands for version number.It is available with jboss 4.2.2 version. Copy the jar file and paste it under /JBOSS_HOME/server/default/deploy/ofbiz.ear/lib/. The exact file name will be commons-codec-1.3.jar

Now Restart jboss again and now fire a request in the browser to see OFBiz in action

Making SSL to work in Jboss

Navigate to JBOSS_HOME/server/default/deploy/jbossweb.sar/server.xml file and uncomment the SSL connector configuration settings and add keystore file path to it. Now you are done

Advantages in deploying OFBiz in JBoss AS

  1. Clustering in Jboss 5.1.0 is easier when compared to lower version of Jboss
  2. After deployment, we can create multiple nodes in jboss and cluster all the nodes to support more load
  3. Jboss can be easily load balanced with Apache making it to create more virtual host address
  4. We can tune maximum client settings for Apache and Jboss and JVM memory settings to improve the performance of Ofbiz
  5. We can also make busyiness based, request based load balancing using Mod_jk

This howto thanks to Vignesh Sabapathi