users@glassfish.java.net

_at_Remote EJB + JNDI supported in hybrid (JavaEE+OSGi) JAR?

From: <glassfish_at_javadesktop.org>
Date: Mon, 03 May 2010 10:51:23 PDT

Hello *,

I'm trying to get a test application running which is built entirely of OSGi bundles. I've browsed the web a while, came across many locations and still have a big problem: I can't get my EJBs properly deployed (they don't pop up in JNDI).

Here's what I found so far:
* http://weblogs.java.net/blog/ss141213/archive/2010/04/21/osgijmsmdb-example
* http://weblogs.java.net/blog/ss141213/archive/2010/03/30/ejb-osgi-service-demo-eclipsecon
* http://www.eclipsecon.org/2010/sessions/?page=sessions&id=1392

After some time trying around, I had my first success: I have a web application containing a simple servlet deployed as OSGi bundle in ${glassfishv3}/glassfish/domains/mydomain/autodeploy/bundles/ and I'm able to access it via the browser. Hurray!

Now I need 2 more things: EJBs and data model.

After quite some time of experimenting, I still don't succeed in getting my EJBs deployed as OSGi bundle. I'm wondering, what I'm doing wrong. Here's my META-INF/MANIFEST.MF:

***
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: OSGi EJB project
Bundle-SymbolicName: org.nightlabs.test.osgi.ejb
Bundle-Version: 1.0.0
Bundle-Vendor: NightLabs.org
Import-Package: javax.ejb
Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.2
Export-EJB: ALL
Export-Package: org.nightlabs.test.osgi.ejb
***

I have one very small class and a corresponding interface (both in package org.nightlabs.test.osgi.ejb):

***
@Remote
public interface TestRemote {
        String test(String s);
}

@Stateless
public class TestBean implements TestRemote {
    @Override
    public String test(String s)
    {
            return s.toUpperCase();
    }
}
***

First, it took me a while to find out that Felix obviously doesn't like module dependencies: I declared my OSGi-web-bundle to be dependent on the EJB-bundle and was not able to load the interface TestRemote (got a NoClassDefFoundError). After changing it to declare a dependency on the package, it finally worked.

But: My TestRemote interface cannot be found anywhere in JNDI. I even wrote some code to scan the complete JNDI, but it is not there (in contrast to EAR-deployed EJBs).

After reading http://www.slideshare.net/wwwsahoo/osgi-java-ee-in-glassfish-3553192 again, I'm wondering, whether it is supported after all, as it says "Export­EJB: List of EJBs to be exported as OSGi services." and "Support for Stateless & Singleton EJBs with Local Views".

Does that mean, an EJB in an OSGi-bundle cannot be exposed via @Remote to remote clients, but is only accessible as *local* OSGi service???

Best regards, Marco :-)
[Message sent by forum member 'nlmarco']

http://forums.java.net/jive/thread.jspa?messageID=400203