aspose file tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Clarification about EJB2.0 Spec Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » EJB Certification (SCBCD/OCPJBCD)
Reply Bookmark "Clarification about EJB2.0 Spec" Watch "Clarification about EJB2.0 Spec" New topic
Author

Clarification about EJB2.0 Spec

Ahamed Mohd
Greenhorn

Joined: Oct 02, 2003
Posts: 3
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.


Ahamed<br />SCJP1.4
Steve Agarwal
Ranch Hand

Joined: Feb 02, 2003
Posts: 51
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


SCJP1.4,SCWCD, SCBCD, SCEA part 1<br />"Its feels good to know the stuff in detail."
Billy Tsai
Ranch Hand

Joined: May 23, 2003
Posts: 1294
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

Joined: Aug 26, 2001
Posts: 7610
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!


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 9982

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Ahamed Mohd
Greenhorn

Joined: Oct 02, 2003
Posts: 3
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

Joined: May 20, 2003
Posts: 84

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 ]

"You were trained to handle mission impossible;<br /> 'difficult' should be a walk in the park for you."
Steve Agarwal
Ranch Hand

Joined: Feb 02, 2003
Posts: 51
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

Joined: Oct 02, 2003
Posts: 3
Thanks Guys for the input.I think I misinterpreted spec.
Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171
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.


Regards,
Jim
SCJP, SCJD, SCWCD, SCEA Part I
Steve Agarwal
Ranch Hand

Joined: Feb 02, 2003
Posts: 51
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

Joined: Feb 11, 2003
Posts: 66

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...


SCJP 91% SCJD 94% SCBCD 98% SCWCD1.4 86%<p>XML141 SCDWJS -- in progress<br />If you don't retreat, you are mostly among those who can surmount it.
hover cheng
Ranch Hand

Joined: Feb 11, 2003
Posts: 66
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

Joined: Oct 07, 2003
Posts: 75
Can we point the reference to Null, thereby making the object eligible for garbage collection ?


UP THE IRONS !
Billy Tsai
Ranch Hand

Joined: May 23, 2003
Posts: 1294
hi I just want to comfirm that BMP is not in the exam
is that right?
hover cheng
Ranch Hand

Joined: Feb 11, 2003
Posts: 66

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

Joined: Feb 11, 2003
Posts: 66

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

That's right.
 
 
subject: Clarification about EJB2.0 Spec
 
Threads others viewed
spec EJB problem with session beans
EJBLocalHome
RemoveException or EJBException
[EJB 2.0 Spec] WHERE IS THE TRICK???!!!
Session removal via local home?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com