Saturday, February 25, 2012

XMPP/GTalk Shell Connector for Apache Karaf / Felix GoGo

Connecting Felix GoGo Shell through XMPP / Google Talk ?

I did a pretty interesting experiment (and will be useful at least to myself) connecting the Felix GoGo Shell in Apache Karaf/ServiceMix to XMPP/Google Talk Instant Messaging Protocol via Smack library. I spent almost 24 hours just for this. The results is pretty amazing though. :-)

I also spent quite some time to make ANSI colors sort of "working". It's not strictly correct, but at least it's not entirely boring.

What do you think ?

UPDATE: The OSGi Blueprint-compatible XMPP Shell connector is available as open source with Apache License 2.0 at

Recommended Resources
For more in-depth explanation on OSGi, I highly recommend OSGi in Action: Creating Modular Applications in Java.

Thursday, February 16, 2012

Puppet Module for JBoss AS 7.1 "Thunder"

We at Bippo Indonesia and Soluvas love JBoss AS. Especially with the shiny new release 7.1.0.Final aka "Thunder".

And we love DevOps with Puppet too!

As the least contribution we could provide, our Puppet Module for JBoss AS on GitHub is available as an open source project.

It's currently a work in progress, but as time goes we hope to make it flexible with Puppet's parameterized class feature and hopefully able to do deploy/redeploy/undeploy operations, change logging features, user management, etc. Especially that JBoss has an excellent CLI tool, we hope the integration with Puppet will be relatively easy.

Thank you JBoss!

Reblogged from

Wednesday, February 15, 2012

UnproxyableResolutionException Workaround when using Scala Closures and javax.inject CDI Beans Together

Some powerful Scala programming language features like closures, pattern matching, and lazy vals don't work well with dependency injection frameworks like javax.inject aka CDI. This is due to stricter class structure requirements to enable proxying.

For example, this "innocent" code will not work:

  @Inject private var fbPhotoImporterFactory: Instance[FacebookPhotoImporter] = _
  @Produces @Named("facebookPhotoImporter") private var fbPhotoImporter: ActorRef = _

  def init() {
    logger.debug("Starting FacebookPhotoImporter actor")
    fbPhotoImporter = Actor.actorOf(fbPhotoImporterFactory.get())

It will throw:

Caused by: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001437 Normal scoped bean class com.satukancinta.web.Persistence is not proxyable because the type is final or it contains a final method public final javax.enterprise.inject.Instance$satukancinta$web$Persistence$$fbPhotoImporterFactory() - Managed Bean [class com.satukancinta.web.Persistence] with qualifiers [@Any @Default].
    at org.jboss.weld.util.Proxies.getUnproxyableClassException(
    at org.jboss.weld.util.Proxies.getUnproxyableTypeException(
    at org.jboss.weld.util.Proxies.getUnproxyableTypesExceptionInt(
    at org.jboss.weld.util.Proxies.getUnproxyableTypesException(
    at org.jboss.weld.bootstrap.Validator.validateBean(
    at org.jboss.weld.bootstrap.Validator.validateRIBean(
    at org.jboss.weld.bootstrap.Validator.validateBeans(
    at org.jboss.weld.bootstrap.Validator.validateDeployment(
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(
    ... 5 more

As you can see, my use code isn't exactly "edge cases".

It's actually a pretty common use case: create a Akka actor and pass a factory function to it, as a closure.
The code above doesn't look like it's using a closure, but it actually is when written like this: (same functionality, but still breaks CDI)

    fbPhotoImporter = Actor.actorOf { fbPhotoImporterFactory.get() }

I can see why CDI has a strict requirement, and I can also understand why Scala implements it the way it is (Scala developers definitely already has a lot of problems working around powerful Scala features into a very restrictive JVM bytecode requirements). This is the price we pay for having a somewhat inferior language (Java, please don't get offended) in the first place.

But I as an application developer want to have a quick fix for this issue. Re-coding the class in plain Java is one option, but it turns I don't need to. There is a workaround, by creating a helper method then using it:

  @Inject private var fbPhotoImporterFactory: Instance[FacebookPhotoImporter] = _
  @Produces @Named("facebookPhotoImporter") private var fbPhotoImporter: ActorRef = _
  def createFbPhotoImporter() = fbPhotoImporterFactory.get()
  def init() {
    logger.debug("Starting FacebookPhotoImporter actor")
    fbPhotoImporter = Actor.actorOf(createFbPhotoImporter)

Now Scala is happy and CDI is also happy. Yes it's a bit more verbose but not too bad. And I guess the code is now somewhat more understandable for Java guys. :)

Tip: To learn more about Scala programming, I recommend Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd Edition.