• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification about EJB2.0 Spec

 
Ahamed Mohd
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I was going through EJB2.0 specifications.In Chapter 6
Part6.4 it is written
"The local home interface allows a local client to do the following:
� Create a new session object.
� Remove a session object."
and in 6.4.2 is as follows
"
Because session objects do not have primary keys that are accessible to clients, invoking the
javax.ejb.EJBLocalHome.remove(Object primaryKey) method on a session results in
the javax.ejb.RemoveException."
As per the above mentioned lines we should never call remove on home interface.Aren't above two statements contradicting or am i interpreting wrongly???
Any help or suggestions are highly appreciated.
 
Steve Agarwal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
removing a session from the refrence by calling on the home is allowed.
But there is a method with remove (pk) which if called throws error.
if you look at the beans development in EJB, most of them have similar architecture and concepts. So the functions though available but doesnt make sense with some beans. And thus they wanted to make it as a Note.
Steve
 
Billy Tsai
Ranch Hand
Posts: 1304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do I just need to study the parts of the EJB2.0 spec that are mapped to the exam objectives from one of the links in the resoruce page?
or the whole chapter relating to a objective?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahamed,
Welcome to Javaranch, a friendly place for Java greenhorns
We ain't got many rules 'round these parts, but we do got one. Please change your displayed name to comply with the JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Billy,
I suspect you are looking at Valentin Crettaz's mappings. If so, then you should be aware that there is at least one chapter that Kathy Sierra identified that is not in Valentin's mappings. So you should also look at the major headings in the "non mapped" chapters to see if they could apply to the topic on the exam.
I would recommend reading the entire chapter. In most cases Valentin seemed to map the actual topics, and skipped the introductions and/or examples. It will take you very little time to read those extra pieces, and it will help you to put things in perspective. And (having done the exam today) I can tell you that perspective is required. You do have to be able to do things like look at a piece of code and an extract of the web.xml file, and determine if the two do relate to each other and if they are valid together. Or based on one, pick what is needed for the other to be valid.
Regards, Andrew
 
Ahamed Mohd
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,
Thanks for providing your insight to my clarification.But one thing i wasn't sure is calling remove(Handle) method on home.Is it allowed for a SessionBean??? .I created a StatelessSessionBean and called remove on Home container is throwing RemoveException[which is very much in complaince with EJB spec].Here is the code snippet
try {
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
ht.put(Context.PROVIDER_URL,"iiop://localhost");

Context ctx = new InitialContext(ht);
System.out.println("Got the context");
Object obj = ctx.lookup("scbcd/test/sessiontest/SLSBTest");
System.out.println("Got the LookUp Object");
SLSBTestHome home = (SLSBTestHome)
PortableRemoteObject.narrow(obj,SLSBTestHome.class);
System.out.println("got home"+home);
HomeHandle handle = home.getHomeHandle();
home.remove(handle);

} catch ( RemoveException e) {
System.out.println("Caught Remove Exception");
e.printStackTrace();
} catch ( Exception e) {
}
Iam getting Caught Remove Exception if i execute above code
 
Gustavo Torreti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Iam getting Caught Remove Exception if i execute above code[/qb]<hr></blockquote>
Greetings!
There are few details on your stateless bean:
1. You CAN call remove(handle) at the home, but YOU MUST BE REMOTE (I mean, that can't be a LocalHome nor local SessionBean): Local stuff have no handle, since it's all within one VM...
2. Back to the code, you may call home.remove(sessionObjectHandle), but you CANNOT try to remove the home itself.
Removing a Stateless session Bean is telling the Home you won't need it anymore (so it can be reused someplace else), and you do so using the bean's handle (not the home's).

I was just wondering.... if that is a both nice and important thing to do, how is one supposed to remove a LOCAL session bean, as it has no Handle nor pk?
So many questions to be answered...
[ October 03, 2003: Message edited by: Gustavo Torreti ]
 
Steve Agarwal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Gustavo Torreti
I would add the talk by looking at the need of EJB.
EJB are more for solving the problem of STUBS and SKELETON architecture of distributed computing. EJB is framed to make things simpler ( though at present they are killing the performance ). we can always think of overselves by sitting on the remote client and then accessing services on a different JVM. which makes sense with HOME interface.
HOME.create -> returns remoteObject ( interface )
HOME.remove -> drops the EJBObject in the container
HOME.... -> asking the JNDI to help with user specific method but EJBObject independent.
Now to get into this business of efficiency and working we can go ahead with EJBLocal... which is to cut on marshelling and unmarshelling in a simple way.
I am preparing but this is my broad outlook when i look at any EJB Q's. Please feel free to correct or add on new details
Steve
 
Ahamed Mohd
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys for the input.I think I misinterpreted spec.
 
Jim Bedenbaugh
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve Agarwal:
thanks Gustavo Torreti
I would add the talk by looking at the need of EJB.
EJB are more for solving the problem of STUBS and SKELETON architecture of distributed computing. EJB is framed to make things simpler ( though at present they are killing the performance ).
Steve

I'm afraid I'll have to respectfully disagree. EJB container services do a lot more than just provide proxies and factories - for instance, security and transaction services. This is no mean feat, I can assure you.
 
Steve Agarwal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see security and transaction as a additional feature to the distributed computing. ( basically part of framework to implement RMI in a structural way ) Buts thats my way of looking at things and designing things.
Steve
 
hover cheng
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I was going through EJB2.0 specifications.In Chapter 6
Part6.4 it is written
"The local home interface allows a local client to do the following:
� Create a new session object.
� Remove a session object."
and in 6.4.2 is as follows
"
Because session objects do not have primary keys that are accessible to clients, invoking the
javax.ejb.EJBLocalHome.remove(Object primaryKey) method on a session results in
the javax.ejb.RemoveException."
As per the above mentioned lines we should never call remove on home interface.Aren't above two statements contradicting or am i interpreting wrongly???

IMHO, we can NOT remove any session object using the local home ingerface of Session Bean. This conflication could be one of the defects of the spec...
 
hover cheng
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi steve,

removing a session from the refrence by calling on the home is allowed.
But there is a method with remove (pk) which if called throws error.
if you look at the beans development in EJB, most of them have similar architecture and concepts. So the functions though available but doesnt make sense with some beans. And thus they wanted to make it as a Note.

So coincidently, I encoutered a question in my test. It concerns whether we can remove a session instance using a reference to local home interface. I chose NO, and I am right.
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we point the reference to Null, thereby making the object eligible for garbage collection ?
 
Billy Tsai
Ranch Hand
Posts: 1304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi I just want to comfirm that BMP is not in the exam
is that right?
 
hover cheng
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can we point the reference to Null, thereby making the object eligible for garbage collection ?

The ejb instances are maintained by container, so I don't think it can be done in such way.
 
hover cheng
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi I just want to comfirm that BMP is not in the exam
is that right?

That's right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic