1
votes

I want to deploy a Spring MVC web application to Sling OSGi Container. I follow this guide http://www.jasonday.net/content/running-spring-mvc-sling#configure-slingdispatcherservlet-sling-aware.

But when I deploy jar file to Sling OSGi Container, my bundle is not 'Active' (it's just 'Installed') and I found that the root cause is some dependencies are not resolved.

javax.annotation,version=[1.0,2) -- Cannot be resolved
javax.inject,version=[1.0,2) -- Cannot be resolved
net.sf.cglib.beans,version=[2.2,3) -- Cannot be resolved
net.sf.cglib.core,version=[2.2,3) -- Cannot be resolved
net.sf.cglib.proxy,version=[2.2,3) -- Cannot be resolved
net.sf.cglib.reflect,version=[2.2,3) -- Cannot be resolved
net.sf.cglib.transform,version=[2.2,3) -- Cannot be resolved
net.sf.cglib.transform.impl,version=[2.2,3) -- Cannot be resolved
net.sf.cglib.util,version=[2.2,3) -- Cannot be resolved
org.aopalliance.aop,version=[1.0,2) -- Cannot be resolved
org.aopalliance.intercept,version=[1.0,2) -- Cannot be resolved
org.apache.commons.codec,version=[1.5,2) -- Cannot be resolved
org.apache.commons.codec.binary,version=[1.5,2) -- Cannot be resolved
org.apache.commons.lang,version=[2.6,3) -- Cannot be resolved
org.apache.commons.lang.builder,version=[2.6,3) -- Cannot be resolved
org.apache.commons.lang.math,version=[2.6,3) -- Cannot be resolved
org.apache.commons.lang.time,version=[2.6,3) -- Cannot be resolved
org.aspectj.lang,version=[1.6,2) -- Cannot be resolved
org.aspectj.lang.annotation,version=[1.6,2) -- Cannot be resolved
org.objectweb.asm,version=[3.2,4) -- Cannot be resolved
org.objectweb.asm.signature,version=[3.2,4) -- Cannot be resolved
org.springframework.aop,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.aspectj,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.aspectj.annotation,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.aspectj.autoproxy,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.config,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.framework,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.framework.adapter,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.framework.autoproxy,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.framework.autoproxy.target,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.interceptor,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.scope,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.support,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.support.annotation,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.target,version=[3.0,4) -- Cannot be resolved
org.springframework.aop.target.dynamic,version=[3.0,4) -- Cannot be resolved
org.springframework.beans,version=[3.0,4) -- Cannot be resolved
org.springframework.beans.factory,version=[3.0,4) -- Cannot be resolved
org.springframework.beans.factory.annotation,version=[3.0,4) -- Cannot be resolved
org.springframework.beans.factory.config,version=[3.0,4) -- Cannot be resolved
org.springframework.context,version=[3.0,4) -- Cannot be resolved
org.springframework.context.annotation,version=[3.0,4) -- Cannot be resolved
org.springframework.context.support,version=[3.0,4) -- Cannot be resolved
org.springframework.core,version=[3.0,4) -- Cannot be resolved
org.springframework.core.io,version=[3.0,4) -- Cannot be resolved
org.springframework.expression,version=[3.0,4) -- Cannot be resolved
org.springframework.osgi.extensions.annotation,version=[1.2,2) -- Cannot be resolved
org.springframework.osgi.web.context.support,version=[1.2,2) -- Cannot be resolved
org.springframework.stereotype,version=[3.0,4) -- Cannot be resolved
org.springframework.util,version=[3.0,4) -- Cannot be resolved
org.springframework.web.bind.annotation,version=[3.0,4) -- Cannot be resolved
org.springframework.web.bind.support,version=[3.0,4) -- Cannot be resolved
org.springframework.web.context,version=[3.0,4) -- Cannot be resolved
org.springframework.web.context.request,version=[3.0,4) -- Cannot be resolved
org.springframework.web.context.support,version=[3.0,4) -- Cannot be resolved
org.springframework.web.servlet,version=[3.0,4) -- Cannot be resolved
org.springframework.web.servlet.handler,version=[3.0,4) -- Cannot be resolved
org.springframework.web.servlet.mvc.annotation,version=[3.0,4) -- Cannot be resolved
org.springframework.web.util,version=[3.0,4) -- Cannot be resolved

In the console I see this error:

ERROR: Bundle net.jasonday.examples.sling.spring.mvc [79]: Error starting/stopping bundle. (org.osgi.framework.BundleException: Unresolved constraint in bundle
net.jasonday.examples.sling.spring.mvc [79]: Unable to resolve 79.0: missing requirement [79.0] package; (&(package=javax.annotation)(version>=1.0.0)(!(version>
=2.0.0))))
org.osgi.framework.BundleException: Unresolved constraint in bundle net.jasonday.examples.sling.spring.mvc [79]: Unable to resolve 79.0: missing requirement [79
.0] package; (&(package=javax.annotation)(version>=1.0.0)(!(version>=2.0.0)))
        at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3443)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1727)
        at org.apache.felix.framework.Felix.setBundleStartLevel(Felix.java:1333)
        at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:270)
        at java.lang.Thread.run(Thread.java:662)

What should I do to install these dependencies in Sling OSGi Container? Please give me some advice on this issue.

1

1 Answers

2
votes

The second error message means that your net.jasonday.examples.sling.spring.mvc bundle requires the javax.annotation package, version >= 1.0.0 and < 2.0.0, and that package is not exported in your Sling instance.

IMO the best way to make this package available is to install a fragment bundle that adds it to the package exports of the system bundle. I don't think we have such a fragment bundle in Sling but you can take the framework-extension-activation bundle as an example to create one.

Reading the first error message that you posted it seems like you're missing a lot of other bundles as well, you can install those via /system/console/bundles, or just copy them in the Sling content repository under a folder named like /apps/yourapp/install if the Sling OSGi installer is active.