osgiactivemq-classicembedded-jettyapache-felixweb-console

Deploying Active MQ Web Console on Felix


I have a plain Felix based OSGI Environment on which I have deployed a bundle, which has an Embedded ActiveMQ Broker. I want to have another bundle deployed on the same OSGI environment, which shall have an embedded jetty on which the ActiveMQ Web Console War file will be deployed. I tried by spawning the embedded jetty and deploying the war file as part of this bundle (bundleActivator Start Method), but it gives me the following exception -

Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContextListener
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:431)
    at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:393)

I have the Servlet-API jar in the bundle classpath (imported the package and is being resolved while bundle deployment). I have also noticed that the activemq-web-console-5.10.0.war file's lib folder also contain the Servlet-API jar.

So, I thought may be because of duplication of the Servlet-API jar, it it throwing this exception and removed the Servlet-API jar from my bundle classpath (removed the import, also tried by undeploying the bundle exporting that package) but in this case my bundle did not get deployed and I received wiring exceptions (as Jetty dependencies clearly need that jar).

I donot want to unpack and pack again the war file and try.

Please Note: this war file got deployed successfully on Karaf, but I am failing it to deploy on OSGI env based on plain Felix with my own felix launcher.

Please help !

EDIT

The bundle containing embedded jetty gets deployed, but when I start it, while Jetty is starting (deploying the war file) above exception is being thrown

END EDIT


Solution

  • hmm, rebuilding Karaf from scratch there? Anyway you'll need a webcontainer running with your felix environment to have the web-console running. Therefore you need to either have the felix http-service running, or the Pax Web Bundles (as in Karaf). The next thing you'll stumble upon will be to have a satisfying and easy logging. This you'll either need to create yourself or deploy the Pax Logging bundles (again as in Karaf). Any reason not to stick to Karaf where you have all infrastructure bundles available?