Thursday, 24 December 2015

Setting up DROOLS workbench 6.2 on Weblogc 12c

Steps:

  1. Install Weblogic 12c version 12.1.3.0. JDK 1.8. Set up DROOLS groups.
  2. Set up a Git local respository
  3. Modify the workbench war archive
  4. Create a datasource
  5. Maven repository
  6. JVM options

1.Install Weblogic 12c version 12.1.3.0. Set up DROOLS groups.

Download Weblogic 12.1.3.0 at:

http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html

Install (see fig 1):

- Admin Server on port:7001
- Managed Server (on which the Drools Workbench will be installed) on port: 7003



Figure 1

Create two groups. Apparently Drools workbench relies on these two groups. Myream is the default Weblogic realm. Attach the groups to this realm.
Steps:
  1. Go to Domain-> Security realms-> myrealm.)
  2. Go to Tab "Users and Groups"
  3. Go to sub tab "Groups"
  4. Create groups
    •   admin
    •   analyst
  5. Create user "kieuser" and assign the two groups to it (fig. 2)

Figure 2


2. Set up a git local respository
Just a few points to make on git. Git is a version control system different in working than SVN.
Basically repositories are copied locally, what is called cloning. When changes are made, a user will commit his changes, however as opposed to SVN, commit does not communicate or persist changes to a remote git server, but moves changes to the HEAD, hence changes are still locally saved. A push operation will persist files to the remote server . A pull operation will update the local repository.

The Drools workbench features a builtin git server. Unfortunately, when deployed on Weblogic the embedded git server does not work. As a workaround we need to :
  • to create our local repository without having a git server:
    Reinit your git repo to enable sharing (man page)
    cd /myRepoDirectory
    git init --shared=yes
  • tell the workbench that the server is off and instead lead it to the git path. Make sure you specify the same path of git repository just created

    set JAVA_OPTIONS=-Djavax.xml.bind.context.factory=com.sun.xml.bind.v2.ContextFactory -Dorg.uberfire.start.method=ejb -Dorg.uberfire.domain=OracleDefaultLoginConfiguration -Dorg.kie.demo=false -Dorg.uberfire.nio.git.ssh.enabled=false -Dorg.uberfire.nio.git.daemon.enabled=false -Dorg.uberfire.nio.git.dir=/myRepoDirectory



3. Modify the workbench war archive
The workbench archive is available at this link:

http://www.drools.org/download/download.html

Application must be deployed as as folder to allow complete feature set to be activated. We have unpacked the war into a directory named droolsWB, hence the web app context will be also droolsWB
When unpacking the war, Windows will complain that your file system does accept such long file names as there is one class in the archive that is too long.

To resolve this, we are going to delete the long named class and add to our classpath a jar containing the same class. Steps:
  • open your archive explorer into the kie-drools-wb-distribution-wars-6.2.0.Final-weblogic12.war and delete de following file:
    org\jboss\errai\marshalling\server\impl\ServerMarshallingFactoryImpl$Marshaller_for_org_drools_workbench_models_guided_dtable_shared_model_adaptors_ActionInsertFactCol52ActionInsertLogicalFactAdaptorImpl.class
    The class is located under \WEB-INF\classes
  • As a workaround, we have packaged the long file in a jar. Add kie-drools-wb-distribution-wars-6.2.0.Final-weblogic12.jar  to your web app lib classpath. The jar is already read and can be downloaded here

4. Create a datasource


The workbench requires a datasource configuration. To allow easy setup, we have chosen a h2 in memory database. To download the jdbc driver, go to :

http://www.h2database.com/html/download.html

Make sure you download jar h2-1.4.190.jar

Add the jar under your Weblogic domain classpath at Your Domain\llib


Next we will setup jbpm datasource required by the workbench:
Make sure, you specify the jndi name as: jdbc/jbpm

  • Go to domain->Services->Data sources->New
  • set the following properties :
    • name :jbpm
    • jndi : jdbc/jbpm
    • Database Type: other
  • Press next
  • Leave Supports Global Transactions checked
  • Select radio button Emulate Two-Phase Commit
  • Enter database user properties
    • user :sa
    • password  : leave blank

  • Press next
  • Fill in driver properties (see figure 3):
    • Driver Class Name: jdbc:h2:mem:test
    • URL : org.h2.Driver

figure 3





5. Maven repository

The workbench will create a directory under your Weblogic domain file system in which it will puish the Maven artifacts. By default the respository will be placed under : \domain\repositories\kie\

If the intention is to change that directory, in managed server launch bat file, add the following JVM system property :

-Dorg.guvnor.m2repo.dir=Path to your Maven repository


6. JVM options 
In your managed launch server bat file add the following line:
set USER_MEM_ARGS=-Xms512m -Xmx1024m -XX:MaxPermSize=512m
Launch the managed server.
The context will appear under droolsWB (figure 4)
http://localhost:7003/droolsWB



Tuesday, 8 December 2015

Embed your ActiveMQ broker within your Wildfly (JBoss) JVM

This post is intended for ActiveMQ 5.11 and WildFly (JBoss) 8.2

It is possible to launch the JMS broker inside the JVM of Wildfly so no need to set up a different ActiveMQ server.



All I did is just change the transport protocol inside standalone.xml



From
                        tcp://localhost:61616?jms.rmIdFromConnectionId=true

                   

To :

                 
                      vm://localhost?broker.persistent=false

                   

It is important to set the persistence to false as to avoid persistence configuration. In addtion, one can also set the ActiveMQ configuration file with the parameter brokerConfig=xbean:activemq.xml
Monitoring the JMS queues



Now that the ActiveMQ console is down you probably wonder how can you check the queues. You can do it by connection to JMX environment of the Wildfly JVM.

You have two options :

    Use the ActiveMQ web console
    Use JConsole


1. Use the ActiveMQ web console


To enable  the ActiveMQ console in Wildfly, just two steps are needed:

    Set the JVM system parameters in standalone.xml to inform the ActiveMQ console application to connect through JMX. Add the following JVM system parameters under the extensions tag:

    <server name="xyz.home" xmlns="urn:jboss:domain...">
    <extensions>
   
    </extensions>
 
   <system-properties>
        
        <property name="webconsole.type" value="properties"/>
        <property name="webconsole.jms.url" value="vm://localhost"/>
        <property name="webconsole.jmx.url" value="service:jmx:http-remoting-jmx://localhost:9990"/>
       
     </system-properties>
     

       
   
           
           
           
       




    Deploy the ActiveMQ console war.  This war contains the jboss-client.jar (under /lib). You can download it here

Make sure you delete the line specifying kaha db persistence from webconsole-embedded.xml

In activemq.xml, change the broker name to (so your console and wildfly point to the same object) :

  <broker brokerName="localhost" useJmx="true" xmlns="http://activemq.apache.org/schema/core">


     The ActiveMQ should be running under this WildFly context
               

      http://localhost:8080/activemq-web-console-5.11.1/



2. Use JConsole


Just use JConsole by adding into its classpath the jar jboss-cli-client.jar. I have added bat file to run jconsole on Windows. Just set JAVA_HOME and JBOSS_JAR.



set JAVA_HOME=

set JBOSS_JAR=



%JAVA_HOME%\bin\jconsole -J-Djava.class.path=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\jconsole.jar;%JBOSS_JAR%\jboss-cli-client.jar"







On the new connection in JConsole, choose Remote process. Set value as :


service:jmx:http-remoting-jmx://localhost:9990



username : your_admin_username

password : your_admin_password



A few tabs will appear.



Go to MBeans tab, org.apache.activeMQ sub tree will appear on the left side.



About Me

My Photo