Eric D. Schabell

Sunday, March 14, 2010

JBoss BRMS install example repository gives OutOfMemoryError: PermGen space

When setting up a demo of JBoss BRMS 5.0.1 (don't think it will really matter which BRMS 5.x you use) in a JBoss EAP 4.3 product I was confronted with an error.

After server start-up you login to http://localhost:8080/jboss-brms which asks you if you want to install the sample repository in your new system. When I said yes, it would run a bit and then give me an error like this:
22:05:00,094 ERROR [STDERR] Exception in thread "http-127.0.0.1-8080-5" 
22:05:00,094 ERROR [STDERR] java.lang.OutOfMemoryError: PermGen space
22:05:00,152 ERROR [ContainerBase] Servlet.service() for servlet guvnorService threw exception
java.lang.OutOfMemoryError: PermGen space
 at java.lang.Throwable.getStackTraceElement(Native Method)
        etc.........

To fix this you need to tweak the jboss-as/bin/run.sh by adding near the top of the file the following line:
# Set a sane PermSize.
JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=256m"

Restart EAP 4.3 and the installation of your sample repository will run fine.

Friday, March 12, 2010

Tweaking the log4j BasicConfigurator

This is not magic that I am posting, but something I don't want to sort out again in the future. My current project was involving some extensive debugging of my unit tests, with long log lines on the console causing me to have to full-screen or scroll too much (forced to work on windows and lots of mouse clicks really get my goat).

By digging into the log4j BasicConfigurator.class (with my buddy Maurice, credit to the mastermind!) it has a default setup as follows:

root.addAppender(new ConsoleAppender(new PatternLayout("%r [%t] %p %c %x - %m%n")));

This will generate logging output like this:
4513 [main] DEBUG org.jbpm.graph.def.GraphElement  - event 'process-start' on ProcessDefinition(Exception Handling) for Token(/)
4654 [main] DEBUG org.jbpm.graph.def.GraphElement  -  event 'process-start' on ProcessDefinition(Exception Framework) for Token(/)

I adjusted this in my unit tests as follows:
((PatternLayout) ((Appender) Logger.getRootLogger().getAllAppenders()
  .nextElement()).getLayout())
  .setConversionPattern("%r [%t] %p %c %x -%n%n  %m%n%n");

This will give you output like this:
4513 [main] DEBUG org.jbpm.graph.def.GraphElement  -

  event 'process-start' on ProcessDefinition(Exception Handling) for Token(/)

4654 [main] DEBUG org.jbpm.graph.def.GraphElement  -

  event 'process-start' on ProcessDefinition(Exception Framework) for Token(/)

Monday, March 8, 2010

Fedora 12 NetworkManager update breaking GSM connection

My latest Fedora 12 update broke my Mobile Broadband GSM connection. I kept seeing this in my message log:


6516 Mar  8 12:22:49 localhost NetworkManager:   (hso0): device state change: 3 -> 4 (reason 0)
6517 Mar  8 12:22:49 localhost NetworkManager:   Activation (hso0) Stage 1 of 5 (Device Prepare) scheduled...
6518 Mar  8 12:22:49 localhost NetworkManager:   Activation (hso0) Stage 1 of 5 (Device Prepare) started...
6519 Mar  8 12:22:49 localhost NetworkManager:   (hso0): device state change: 4 -> 6 (reason 0)
6520 Mar  8 12:22:49 localhost NetworkManager:   Activation (hso0) Stage 1 of 5 (Device Prepare) complete.
6521 Mar  8 12:22:49 localhost NetworkManager:   Activation (hso0) Stage 1 of 5 (Device Prepare) scheduled...
6522 Mar  8 12:22:49 localhost NetworkManager:   Activation (hso0) Stage 1 of 5 (Device Prepare) started...
6523 Mar  8 12:22:49 localhost NetworkManager:   (hso0): device state change: 6 -> 4 (reason 0)
6524 Mar  8 12:22:49 localhost NetworkManager:   Activation (hso0) Stage 1 of 5 (Device Prepare) complete.
6525 Mar  8 12:22:49 localhost modem-manager: (ttyHS2) opening serial device...
6526 Mar  8 12:22:49 localhost modem-manager: Modem /org/freedesktop/ModemManager/Modems/0: state changed (disabled -> enabling)
6527 Mar  8 12:22:50 localhost modem-manager: Modem /org/freedesktop/ModemManager/Modems/0: state changed (enabling -> enabled)
6528 Mar  8 12:22:50 localhost modem-manager: Modem /org/freedesktop/ModemManager/Modems/0: state changed (enabled -> disabled)
6529 Mar  8 12:22:50 localhost NetworkManager:   (hso0): device state change: 4 -> 3 (reason 0)
6530 Mar  8 12:22:50 localhost NetworkManager:   (hso0): deactivating device (reason: 0).
6531 Mar  8 12:22:50 localhost NetworkManager:   stage1_enable_done(): GSM modem enable failed: (32) SIM PIN required
6532 Mar  8 12:22:50 localhost NetworkManager:   (hso0): device state change: 3 -> 9 (reason 0)
6533 Mar  8 12:22:50 localhost NetworkManager:   Activation (hso0) failed.
6534 Mar  8 12:22:50 localhost NetworkManager:   (hso0): device state change: 9 -> 3 (reason 0)
6535 Mar  8 12:22:50 localhost NetworkManager:   (hso0): deactivating device (reason: 0).

The key here was the line:
  stage1_enable_done(): GSM modem enable failed: (32) SIM PIN required

Some looking around and it appears that the last update to NetworkManager broke it:

Name : NetworkManager
Arch : x86_64
Epoch : 1
Version : 0.7.998
Release : 2.git20100106.fc12

A simple downgrade will fix this to back you up to the previous version, here is mine:

Name : NetworkManager
Arch : x86_64
Epoch : 1
Version : 0.7.996
Release : 6.git20091021.fc12

To do this you use the following command:

$ sudo yum downgrade NetworkManager

Restarted and the GSM card worked as advertised!

============== UPDATE 02 April 2010 =========================
See Bugzilla on this for solution of upgrading the NetworkManager and ModemManager packages
to the versions found in the test repo:

https://bugzilla.redhat.com/show_bug.cgi?id=560742
http://download.fedora.redhat.com/pub/fedora/linux/updates/testing/12/

Sunday, February 28, 2010

Drools JBoss Rules 5.0 Developer's Guide review

This book from Packt Publishing is the best one I have run across in 2009. Often they are a bit off the mark on order, cohesion and readability, but this one is spot on for business rules developers.

I think that this will become the bible for JBoss BRMS developers as it covers all the details you need to get your projects rolling.

After a very short introduction (as it should be, we are developers and want to get started), this book dives into the basic rules syntax and validation. You are then walked through the process of how to load facts into a knowledge session which is all about data transformation.

When dealing with rules we often have to make sure that the business users are not left out in the cold. The author take a good look at Domain Specific Language (DSL) implementation in Drools, decision tables and dealing with Drools Flow. These are all supported with examples and code to feed the developer learning how to make use of these elements of a rules implementation.

A walk through stateful sessions is followed by Complex Event Processing (CEP) with Drools Fusion and supported with a fraud detection example. This is really interesting and feeds me at the technical depth I expect from a developers guide.

There is an entire chapter spent on the details within Drools Flow and this is followed up with a sample application to walk you through all the details of setting up and executing a rules project. Testing is touched on briefly, along with some integration topics (Spring and the JSR94 standard). Finally, the book finishes up with a look at performance, providing you with insights to help you optimize your rules projects.

This book is well written, contains good technical depth and is very thorough. There is not much left for you to look for on JBoss with regards to your rules projects. You need this book on your development shelf if you are working with JBoss and rules in your organization.

JBoss Drools Business Rules review

I read this book early in 2009 when I was diving deeper into the JBoss Business Rules Management System (BRMS) and found it to be a good overview.

It is light on the technical depth, but this is not a problem and all crucial parts of the system are covered. It appeals to both business types and technical types trying to get a grasp of the Drools project components.

The book begins with a good introduction to rules and business rules in an organization, provides help with setting up your Drools environment and provides a tour of the following components in your business rules infrastructure:
  • Guvnor, the guided rule editor
  • JBoss IDE, the developers rule editing environment
  • Testing your rules
  • Managing your rules from Excel
  • Domain Specific Languages (DSL)
  • RuleFlow, graphical rule design
Furthermore, the book takes you through deploying rules in a real life situation and details how the rule engine works all the way down to the RETE algorithm.

This book is a very good place to start your JBoss Business Rules experience, whether you have done rules development before or not. It will get you up to speed on rules, is easy to read, well structured and before you know it you will be designing your first rules package.

Thursday, February 18, 2010

JBoss Developer Studio 3.0.0.RC1 optimizations

For those lucky customers out there that have been evaluating or playing with the customer releases of the up-coming 3.0.0 release, you might have noticed the default setup is a bit slow to start.

I was playing with my eclipse.ini file parameters and got mine to start 5x faster with these settings, maybe they will help you too:

--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.0.200.v20090519
-vmargs
-Xms256m
-Xmx1024m
-XX:-UseParallelGC
-XX:+AggressiveOpts
-XX:-UseConcMarkSweepGC
-XX:MaxPermSize=512m
-Dosgi.bundles=reference:file:org.eclipse.equinox.simpleconfigurator_1.0.101.R35x_v20090807-1100.jar@1:start,org.eclipse.equinox.transforms.xslt@1:start,org.jboss.tools.equinox.transforms.xslt@1:start

JBoss Developer Studio performance optimizations (amazing speed improvements)

Working in a virtualized environment and very sick of the slow JBDS startups, we went looking for some help in the settings. Here is what we found:

The tricks is to use the optimization done in JDK 1.6 (VMarg2) and the new agresivity of the Just In Time compiler (JIT) for VMarg3. Add theses VM arguments to eclipse.ini (file is located in your Eclipse directory, one to each line)
 
-XX:-UseParallelGC 
-XX:+AggressiveOpts 
-XX:-UseConcMarkSweepGC

What are these doing:
VMarg1 -XX:-UseParallelGC Use parallel garbage collection for scavenges. (Introduced in 1.4.1) this will create more threads running in parallel, so the second processor will be put in use
VMarg2 -XX:-UseConcMarkSweepGC Use concurrent mark-sweep collection for the old generation. (Introduced in 1.4.1) The Eclipse GUI will feel more responsive as memory will be reclaimed without blocking VM executions.
VMarg3 -XX:+AggressiveOpts Turn on point performance compiler optimizations that are expected to be default in upcoming releases. (Introduced in 5.0 update 6.)

JBoss Developer Studio / Eclipse debug ignores breakpoints fix

This week I ran into some of my Java projects where the debugging was ignoring breakpoints in my JBoss Develoepr Studio / Eclipse IDE's. I thought this was maybe just something in JBoss Developer Studio (JBDS), but it appears to be an issue with Eclipse too. 
This was the fix for me, in JBDS /Eclipse:
 
Window -> Preferences -> Java -> Installed JRE's:
  • edit JRE being used
    • edit 'Default VM Arguments' line
    • -XX:+UseParallelGC
Fixes it for me!