• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why JNDI name is not present in the ejb-jar.xml file

 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

As without using the JNDI name it is not possible to access the EJB. Then why we kept the EJB JNDI name in the weblogic.xml instead of ejb-jar.xml file. Is it just to keep the changes in one xml file and constant properties in another xml file?

Thanks & Regards,
M.S.Raman
[ February 09, 2005: Message edited by: Malli Raman ]
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason you have to set up the JNDI name twice is because the J2EE spec provides a level of indirection for you. When you write your application (webapp or EJB), you can use a specific JNDI name to lookup resources. However, when you go to deploy the application in a new environment, the resources may actually be located somewhere different. Now, you wouldn't want to have to re-write your application for each deployment environment. So, you just specify in your weblogic.xml (or equivialent on another platform) what your JNDI name that you're using REALLY points to. Does that make sense?
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,

I don't find it sense,because for example you a have pet store application is deployed in one server and then why don't you require to deploy it again in another server. If I want to reuse the bean, I can lookup the bean remotly and use the methods.

Also I am not sure about the same for clustering.
 
adrian osullivan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<quote>
I don't find it (makes) sense, because for example (if) you a have pet store application deployed on one server, then why don't you (need) to deploy it again in another server.
</quote>
I don't find it (makes) sense either, 'it' being your post.

<quote>
If I want to reuse the bean, I can lookup the bean remotly and use the methods.
</quote>
That is certainly true.

<quote>
Also I am not sure about the same for clustering.
</quote>
In a cluster, method calls to remote beans will be delegated by the server according to the predefined rules, e.g. round robin, random etc. In general, servers prefer to make calls to beans within a single server rather than jumping around.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming that you don't do your development on your production server. So, while you're developing your "pet store" application, you might have your datasource named "jdbc/MyDataSource", but in production it might be called "jdbc/ProductionDataSource." So, you don't want to have to change the code so that it will work in the production system. That's why the level of indirection is there.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks for replying my query. Actually in my application, I used to lookup the actual JNDI name of the datasource directly. In my case as I am the bean developer, application assembler and deployer I don't realized the use of indirection mechanism. In head first EJB book it was clearly mentioned that the bean developer will look up for fake jndi name defined in the resource-ref tag, for which deployer will map with the original jndi name which inturn actually maps with the database.

Hi Soubir Choudhury,

You are right, the xml file which I have mentioned is ejb-jar.xml and not web.xml which is used to define the web application. From the above point, the resource ref tags are defined in the ejb-jar.xml which has been used by the bean developer/application assembler and the original jndi names is defined in the app server specific xml file mostly used the bean deployer.

Can I say, all the application server will have two xml files to distinguish the user of that files for security reasons.
[ February 09, 2005: Message edited by: Malli Raman ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!