Deploying JBoss Drools BRMS on Weblogic
From Kb
Contact Article Author | Blog of Article Author | FirstPartners.net Home | LinkedIn profile of Author
Contents |
See Also
BRMS Setup | JBoss Drools BRMS on Weblogic | JBoss DSL | JBoss Rules Engine | Red Hat Developer Studio (RHDS - JBoss IDE)
JBoss and External Wiki Pages
Aim
Drools BRMS (Business Rules Management System) is a (GWT and Seam based) Web application that allows non-technical users to write and edit business rules in a Web environment. By default this is tested and deployed on JBoss Application server.
This tutorial shows how to deploy the BRMS on a non JBoss Server (BEA Weblogic) with a standard database - in this case we use MySQL, but could equally be Oracle or Micrsoft SQL Server.
Note that even after configuring BRMS to use an external database, some JCR application information (e.g. Search indexes) may still be present on the application server.
Instructions
Java Instructions
- Ensure you have Java 5 or higher installed on your machine
Weblogic Instructions
- Download BEA Weblogic (this tutorial uses 9.2 MP2 on Windows 2000) Server from : http://commerce.bea.com/showproduct.jsp?family=WLS&major=10&minor=0
- Install as standard using the Wizards.
- Create a new Domain (server instance) Using the BEA Weblogic Configuration Wizard - accept defaults
- Start Weblogic
- Open C:\bea9\user_projects\domains\base_domain in a DOS window
- run startWebLogic.cmd
- Weblogic console available at: http://localhost:7001/console
- username and password as set during installation (e.g. weblogic/weblogic)
- Weblogic Logs to Directory (Weblogic_Home)\user_projects\domains\base_domain\servers\AdminServer\logs
- We do not setup any connection pools etc as we will use JackRabbits config (later) to manage database connections.
BRMS Setup Instructions
- Get Stable or latest build of BRMS (war)
- Deploy to Weblogic
- Open console; deploy BRMS
- Open base_domain... deployments ... install
- or Ensure hotdeploy is setup as per http://www.firstpartners.net/kb/index.php/Weblogic#BEA_Weblogic_Hotdeploy
- Start application via Weblogic console
- Test via http://127.0.0.1:7001/drools-jbrms/.
- You should be able to see the following Screens. (By default, any username and password will log you in)
Drools BRMS Login Screen
Drools BRMS Package Screen
Default (Derby) Database Startup
By default , Drools BRMS bundles the Derby Database. You do not need a database setup step. If working, you should see the following entries in the log file the first time the appplication is run as Jackrabbit instantiates the required tables in the in the default in the Derby in process database.
<05-Oct-2007 19:05:34 o'clock IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
Setting up the repository, registering node types etc.
DEBUG 05-10 19:06:01,806 (JackrabbitRepositoryConfigurator.java:registerNodeTypesFromCndFile:127) Attempting to regsiter node type named: {http://www.jboss.
rg/drools-repository/1.0}categoryNodeType
DEBUG 05-10 19:06:01,927 (JackrabbitRepositoryConfigurator.java:registerNodeTypesFromCndFile:127) Attempting to regsiter node type named: {http://www.jboss.
rg/drools-repository/1.0}stateNodeType
DEBUG 05-10 19:06:01,967 (JackrabbitRepositoryConfigurator.java:registerNodeTypesFromCndFile:127) Attempting to regsiter node type named: {http://www.jboss.
rg/drools-repository/1.0}versionableNodeType
DEBUG 05-10 19:06:02,538 (JackrabbitRepositoryConfigurator.java:registerNodeTypesFromCndFile:127) Attempting to regsiter node type named: {http://www.jboss.
rg/drools-repository/1.0}versionableAssetFolder
DEBUG 05-10 19:06:02,568 (JackrabbitRepositoryConfigurator.java:registerNodeTypesFromCndFile:127) Attempting to regsiter node type named: {http://www.jboss.
rg/drools-repository/1.0}assetNodeType
DEBUG 05-10 19:06:02,738 (JackrabbitRepositoryConfigurator.java:registerNodeTypesFromCndFile:127) Attempting to regsiter node type named: {http://www.jboss.
rg/drools-repository/1.0}packageNodeType
DEBUG 05-10 19:06:02,848 (RulesRepository.java:addNodeIfNew:131) Adding new node of type: nt:folder named: drools:repository to parent node named
DEBUG 05-10 19:06:02,848 (RulesRepository.java:addNodeIfNew:131) Adding new node of type: nt:folder named: drools:package_area to parent node named dro
ls:repository
DEBUG 05-10 19:06:02,858 (RulesRepository.java:addNodeIfNew:131) Adding new node of type: nt:folder named: drools:packagesnapshot_area to parent node n
med drools:repository
DEBUG 05-10 19:06:02,858 (RulesRepository.java:addNodeIfNew:131) Adding new node of type: nt:folder named: drools:tag_area to parent node named drools:
epository
DEBUG 05-10 19:06:02,868 (RulesRepository.java:addNodeIfNew:131) Adding new node of type: nt:folder named: drools:state_area to parent node named drool
:repository
DEBUG 05-10 19:06:02,878 (RulesRepository.java:addNodeIfNew:131) Adding new node of type: drools:stateNodeType named: Draft to parent node named drools
state_area
<05-Oct-2007 19:06:05 o'clock IST> <Notice> <Log Management> <BEA-170027> <The server initialized the domain log broadcaster successfully. Log messages will no
be broadcasted to the domain log.>
<05-Oct-2007 19:06:05 o'clock IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
<05-Oct-2007 19:06:05 o'clock IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
<05-Oct-2007 19:06:06 o'clock IST> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 172.27.104.73:7001 for protocols iiop, t3, ldap, http.
<05-Oct-2007 19:06:06 o'clock IST> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, http.>
<05-Oct-2007 19:06:06 o'clock IST> <Notice> <WebLogicServer> <BEA-000331> <Started WebLogic Admin Server "AdminServer" for domain "base_domain" running in Deve
opment Mode>
<05-Oct-2007 19:06:06 o'clock IST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
<05-Oct-2007 19:06:06 o'clock IST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
Troubleshooting Errors in BRMS deployment
Proxy Errors
GWT may load the initial page, but then refuse to do anything else if your proxy settings are incorrect (it is making a lot of Ajax calls behind the scenes). Any problems at this stage, check your proxy settings on your browser, especially if you are running in a corporate environment. If you are running BEA Weblogic on your local machine, make sure that you do not use a proxy for the following addresses: localhost, 127.0.0.1
JSF Error
If you get the following java.lang.NoClassDefFoundError: javax/faces/context/FacesContext error on your server, it is likely that you do not have the correct version of JSF (Java Server Faces) installed.
<05-Oct-2007 18:55:03 oclock IST> <Warning> <HTTP> <BEA-101162>
<User defined listener org.jboss.seam.servlet.SeamListener failed:
java.lang.NoClassDefFoundError: javax/faces/context/FacesContext
at org.jboss.seam.util.Resources.getResourceAsStream(Resources.java:21)
at org.jboss.seam.init.Initialization.getReplacements(Initialization.java:140)
at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:126)
at org.jboss.seam.init.Initialization.<init>(Initialization.java:81)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
Truncated. see log file for complete stacktrace>
<05-Oct-2007 18:55:03 oclock IST> <Error> <Deployer> <BEA-149231>
<Unable to set the activation state to true for the application drools-jbrms.
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:891)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:333)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
Truncated. see log file for complete stacktrace
java.lang.NoClassDefFoundError: javax/faces/context/FacesContext
at org.jboss.seam.util.Resources.getResourceAsStream(Resources.java:21)
at org.jboss.seam.init.Initialization.getReplacements(Initialization.java:140)
at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:126)
at org.jboss.seam.init.Initialization.<init>(Initialization.java:81)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
Truncated. see log file for complete stacktrace
JSF Installation
Add the following jar files to to (weblogic_home)\user_projects\domains\base_domain\lib . Note that for other Tomcat based (non BEA) application servers these jar's may need to be copied to an endorsed directory on the server (so that they are 'trusted' by the server's security).
- MyFaces : http://myfaces.apache.org/download.html
- commons-beanutils-1.7.0.jar
- commons-codec-1.3.jar
- commons-collections-3.2.jar
- commons-digester-1.8.jar
- commons-discovery-0.4.jar
- commons-logging-1.1.jar
- myfaces-api-1.2.0.jar
- myfaces-impl-1.2.0.jar
- Download the JBoss App Server from http://labs.jboss.com/projects/download/ . Unzip and copy the following libs
- jstl.jar
- serializer.jar
- xalan.jar
- xercesImpl.jar
While not needed on BEA, you may need to remove any Jar files in your Server and-or the Drools/WEB-INF/lib application that clash with the files that you have just copied.
Database Setup - Oracle, MySql and Microsoft SQL Server
You may choose to use an alternative Database such as MySQL, Oracle or SQL Server (e.g. Corporate Standard, scalability, backups). Here we note how to setup BRMS and MySQL, but the steps will be similar for any JDBC compliant database.
These steps are not specific to Drools , but use the underlying Apache Jackrabbit JCR technology.
This example uses XAMP as Quick and easy way to setup MySQL with the (Web Based) PHPMyAdmin Tool. If you wanted , you could just install MySQL and use command line tools.
Install XAMP
Note that we are using XAMP for ease of use in the tutorial and that XAMP is not secure enough for a production environment.
- Download XAMP: http://www.apachefriends.org/en/xampp-windows.html#641
- Install (and choose to open XAMP Control panel)
- Optional Change port (as your Java Web Server might already be using the standard port 80 )
- Open C:\software\xampp\apache\conf\httpd.conf (or wherever you installed xamp)
- Find the line 'Listen 80' and replace with 'Listen 81' or port of your choice
- Restart Apache to pick up port change
- Open http://localhost:81/xampp/ - should see XAMP Screen Below
Configuring BRMS to use External DB
Add MySQL JDBC Drivers to Weblogic
- Download the MySQL JDBC Drivers
- Extract, find mysql-connector-java-5.0.7-bin.jar and place in (weblogic_home)\user_projects\domains\base_domain\lib
- You may also need to add the Drivers to the (deployed) app directory: e.g. C:\bea9\user_projects\domains\base_domain\servers\AdminServer\tmp\_WL_user\drools-jbrms_@4.0.1\ygcp9e\war\WEB-INF\lib
Create an Empty BRMS Database
- Create Database
- Open PhpMyAdmin http://localhost:81/phpmyadmin/
- Create the Database using the following steps : Databases ... enter db name (brms-db) ... create. You should get the message Database brms-db has been created.
- Using the priviliges tab on PHPMyAdmin, create a MySQL user with permissions to create tables in this database (we gave permissions for everything to the user brms_user in this example, which is very bad, so don't try this at home without a grown up). You probably want to remove alter tables permissions once JackRabbit has done it's stuff. Our password is brms_password
- For our example , the JDBC url (when MySQL is running on the same server as Weblogic) is : jdbc:mysql://127.0.0.1:3306/brms-db
- Tip 1: The next step needs the JDBC URL to this database. Oracle Raptor contains a tab to allow you to test if you have your JDBC URL correct. More information from the blog on how to do this
- Tip 2: Alternatively , use the Weblogic console to setup a MYSQL Connection. This is not needed for JackRabbit, but useful to test if you have your JDBC URL connection correct.
Configure BRMS to use MySQL database
More documation on configuring Java Content Repositories (Apache JackRabbit Site). We'll use the JDBC based SimpleDBPersistenceManager - to use Oracle or SQL Server instead, just change the JDBC URL in the config file below. Note that the JackRabbit Wiki has more specific Weblogic information e.g. if you want to use Weblogic to manage the database connections for you.
- Locate the repository.xml file. On BEA , it will be in a location similar to C:\bea9\user_projects\domains\base_domain Note that any changes we make here will be overwritten if we redeploy the drools-brms.war file , so keep a backup (like you always do !)
- Open the file in an XML / Text Editor.
- There will be two lines in the config file beginning with excerpt below - the first to configure the main datastore, the second to configure versioning.
<PersistenceManager class="org.apache.jackrabbit.core.persistence.db.DerbyPersistenceManager">
- Replace these two entries with config suitable for your database (samples below). Note the main difference betweent the two entries is the schemaObjectPrefix parameter
BRMS Objects DB Config
<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql:///brms-db"/> <param name="user" value="brms_user" /> <param name="password" value="brms_password" /> <param name="schema" value="mysql"/> <param name="schemaObjectPrefix" value="${wsp.name}_"/> <param name="externalBLOBs" value="false"/> </PersistenceManager>
BRMS Versions DB Config
<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql:///brms-db"/> <param name="user" value="brms_user" /> <param name="password" value="brms_password" /> <param name="schema" value="mysql"/> <param name="schemaObjectPrefix" value="version_"/> <param name="externalBLOBs" value="false"/> </PersistenceManager>
Populate BRMS Database
- Start BEA Weblogic as normal
- If everything goes correctly (no SQL Exception in Logs), you should be able to see the following tables have been automatically created (PhpMyAdmin view below)
- You should be able to use JBoss Drools BRMS as before
Other Configurations
(from Mike McMahon on Drools Mailing List)
WebLogic connection pooled
<PersistenceManager class="org.apache.jackrabbit.core.persistence.db.JNDIDatabasePersistenceManager"> <param name="dataSourceLocation" value="java:comp/env/jdbc/MyJndiPoolName"/> <param name="schema" value="mysql"/> <param name="schemaObjectPrefix" value="${ wsp.name <http://wsp.name>}_"/> <param name="externalBLOBs" value="false" /> </PersistenceManager>
Database instead of local filesystem storage
<FileSystem class="org.apache.jackrabbit.core.fs.db.JNDIDatabaseFileSystem"> <param name="dataSourceLocation" value="java:comp/env/jdbc/MyJndiPoolName"/> <param name="schema" value="mssql"/> <param name="schemaObjectPrefix" value="${ wsp.name <http://wsp.name>}"/> </FileSystem>
Two BRMS One Server
The BRMS contains functionality (packages) to allow you to segregate and manage your rules by business function. However , this may not be enough. For example, you want to have two completely different RuleBases edited by different sets of business users. This can be done by having two instances of the BRMS with two web and database servers. Or , for ease of admin, the two BRMS instances could share the Web and database servers (details below).
Two BRMS One Web server
- Stop the Web Server (e.g. JBoss, Tomcat , Weblogic etc)
- Deploy the First BRMS instance as normal
- Copy the Drools-Jbrms.war file and give it another name (e.g. Drools-JBRMS-2.war , or something more meaningful)
- Deploy the 2nd War file.
- Start the Web Server
- 1st BRMS should be available (e.g. on JBoss) at a URL like : http://localhost:8080/drools-jbrms/
- 2nd BRMS should be available (e.g. on JBoss) at a URL like : http://localhost:8080/drools-jbrms-2/
- By default, each of these BRMS will have their own Derby Database (unless you have followed this guide and used another DB instead).
Two BRMS one Database Server
Look for the sections BRMS Objects DB Config and BRMS Versions DB Config above
Modify the schemaObjectPrefix value to something suitable in both sections. These values should be different for each instance to the BRMS you setup in the previous step. It should be possible to run two completely separated instances of the BRMS using the same SQL-Server database , each with it's own set of tables, with the tablename prefixed by the value you give as schemaObjectPrefix.
You'd probably want to test this quickly for yourself. It should be fairly obvious that two separate sets of tables have been created, each with a distinct prefix to distinguish them.
More relevant ,information on:
- http://jackrabbit.apache.org/doc/config.html
- http://jackrabbit.apache.org/faq.html#pm-available
- http://jackrabbit.apache.org/api-1/org/apache/jackrabbit/core/state/db/SimpleDbPersistenceManager.html
See Also
BRMS Setup | JBoss Drools BRMS on Weblogic | JBoss DSL | JBoss Rules Engine | Red Hat Developer Studio (RHDS - JBoss IDE)





