I have a servlet deployed to the WebSphere Liberty profile via an EAR file. The application entry in server.xml looks like this:
<application id="MyApp" name="MyApp" type="ear" location="MyApp.ear" />
The servlet needs to access a service provided by an OSGi bundle. I followed the example mentioned here. The OSGi bundle exports the package the Counter interface is in. Adding an "Import-Package" statement to the EAR's manifest (like an OSGi bundle would have) to resolve the reference to Counter resulted in a class-def exception. So I added the class directly to the EAR. Now InitialContext.lookup() does return a proxy object but typecasting it to the Counter interface results in a casting exception.
I suspect the casting exception is happening because the EAR has its own Counter.class. Is there some other way I should be resolving that reference? How can an EAR import a package from another OSGi bundle?