3 Replies Latest reply on Jun 14, 2013 2:12 AM by wdfink

    Moving from 4.2.2 to AS 7

    rdiddly

      Hi.

       

      I'm in the process of moving a rather large application from JBoss 4.2.2 to JBoss AS 7.1.1. There's an awful lot to know about when doing this, and sometimes the documentation can seem to lead one around in circles. I'm sure if I was starting this from scratch, I'd do better, but I'm not, so, I have a question:

       

      I have a single EJB jar containing Entity and Session beans. Many of the Session beans use the services of other Session beans. To gain access to those beans, they use JNDI, using a utility method like the following:

       

      EJBUtil:

       

        public static AccountManagerLocalHome getAccountManagerLocalHome()

            throws NamingException {

          return HomeFactory.getHomeFactoryInstance().lookupAccountManagerLocalHome();

        }

       

      HomeFactory:

       

        public AccountManagerLocalHome lookupAccountManagerLocalHome()

            throws NamingException {

          return (AccountManagerLocalHome) lookupLocal(

              JNDINames.ACCOUNTMANAGER_LOCAL, AccountManagerLocalHome.class);

        }

       

      JNDINames.java:

       

      public interface JNDINames {

           public final static String ACCOUNTMANAGER_LOCAL = "java:comp/env/ejb/AccountManagerLocal";

      }

       

      In JBoss startup log I find this:

       

      15:50:10,268 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-10) JNDI bindings for session bean named AccountManager in deployment unit subdeployment "appEJB-1.0-SNAPSHOT.jar" of deployment "appEar-1.0-SNAPSHOT.ear" are as follows:

       

       

                java:global/appEar-1.0-SNAPSHOT/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerRemote

                java:app/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerRemote

                java:module/AccountManager!com.app.session.accountManager.AccountManagerRemote

                java:jboss/exported/appEar-1.0-SNAPSHOT/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerRemote

                java:global/appEar-1.0-SNAPSHOT/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerRemoteHome

                java:app/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerRemoteHome

                java:module/AccountManager!com.app.session.accountManager.AccountManagerRemoteHome

                java:jboss/exported/appEar-1.0-SNAPSHOT/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerRemoteHome

                java:global/appEar-1.0-SNAPSHOT/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerLocal

                java:app/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerLocal

                java:module/AccountManager!com.app.session.accountManager.AccountManagerLocal

                java:global/appEar-1.0-SNAPSHOT/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerLocalHome

                java:app/appEJB-1.0-SNAPSHOT/AccountManager!com.app.session.accountManager.AccountManagerLocalHome

                java:module/AccountManager!com.app.session.accountManager.AccountManagerLocalHome

       

      Given the above, and assuming that this code would only be called from beans within this jar, would the code work if I were to change JNDINames.java to:

       

      public interface JNDINames {

           public final static String ACCOUNTMANAGER_LOCAL = "java:app/AccountManager!com.app.session.accountManager.AccountManagerLocal";

      }

       

       

      Would there be a better/easier way to make this change? Keep in mind, I have about 50 session beans and about 30 entity beans, so the fewer changes the better.

       

      Thanks in advance.

       

      Richard

        • 1. Re: Moving from 4.2.2 to AS 7
          wdfink

          Hello Richard,

           

          yes, the JNDI names must be changed.

          If you run in the same module of the application you can use

            java:modul/Account.....

          if you are 'only' in the same EAR but in a different module you need to use

            java:app/appEar-1.0-SNAPSHOT/.....

          To make it more easy I recommend to define a module name in the DS to get rid of the version, also you can rename the ear/jar

           

          If you are using XDoclet to generate the interfaces you might change the XDoclet *.xdt templates to be able to use AS7 and earlier with the same applicaiton.

          • 2. Re: Moving from 4.2.2 to AS 7
            rdiddly

            Thanks Wolf,

             

            A question (probably stupid):

            To make it more easy I recommend to define a module name in the DS to get rid of the version, also you can rename the ear/jar

             

            In this context, what is DS?

             

            I'm using Maven to build, so I know how to get rid of the version in the module name via that route (I think), and, given what I see here, I wouldn't do this in any other way.

             

            I wish I was using some utility to generate the interfaces, but they're all hand-written. After I get it moved, I'll likely move to injection and annotations and all of that beautiful stuff anyway.

             

            Richard

            • 3. Re: Moving from 4.2.2 to AS 7
              wdfink

              Sorry,

              meant DD = DeploymentDescriptor

               

              with maven you can add the <finalName> element to the <build> to set the name of the modul.