cancel
Showing results for 
Search instead for 
Did you mean: 

EJB intermediate context problem

Former Member
0 Kudos

Hello.

I'am migrating an application from jboss to SAP WAS and my problem is: I've got the jndi names of my EJB in the code of an interface that I can not change. The EJB names are like : ejb/myEjb1, ejb/myEJB2, etc. So I changed the default jndi name of my ejbs from the file ejb-j2ee-engine.xml. It looks like this:

<ejb-j2ee-engine>

<enterprise-beans>

<enterprise-bean>

<ejb-name>AxXnidEEntity</ejb-name>

<jndi-name>ejb/AxXnidEEntity</jndi-name>

<entity-props/>

</enterprise-bean>

<enterprise-bean>

<ejb-name>AxXfEEntity</ejb-name>

<jndi-name>ejb/AxXfEEntity</jndi-name>

<entity-props/>

</enterprise-bean>

.....

But after deploying my application I use the Engine Administrator to see where in the tree are my beans but they are not under <root>/ejb. It seems like <root>/ejb is not a context (blue), it's an object bound (red). So the deployment fails. My question is: is it a reserved name in the jndi tree? is there a way to delete or overwrite it?

I tried it using <root>/myejbs/<ejb-name> and it works.

My beans have a local interface that my application looks for at ejb/<ejbname> but they appears at localejbs/ejb/<ejbname>. Is it possible to change this?.

Please, could anybody help me?

Thank you very much.

Carlos

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Carlos,

as far as I understand you, you´re trying to lookup your Bean in the new environment without changing your lookup string from "ejb/", right?

I'm afraid it´s necessary to touch the lookup string. That's why it is a good idea to hold your jndi lookup strings in a properties file rather than to hard-wire them.

BTW - I don't think that it would be a clean migration approach to change the default composition of the JNDI-Tree just in order to not having to change your Code (I don´t know if this is possible anyway).

Regards,

Helge

Former Member
0 Kudos

Hello Helge!!

Thank you for your answer. I think your are right, the correct way is to hold the jndi lookup strings in a properties file and don't to change the jndi tree to fit my needs. But in this case is too late.

I'm making an ant script that checkouts the code from de CVS, finds the jndi strings in the code, changes them for the right strings for SAP WAS and makes the distribution "ear". In this way I don't have to change the code in the CVS that is used by the other application servers distributions. It's not the better way, but ...

Thank you again.

Carlos

Answers (1)

Answers (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Carlos,

First, let's try to answer your questions:

> is it a reserved name in the jndi tree?

Yes, it is.

> is there a way to delete or overwrite it?

Yes, you could use the commands from the NAMING group in the Console Administrator but in principle you should be very careful. However, in this case there will be no harm if you delete the object bound under /ejb.

> they appears at localejbs/ejb/<ejbname>. Is it possible to change this?

Unfortunately not.

Now, in general your application should not use the beans' jndi-names directly to look them up. Instead, you have to declare ejb-refs and use "java:comp/env/<ejb-ref-name>" for the lookup string. In this case the real jndi-names in the ejb-j2ee-engine.xml don't matter [for your application code] and you can even leave the EJB container generate them, i.e. remove them from the ejb-j2ee-engine.xml.

I'm also giving you a reference to a how-to document that might be useful to you:

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/accessin... ejb applications using jndi.pdf

Hope that helps a bit!

Vladimir

Former Member
0 Kudos

Hi Vladimir!

Thank you for you answer.

I think you are right when you say that the application should not use the beans' jndi-names directly to look them up. Using ejb-refs the application would be more portable, and migrating to other application servers in the future would be more easy. But I can't change a line of the web.xml or ejb-jar.xml of my app.

I finished the ant script and after deploy the application using the Deploy Tool, the application is working correctly.

Thank you again.

Carlos