Monday, January 28, 2013

JBoss OSGi

We have migrated to JBoss from Tomcat+Equinox recently.  There's a challenge to do the migration basically the documenation in jboss is a bit less than desired.

Here is the osgi subsystem in standalone.xml we finally use.

        <subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="eager">
            <properties>
                <property name="org.jboss.osgi.system.modules.extra">
                    org.apache.log4j, org.apache.commons.logging, org.slf4j, javax.xml.bind.api
                </property>
                <property name="org.osgi.framework.startlevel.beginning">
                    5
                </property>
                <property name="org.osgi.framework.system.packages.extra">
                    org.apache.log4j;version=1.2.15, org.apache.commons.logging;version=1.1.1, org.slf4j;version=1.6, javax.activation;version=1.1.1, javax.xml.bind;version=2.2, sun.security.provider;version=1.0
                </property>
            </properties>
            <capabilities>
                <capability name="javax.servlet.api"/>
                <capability name="javax.transaction.api"/>
                <capability name="javax.xml.bind.api"/>
                <capability name="javax.api"/>
                <capability name="javax.enterprise.api"/>
                <capability name="org.apache.felix.log" startlevel="1"/>
                <capability name="org.apache.felix.configadmin" startlevel="1"/>
                <capability name="org.jboss.osgi.logging" startlevel="1"/>
                <capability name="org.jboss.logmanager"/>
                <capability name="javax.ws.rs.api" startlevel="1"/>
                <capability name="org.jboss.resteasy.resteasy-jaxrs" startlevel="3"/>
                <capability name="ch.qos.cal10n"/>
                <capability name="org.apache.commons.beanutils"/>
                <capability name="org.apache.commons.codec"/>
                <capability name="org.apache.commons.collections"/>
                <capability name="org.apache.commons.lang"/>
                <capability name="org.apache.commons.io"/>
                <capability name="org.codehaus.jackson.jackson-core-asl"/>
                <capability name="org.codehaus.jackson.jackson-jaxrs"/>
                <capability name="org.codehaus.jackson.jackson-mapper-asl"/>
                <capability name="org.codehaus.jackson.jackson-xc"/>
            </capabilities>
        </subsystem>

The first thing we discovered is we have to use JBoss' logging.  It's well integrated, easy to use, but if you tried to deploy your own slf4j, log4j... it just won't work.

The 2nd thing is the org.jboss.osgi.system.modules.extra & org.osgi.framework.system.packages.extra, without them, some of the package are exported without version.  And what you see here is a list of all that I can find on different blog posts or forum.

Also, there're two version of javax.servlet.api, one being javax.servlet.api:v25 and the one i've used here is for servlet api 3.0 which is required by resteasy.

We also use resteasy-jackson-provider, but the one in jboss module exported a package which "masks" the same package exported in resteasy-jaxrs.  I've raised a JIRA about it.  Meanwhile, i've repackaged the resteasy-jackson-provider so it won't export that package.

At last, jboss also comes with a jboss config admin integration, which will add the configurations to the configadmin subsystem in standalone.xml.  However, it doesn't support list as value (Apache Felix FileInstall supports that).  Thus, if you are using FileInstall, you'll have to disable the jboss config admin (by not adding the capability to osgi subsystem)


2 comments:

  1. Hi Arthur!

    I'm trying to do the same, but using Apache Felix (and Karaf) instead of Eclipse Equinox. It is a nightmare, I have always not resolved dependencies!

    ReplyDelete
    Replies
    1. hope you've resolved the dependencies by now. but it's in fact a complicated business, the crazy thing is what took me the most time is to setup the logging! different bundles (including thridparty) use different logging, slf4j, log4j, apache common logging... and if we wanted to have everything to use log4j as the real implementation, that's surprisingly hard to do in equinox. However, JBoss seems to do that really nice. my project has a requirement to use JBoss so i haven't try felix/karaf, I was hoping that would be easier.

      Delete