11 Replies Latest reply on Mar 9, 2012 7:04 AM by sony2006

    JNDI naming issue: Migrating to AS7 using EJB 2.1

      Hi,

      I'm trying to migrate my ear-File from JBoss 5.1 to JBoss AS 7.01. I'm using EJB 2.1 and cannot change to 3.0 right now.

      My application deploys, but when I start the application I run into JNDI naming problems since the JNDI naming rules have changed from 2.1 to 3.0

      (javax.naming.NameNotFoundException: Name 'myapp' not found in context '')

       

      In the documentation( https://docs.jboss.org/author/display/AS7/Order+Application+Migration+from+EAP5.1+to+AS7 ) they solved it by changing the code to use the @EJB annotation. They write there, that this is not a required change. [ I cannot change to EJB 3.0, so I need another solution. ]

       

      Important: My ear-file needs to be deployable on different AS as well (IBM Websphere etc.), so I'm restricted in terms of making code changes.

       

      What do you recommend?

       

       

      Ideas and comments:

       

      - Is there a way to alias the JNDI names or to use a mapping from the new JNDI namespace to the 2.1 standard i.e from

      java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager

      to

      OrderManagerApp/ProductManagerBean/local

       

      - In a German Java journal they write that you have to adapt the ServiceLocator. How does that work? Is this possible when I also want to use the ear-File on other ASs? [They also write that EJB 2.1 is again completely supported in AS 7.1.0, do I have to wiat?]

       

      - In https://docs.jboss.org/author/display/AS7/Seam+2+Booking+EAR+Migration+of+Binaries+-+Step+by+Step they resolve the JNDI naming problems using the components.xml. Can I use a similar solution? Unfortuantely the components.xml is part of Seam 2...

       

      I apprecite your help;)

      J.

        • 1. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1

          if you don't know a solution: any comments?

          • 2. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
            jaikiran

            municheast wrote:

             

            Hi,

            I'm trying to migrate my ear-File from JBoss 5.1 to JBoss AS 7.01. I'm using EJB 2.1 and cannot change to 3.0 right now.

            AS7 does not yet have EJB2.1 support. It will be available in AS 7.1

             

             

            municheast wrote:

             

            Ideas and comments:

             

            - Is there a way to alias the JNDI names or to use a mapping from the new JNDI namespace to the 2.1 standard i.e from

            java:app/OrderManagerEJB/ProductManagerBean!services.ejb.ProductManager

            to

            OrderManagerApp/ProductManagerBean/local

             

            We haven't yet thought of whether we will be allowing JBoss specific JNDI names (via descriptors for example) for the beans. We might allow it (if we don't see any issue with doing that), considering that it might help the migration.

            1 of 1 people found this helpful
            • 3. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1

              Will AS 7.1.0 alpha have EJB 2.1. support?

              Could you send me the issue tracker link for this?

              Thanks!

              • 4. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                duanxz

                hi,municheast

                 

                The EJB2.1 Object not found by JNDI issue do you have a good solution?

                 

                my app also couldn't change to EJB3.0. if you have a good solution,please tell me, thanks!!

                 

                 

                 

                Regards,

                duanxz

                • 5. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                  wolfc

                  If you want true compliancy and portability you should never do global lookups. Instead you should define ejb-refs / ejb-local-refs in the web.xml / ejb-jar.xml descriptors, then use the product specific descriptors to associate them with a jndi-name or lookup-name.

                   

                  For AS 7 it would look like:

                  ejb-jar.xml

                  <?xml version="1.0" encoding="UTF-8"?>
                  <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                              http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
                        version="3.1">
                     <enterprise-beans>
                        <session>
                           <ejb-name>Simple31Bean</ejb-name>
                           <ejb-ref>
                              <ejb-ref-name>other</ejb-ref-name>
                           </ejb-ref>
                        </session>
                     </enterprise-beans>
                  </ejb-jar>
                  

                   

                  jboss-ejb3.xml:

                  <jboss:ejb-jar
                          xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
                          xmlns="http://java.sun.com/xml/ns/javaee"
                          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                          xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
                             http://java.sun.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-spec-2_0.xsd"
                          version="3.1"
                          impl-version="2.0">
                     <enterprise-beans>
                        <session>
                           <ejb-name>Simple31Bean</ejb-name>
                           <ejb-ref>
                              <ejb-ref-name>other</ejb-ref-name>
                              <lookup-name>java:app/othermodule/OtherBean</lookup-name>
                           </ejb-ref>
                        </session>
                     </enterprise-beans>
                  </jboss:ejb-jar> 
                  

                   

                  Note that currently using a 2.1 ejb-jar descriptor is not yet supported, see JBMETA-341.

                  • 6. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1

                    Hi,

                    as the JBoss Team told me the EJB 2.1. support will be added in aSNAPSHOT nightlybuild in November or early December.

                    My strategy: just waiting....

                     

                     

                    PM from Oct 11 2011 about EJB 2.1:

                    It's already in progress (in some individual branches). It will available in a SNAPSHOT nightly build in the upcoming weeks. I am not sure if there are specific JIRAs for EJB2.x work, but I'll check tomorrow. Anyway, we do plan to make a forum post in the AS7 user forum http://community.jboss.org/en/jbossas/as7_users once EJB2.x (and even remote EJB invocations) is made available in a nightly build.

                    • 7. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                      sony2006

                      Does AS version 7.1.0.CR1b support EJB 2.1

                      Thanks

                      • 8. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                        prasad.deshpande

                        Does AS version 7.1.0.CR1b support EJB 2.1

                        Thanks

                        Yes, it does support EJB 2.x...

                        • 9. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                          sony2006

                          Thanks Prasad. It worked.

                          • 10. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                            jsebfranck

                            Hi,

                             

                            Finally, did you find a way to use EJB 2 in AS7.1? If is the case, could you please tell us how to do in the related ticket : https://community.jboss.org/message/722458.

                             

                            Thanks in advance !

                            • 11. Re: JNDI naming issue: Migrating to AS7 using EJB 2.1
                              sony2006

                              I have tried with stateless session beans alone.