This page shows you how you can use ServiceMix Kernel to run Apache Sling. While doing so, we also try to give you an example of all the different techniques you can use for adding bundles to the Kernel's OSGi runtime.
![]() | What is Apache Sling?
Apache Sling is a Web application framework based on REST principles that provides easy development of content-oriented applications. Sling uses a JCR repository, such as Apache Jackrabbit, as its data store. The project is currently undergoing incubation at the ASF. Have a look at http://incubator.apache.org/sling/site/index.html for more information |
Before you start...
Apache Sling currently hasn't been released yet, so you need to build Sling locally yourself before you can continue with the rest of the page. This will also put all the artifacts you require in your Maven repository.
Using hotdeploy
You can deploy a new bundle to ServiceMix Kernel by copying it into the <SMX4_KERNEL_HOME>/deploy. The Sling console depends on commons-io. The latest version of this jar file (1.4) already is an OSGi bundle, so it can be installed like this:
You can verify successful installation of the bundle by typing this command on the ServiceMix Kernel console:
Using osgi commands
ServiceMix Kernel comes with an additional URL handler that allows you to deploy bundles right out of the Maven repository from the ServiceMix console. We are going to use this technique for deploying OPS4J's Pax Web service now. The first command will install the bundle and give you the bundle ID, which can be used to start the bundle in a second command.
If the bundle is already available in your local Maven repository, you can also use an even handier syntax to deploy it. For example, we could also have installed the commons-io bundle using this command instead of hot-deployment:
Using the OBR
While building Sling, you also created an OBR repository inside your local Maven repository. Let's leverage OBR to install our next two bundles. First, add a reference to the repository.xml file in your local Maven repo using obr addUrl and check if you see any Sling bundles listed with obr list
Now, you can use these two commands to add two Sling bundles to start the Sling web console:
Use osgi list to list all bundles and use osgi start as shown above to start the two new bundles. This should give you the Sling Management console at http://localhost:8080/system/console
. Congratulations, you just deployed your first (non-ServiceMix) application on top of ServiceMix Kernel!
Next steps
Although you can use the Sling Management console, you still need to deploy some additional bundles before you can go ahead and click-and-install all the other Sling bundles though the console. You can use either hotdeployment or the OSGi commands to deploy them.
- org.apache.felix.commons/org.apache.felix.commons.commons-beanutils
- org.apache.felix.commons/org.apache.felix.commons.commons-codec
- org.apache.felix.commons/org.apache.felix.commons.commons-collections
- org.apache.felix.commons/org.apache.felix.commons.commons-fileutils
- org.apache.felix/org.apache.felix.eventadmin
- org.apache.felix/org.apache.felix.scr
You also need a JTA spec bundle and a JNDI implementation, both of them come with the ServiceMix NMR project ![]()
When all this is done, just go back to the Sling Management Console and install whatever bundle of Sling you need (skip the LogService bundle, this is already provided by ServiceMix Kernel).