How to create an Object of an EntityBean Class
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Taufiq_Yusuf
Posted On:   Friday, May 20, 2005 02:14 AM

new on j2ee im working on a struts project ... in the action bean class i do this

Accounts acc = new Accounts();

where Account is an Entity bean [btw im using myEclipse IDE]

when i submit the page i get this error:

"java.lang.NoClassDefFoundError: accounts/ejb/Accounts"

where Accounts is the class name[EntityBean] and accounts.ejb is the package .... plz Help ..... :)

Thanx

Re: How to create an Object of an EntityBean Class

Posted By:   Anonymous  
Posted On:   Friday, May 20, 2005 02:55 PM

You cant just instantiate EJB like a normal POJO.You need to use RMI(if u use ejb1.0)/LocalIntefaces mechanism to access Enterprise bean.The Ejb must be running in the EJB Container.You need to lookup the Home Interface using JNDI.Then get the stub of the Ejbobject and need to invoke methods on that.It will be confusing for you..but once u get an idea of RMI..it will be pretty simple.
It is some thing like



your EJB

--------

myejb.java--->Remote Object

myejbHome.java-->Home Interface

myejbRemote.java--->Remote Interface


client

------

you need to have Home and Remote interface at client side to access the bean.then u do something like this
myclient
{
myejbHome obj=(myejbHome)context.lookup("jndiname");

myejbRemote rem=myejbHome.create(XX);

Now u will get reference of remote object in "rm" and u can invoke methods on the bean.

rem.XXX()-->Business logic method in the bean.


}

So the whole story is it is a different mechanism u access Bean(session & Entity)..and u cant access Messagebean accept by sending a message to the queue that it is listening.


Hope it cleared you a bit..Study guide on ejb from "Roman".


Goodluck


mallik.

About | Sitemap | Contact