powered by Jive Software

ActiveMq client in Openfire Plugin

– Active MQ client

While one shouldn’t have much to do with the other (i.e. an active mq client doesn’t really depend on any of the class libraries provided by openfire), I had problems using an Openfire plugin that contained an Active MQ client. I repeatedly received errors indicating that the class org.apache.activemq.jndi.ActiveMQInitialContextFactory could not be found.

2007.10.25 14:36:22 [http://java.util.logging.Logger.log(Unknown Source)

|http://java.util.logging.Logger.log(Unknown Source)

] Failed to start publisher because javax.management.MBeanException: com.ngc.jxfes.serviceControl.ServiceControlException: Failed to start service because javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.activemq.jndi.ActiveMQInitialContextFactory Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory

– Configuration

  • Openfire 3.3.2 and Openfire 3.3.3

  • Active-MQ 5.0 Snapshot

– Resolution

The facts that I referenced the class directly in my plugin class successfully, that the JMX components ran in unit tests outside the plugin, and that I could see the class in the active-mq jar file in the lib directory of the plugin jar indicated that I was doing everything correctly. I worked around the problem by placing the active-mq jar file in the Openfire lib directory and restarting the server.

This indicates that there is some kind of class loader problem. I suspect that the class loader that instantiates the class within the plugin is not in the same class loader branch as the class loader of the plugin itself.

I’m not sure if there is any other way to work around the problem. With this solution, whenever the plug-in is deployed to an Openfire server, the installation program will also have to deploy the Active-MQ jar to the Openfire lib directory as well.

I think this problem is resolved in 3.4.0 but I didn’t test it.

For a workaround have a look at the Classpath section of http://www.theserverside.com/tt/articles/article.tss?l=IntegratingPresenceJ2EEEn vironments