6 Replies Latest reply on Jan 15, 2013 6:07 AM by ralfoeldi

    JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR

    ralfoeldi

      Hi all,

       

      In JBoss 7.1.1 Final I had some osgi bundles and an EAR with EJB/JPA Modules working together "nicely" (not really, but it worked.) For various reasons I switched to 7.2.0 ALPHA.

       

      The 7.1.1 Final EJB Jar Configuration

       

      {code}<Dependencies>org.osgi.core,org.jboss.osgi.framework,

                      deployment.vimes-common:0.0.1.SNAPSHOT,

                      deployment.vimes-app:0.0.1.SNAPSHOT,

                      deployment.alfoeldi-util:0.0.1.SNAPSHOT

      </Dependencies>{code}

       

      no longer works with 7.2.0 Alpha.

       

      Deployment of the EAR is rolled back with " Deploy of deployment "ExchangeEar.ear" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.module.service.\"deployment.ExchangeEar.ear.exchange-ejb.jar\".main is missing [jboss.module.spec.service.\"deployment.alfoeldi-util.0.0.0.SNAPSHOT\".main, jboss.module.spec.service.\"deployment.vimes-app.0.0.1.SNAPSHOP\".main, jboss.module.spec.service.\"deployment.vimes-common.0.0.1.SNAPSHOT\".main]"]}"

       

      {code}<Dependencies>

                      org.osgi.core,

                      org.jboss.osgi.framework,

                      deployment.alfoeldi-util-0.0.1-SNAPSHOT.jar,

                      deployment.vimes-common-0.0.1-SNAPSHOT.jar,

                      deployment.vimes-app-0.0.1-SNAPSHOT.jar

      </Dependencies>{code}

       

      seams to resolve the dependencies. An attempt is made at actualy deploying the EAR, but the deployment fails with class no found exceptions.

       

      Caused by: java.lang.ClassNotFoundException: xxxx.jpa.shared.User from [Module "deployment.ExchangeEar.ear.exchange-ejb.jar:main" from Service Module Loader]

       

      The otherwise exact same configuration worked in JBoss 7.1.1 Final.

       

      For a lack of better words: Help?! :-)

       

      Greetings from Switzerland

       

      Rainer

        • 1. Re: JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR
          jrantav

          This was discussed in (among other things) this thread: https://community.jboss.org/thread/177379?tstart=0

           

          Summary from there:

           

          Yes, 7.1.1 way no longer works.

           

          With the change you've done it should work, but it is recommended to use valid OSGi manifests.

          • 2. Re: JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR
            ralfoeldi

            Hi Jarkko,

             

            thanks for the answer. I usually do search before posting a question and have read the thread and it does not solve the problem.

             

            As for your suggestion to use a valid OSGI Manifest: how?

             

            If I deploy the EJB Jar with a valid OSGi manifest inside of an EAR file, it gets deployed as an OSGi Bundle, but all SLSB, annotations, etc. are not recognized and not deployed.

             

            I need the SLSB, EntityManagers etc. for transaction handling. Otherwise I could dump JBoss and use Felix.

             

            Does anybody have a working, real world example (sorry, the test cases don't do it) of a Maven POM/build that deploys an EAR that needs access to OSGi Bundles?

             

            Greetings from Switzerland

             

             

            Rainer

            • 3. Re: JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR
              jrantav

              Hi,

               

              This is my own test code that does that, and works for 7.2:

               

              .ejb pom: https://github.com/eis/jboss-7.2-osgi-blueprint-gemini-poc/blob/master/noosgi-ejb/pom.xml

              .war pom: https://github.com/eis/jboss-7.2-osgi-blueprint-gemini-poc/blob/master/osgi-web-app-ejb/pom.xml

               

              I am deploying a stateless session bean in a separate module (with OSGi manifest), and annotations are normally recognized. EJB is in turn referring to OSGi service.

               

              -Jarkko

              • 4. Re: JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR
                ralfoeldi

                Hi Jarkko,

                 

                thanks for the code. I'll have to look into it tommorrow. Too much christmas shopping to do today :-)

                 

                Greetings from Bern

                 

                 

                Rainer

                • 5. Re: JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR
                  thomas.diesler

                  Here is the theory ...

                   

                  Any deployment in AS7 has a deployment name which can be referenced from a Dependencies clause in the Manifest. This would be hard-wired modularity with jboss-modules propriatary syntax. In OSGi terminology, it would be Require-Bundle sematics. In 7.2.x we removed the bundle version from the generated deployment name, which unifies bundle deployments with any other deployment name. The module reference in the Dependencies clause should still work as long as you give it the right deployment name.

                   

                  In 7.2.x we also unified the deployment unit (DU) processing such that it should no longer make a difference from that subsystem processing point of view whether a deployment is an OSGi bundle or not. Specifically, we only branch out in the deployment unit processor (DUP) chain when the module dependencies need to be determined and the actual module (which is essentially the ClassLoader) is created. Once the Module/ClassLoader is there, processing of the DU should continue regardless of the deployment type.

                   

                  Rainer, I'm interested in your use case - perhaps we can work together in the new year to get this sorted. Ultimately it should be possible to add OSGi modularity/services to any deployment type that is supported in AS7.

                  • 6. Re: JBoss 7.2.0 ALPHA1 - Acessing OSGi Bundles from EJB/EAR
                    ralfoeldi

                    Hi Thomas,

                     

                    long, long ago (2004) we built a "OSGi inside Websphere" system that allowed us to configure a service stack depending on user identity. Think different tax codes, rates, compliance rules, etc. for different countries. User A got a different stack, than User B. The overall application just "pulled" the appropriate service impls or instances. If lucky, adding a country (market) could be reduced to adding a new service configuration.

                     

                    Right now I have a project where I would like to use some of these concepts. Generic data services (User A gets data from legacy system D, User B gets data from standard JPA impl.), authentication/authorization with the same flexibility etc.

                     

                    After a too long Christmas/New Year/Skiing break :-) I'll see if I can get this up and running.

                     

                    Greetings from Zürich

                     

                    Rainer