Discussion:
[jboss-user] [JNDI and Naming] - Moving from 4.2.2 to AS 7
Richard Doust
2013-06-12 20:52:42 UTC
Permalink
Richard Doust [https://community.jboss.org/people/rdiddly] created the discussion

"Moving from 4.2.2 to AS 7"

To view the discussion, visit: https://community.jboss.org/message/822853#822853

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/822853#822853]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Wolf-Dieter Fink
2013-06-13 06:35:26 UTC
Permalink
Wolf-Dieter Fink [https://community.jboss.org/people/wdfink] created the discussion

"Re: Moving from 4.2.2 to AS 7"

To view the discussion, visit: https://community.jboss.org/message/822898#822898

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/822898#822898]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Richard Doust
2013-06-13 13:30:56 UTC
Permalink
Richard Doust [https://community.jboss.org/people/rdiddly] created the discussion

"Re: Moving from 4.2.2 to AS 7"

To view the discussion, visit: https://community.jboss.org/message/822997#822997

--------------------------------------------------------------
Thanks Wolf,
Post by Wolf-Dieter Fink
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/822997#822997]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Wolf-Dieter Fink
2013-06-14 06:13:05 UTC
Permalink
Wolf-Dieter Fink [https://community.jboss.org/people/wdfink] created the discussion

"Re: Moving from 4.2.2 to AS 7"

To view the discussion, visit: https://community.jboss.org/message/823111#823111

--------------------------------------------------------------
Sorry,
meant DD = DeploymentDescriptor

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

Reply to this message by going to Community
[https://community.jboss.org/message/823111#823111]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Loading...