Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB 2.1. entity bean : How to use remote interface JNDI lookup object ?  RSS feed

 
Rakesh K. Cherukuri
Ranch Hand
Posts: 48
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jboss 7.1.1
EJB 2.1


Hi,

Though it may seem strange but in one of the application i work on still uses EJB 2.1 entity beans.

While looking at the deployment log, seems like each Entity bean is registered using both remote-home and remote interfaces.

java:app/EJBApp/Entity!com.abc.remote.Remote
java:app/EJBApp/Entity!com.abc.remote.RemoteHome


Using the remote-home's JNDI lookup i was able to get the EJBObject proxy and subsequently create and use the entity.

But what about the remote interface JNDI lookup ? Reason i am asking is that one needs to create an entity before use it. That said, how to use the object that i get from remote interface JNDI lookup ? Note that the class of the returned object says its "com.sun.proxy.$Proxy13" type.

The JNDI location i am using "java:app/EJBApp/Entity!com.abc.remote.Remote"

- Rakesh

 
Claude Moore
Ranch Hand
Posts: 892
8
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I remember (by the way, only in theory, because I've never used EJB 2.1 entity myself) you should use HomeRemote to create or get an instance of your entity,
and then using accessor methods to set and get properties. I don't rember EJB 2.1 entity to have a remote interface.

Log trace you posted seems to indicate that your appserver is actually using *new* EJB 3.x portable naming convention. I think that appservers that support both 2.1 and 3.1 EJBs internally treat all EJBs as if they were EJB 3.x (I saw something similar in a project of mine where I have both 3.x and 2.x session beans: the actual JNDI name is in 3.x format). I wonder if java:app/EJBApp/Entity!com.abc.remote.Remote and java:app/EJBApp/Entity!com.abc.remote.RemoteHome are indeed the very same mapping.

 
Anand Bansal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rakesh,

I have a similar problem. Can you please tell me first how were you able to look up with java:app? I am not able to look up using this. I have the ejb jar under the application EAR.

I was able to lookup in the below manner. However, moving ahead it gets stuck in the EJB local receiver error and I am stuck at this point.

You will get a proxy object similar to what you got before. Please suggest how did you get to access the home objects after using java:app?

context.lookup("ejb:/<package>//XXBean!<package>.XXLocalHome");
(com.sun.proxy.$Proxy15) Proxy for remote EJB StatelessEJBLocator
 
Anand Bansal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally found the solution.

Entity beans 2.X are not supported in the lightweight configuration of JBoss AS 7 onwards. We have to use the use the standalone-full configuration or standalone-full-ha configuration for entity beans deployment in AS7.
Start the server using the standalone full.xml and and you'll see the entity beans being bound to JNDI:
17:27:31,762 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named XXXBean in deployment unit subdeployment "XXXEJB.jar" of deployment "XXXEAR.ear" are as follows:

java:global/XXXEAR/XXXXEJB/<ejb bean name>!<package name><ejb local home>
java:app/XXXXEJB/<ejb bean name>!<package name><ejb local home>
java:module/<ejb bean name>!<package name><ejb local home>
java:global/XXXEAR/XXXXEJB/<ejb beanname>!<package name><ejb local>
java:app/XXXXEJB/<ejb bena name>!<package name><ejb local>
java:module/<ejb bean name>!<package name><ejb local>

The JNDI should be looked up by the java:global binding :
java:global/XXXEAR/XXXXEJB/<ejb beanname>!<package name><ejb local home>.
It works good..!!
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing your solution
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!