1 2 Previous Next 20 Replies Latest reply on Sep 26, 2011 12:48 PM by ranthyreddy

    Injecting EJB into cxfse service impl...

    yusuf.jakoet

      Hi

       

      I've amended the cxf-wsdl-first-osgi-package example and I'm struggling to get the following to work.  I'm configuring one EJB via spring.  The bundle compiles file.  When I do a features:install, however, I get a dependency error on javax.ejb.EJBHome.  Now, my service implementation was doing a manual ejb lookup and that worked.  All I want to do now is have the ejb injected.

       

      The debug output shows the packages that are wired when the feature is deployed.  Before it fails, the only dependencies that are wired are Spring packages, so it fails due to not being able to find javax.ejb.EJBHome.  Why are those imports not available at the time the spring context is initialised?

       

      Spring configuration:

       

       

            <property name="jndiName" value="jndiName" />

             

            <property name="businessInterface" value="remoteInterface" />

       

           

        • 1. Re: Injecting EJB into cxfse service impl...
          ffang

          Hi,

           

          I think you need import-package javax.ejb in the pom.xml for your cxf-se bundle.

           

          Freeman

          • 2. Re: Injecting EJB into cxfse service impl...
            yusuf.jakoet

            That's the thing, it's already there.  And if I do a manual lookup in code then it works.  For some reason the spring config doesn't...

            • 3. Re: Injecting EJB into cxfse service impl...
              yusuf.jakoet

              A couple of questions:

               

              a) Would it be possible to deploy a spring configuration containing the ejb and then do an osgi lookup via jndi?

               

              b) Can I configure a remote ejb via blueprint configuration? and would i be able to deploy the configuration to smx?

              • 4. Re: Injecting EJB into cxfse service impl...
                yusuf.jakoet

                Just tried to deploy a spring config to smx and got the same error:

                 

                Caused by: java.lang.ClassNotFoundException: *** Class 'javax.ejb.EJBHome' was not found because bundle org.springframework.context does not import 'javax.ejb' even though bundle wrap_file_____var_java_mtest_jboss_client_jbossall-client.jar does export it. To resolve this issue, add an import for 'javax.ejb' to bundle org.springframework.context . ***

                 

                Would I be able to configure the org.springframework.context bundle?

                • 5. Re: Injecting EJB into cxfse service impl...
                  ffang

                  Hi,

                   

                  Actually org.springframework.context import javax.ejb, but as optional, so after you install your bundle wrap_file_____var_java_mtest_jboss_client_jbossall-client.jar which export javax.ejb, you do osgi:refresh bundle_id_for org.springframework.context, then you could see this package get resolved for org.springframework.context, then you install your cxf-se bundle, you will not see  'javax.ejb.EJBHome' CNFE.

                   

                  Freeman

                  • 6. Re: Injecting EJB into cxfse service impl...
                    yusuf.jakoet

                    Thanks for that.  It makes sense, but at which point would the osgi:refresh make the spring-context bundle see my packages?  The refresh isn't picking up the packages.

                     

                    Will re-installing the jbossall-client.jar help?

                     

                    Thanks

                    • 7. Re: Injecting EJB into cxfse service impl...
                      ffang

                      Hi,

                       

                      jbossall-client.jar export javax.ejb package, right?

                       

                      After you install jbossall-client.jar successfully(you can check this bundle status, and check if jbossall-client.jar export javax.ejb), then refresh spring-context  should get javax.ejb resolved, it expected the javax.ejb version [2.1.0, 4.0.0), ensure the javax.ejb version exported by  jbossall-client.jar meet the requirement.

                       

                      Freeman

                      • 8. Re: Injecting EJB into cxfse service impl...
                        yusuf.jakoet

                        Yes it does export javax.ejb.

                         

                        When I refresh the spring-context, i get a few exceptions :

                         

                        ERROR: JarContent: Unable to read bytes. (java.lang.IllegalStateException: zip file closed)

                         

                        once it settles, then i can no longer use the 'osgi:' commands in the karaf shell...

                         

                        here's a snippet of what's happening after i install the jbossall-client.jar...

                         

                        karaf@root> osgi:list | grep Spring

                           ID   State         Blueprint      Spring    Level  Name

                        Apache Karaf :: Spring Deployer (2.0.0)

                        Spring ASM (3.0.3.RELEASE)

                        Spring AOP (3.0.3.RELEASE)

                        Spring Aspects (3.0.3.RELEASE)

                        Spring Core (3.0.3.RELEASE)

                        Spring Beans (3.0.3.RELEASE)

                        Spring Context (3.0.3.RELEASE)

                        Spring Context Support (3.0.3.RELEASE)

                        Spring Expression Language (3.0.3.RELEASE)

                        Spring Transaction (3.0.3.RELEASE)

                        Spring JMS (3.0.3.RELEASE)

                        Apache XBean :: Spring (3.7)

                        karaf@root> osgi:refresh 60

                        karaf@root> ERROR: JarContent: Unable to read bytes. (java.lang.IllegalStateException: zip file closed)

                        java.lang.IllegalStateException: zip file closed

                        • 9. Re: Injecting EJB into cxfse service impl...
                          ffang

                          Hi,

                           

                          What FUSE ESB version you're using?

                          If you're using 4.3.0-fuse-00-00, edit etc/config.properties

                          change

                          karaf.framework=felix

                          to

                          karaf.framework=equinox

                          Or you should use 4.3.0-fuse-00-01.

                           

                          I think there's a felix[1] issue related to refresh spring-context bundles

                           

                          https://issues.apache.org/jira/browse/FELIX-2480

                           

                          Freeman

                          • 10. Re: Injecting EJB into cxfse service impl...
                            yusuf.jakoet

                            I've switched to equinox.  The bundle installs fine, but cannot start due to the spring dependency.  Same issue, though the spring-context refresh doesn't kill servicemix..

                             

                            How do i know if the Spring-Context has picked up the packages correctly?

                            • 11. Re: Injecting EJB into cxfse service impl...
                              ffang

                              Hi,

                               

                              You can use

                               

                              packages:imports bundle_id

                               

                              to check which package the bundle import

                               

                              Freeman

                              • 12. Re: Injecting EJB into cxfse service impl...
                                yusuf.jakoet

                                Hi,

                                 

                                Okay, the Spring Context bundle isn't importing javax.ejb.  The command I'm using to install the jbossall-client.jar is

                                 

                                osgi:install -s wrap:file:////path/to/file.jar

                                 

                                Once the bundle is active, and I do a osgi:refresh on the spring context, should it work?  How can I be sure that the Spring Context bundle is the culprit?

                                 

                                 

                                Thanks

                                • 13. Re: Injecting EJB into cxfse service impl...
                                  yusuf.jakoet

                                  I've noticed that the packages exported by jbossall-client bundle have the version set to "0.0.0" ie.  (done via packages:export...)

                                   

                                  wrap_file_____var_java_mtest_jboss_client_jbossall-client.jar (172): javax.ejb; version="0.0.0"

                                  wrap_file_____var_java_mtest_jboss_client_jbossall-client.jar (172): javax.ejb.spi; version="0.0.0"

                                   

                                  Could this be the cause. If so, how do I go about changing that value?

                                  • 14. Re: Injecting EJB into cxfse service impl...
                                    yusuf.jakoet

                                    Caused by: java.lang.NoClassDefFoundError: javax/ejb/EJBHome

                                     

                                    Is anyone able to get around this issue when injecting an EJB into a cxfse bundle...?

                                    1 2 Previous Next