0

I have an OSGi Bundle and a servlet. Now I want to access the bundle from the servlet. For that purpose I use the following in the servlet:

@Resource
BundleContext context
...

ServiceReference ref = context.getServiceReference("package.MyOSGiServiceInterface");
MyOSGiServiceInterface service = context.getService(ref); 

The Problem is that my servlet doesn't know MyOSGiServiceInterface 'cause that is defined in the OSGiBundle. In Eclipse I added a reference to the bundle Project in my Build Path. But at runtime it obviously can't find it.

To solve that Problem I played around with

(in bundle manifest)
Export-Package: package-of-osgi-service-interface 

(in servlet manifest)
Import-Package: package-of-osgi-service-Interface 
Dependencies: ...,deployment.MyBundle

But I couldn't solve it.

Whats the missing step? How can I tell JBoss to add the package containing MyOSGiServiceInterface in OSGiBundle to the class path?

Thanks for answers!

(JBoss AS 7.1.1)

--> error message <--

andineupert
  • 341
  • 2
  • 6
  • 19

1 Answers1

0

Eventually I solved it. I had to put the right combination of settings together to reach my goal:

  • Deploy the bundle per: File - Export - "Deployable plug-ins and fragments" into folder: "jboss/standalone/deployments"
  • Bundle-Manifest:
    • Bundle-SymbolicName: TestBundle
    • Bundle-Version: 1.0.0
    • Export-Package: "package-which-includes-my-service"
  • Servlet-Manifest:
    • Dependencies: org.osgi.core,org.jboss.osgi.framework,deployment.TestBundle:1.0.0
    • Import-Package: "package-which-includes-my-service"
andineupert
  • 341
  • 2
  • 6
  • 19