This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!

Peter Wiederkehr

Greenhorn
+ Follow
since Jul 15, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Peter Wiederkehr

I can also recommend eclipse because it really helps you in formatting your code (I've read that you must be absolutely conform to the java formatting convention) and helps you adding javadoc comments. Auto completion is also nice
Eclipse offers much more but the points above (for me) are the interestings one regarding the SCJD
If it would be allowed (but it isnt't):

SELECT p.phoneNrs FROM Person p, IN(p.phoneNrs) nr WHERE nr = ?1

You have to select the Person to which the number belongs and the call getPhoneNrs on that person.
I would give them a feedback if it would be possible to change, but because they must support backward compatibility they will not change that stuff (I will allways return null for a cmp entitty bean )
>Well, I guess we will never find out why the EJB team decided to do so.
Agree! (after much thinking about that Exception I would prefer an OperationNotSupportedException )

I also do not understand why they have defined ejbActivate and ejbPassivate in SessionBean and EntityBean, although they have a completely different meaning!
But somebody has thought that this is a good idea (perhaps I will never understand why and if someone knows the answer pls tell me )
@Valentin
>IllegalStateException should be thrown when a method has been invoked at
>an illegal or inappropriate time

If the definition is that the IllegalStateException should be thrown at an illegal time, why does that not match the getPrimaryKey on session beans? The session bean has this method and it's illegal to call it (because session bean do not make their identity public).
Of course there will never be a proper time where getPrimaryKey() could be invoked, but that would only match the definition at the "inappropriate time" part!
If yopu change the definition to:
"IllegalStateException should be thrown when a method has been invoked at
an inappropriate time" I would be fully agree.

@Jason
>So I think, if callMethodMakeNoSense() happened in the bean class code >then the bean class itself will get IllegalStateException
Why should the bean class itself get an IllegalStateException, makes it more sense for the bean itself to call such a method?? I dont't think so.

Originally posted by Valentin Crettaz:
So is it possible to call the getEJBObject in ejbCreate because it doesn't matter which EJBObject is returned?
Yes, that's right. Section 6.9.2 of the EJB 2.0 spec states that all session objects of the same stateless session bean within the same home have the same object identity assigned by the container. So it doesn't really matter which EJBObject is returned.



Really thx 4 the answer /bow

Originally posted by Valentin Crettaz:
Does the server create one if I call getEJBObject in ejbCreate and when a client invokes create on the home this instance is returned to the client?
I'm not sure I understand the question, could you rephrase please? Thanks [/QB]



:roll: ok let me rephrase it:
Assumption:
I call getEJBObject in the ejbCreate and no EJBObject exists. Now the server has to create an EJBObject.
<some time later>
A Client invokes create on the home interface. Which EJBObject is returned, a new one or the EJBObject the server has created when getEJBObject was called in ejbCreate?

I think the answer is: It doesn't matter

Originally posted by Valentin Crettaz:


Working on it



You will get

if you can answer my question (but you have to come to zurich )
Hi javaranch readers,

Invoking javax.ejb.EJBLocalObject.getPrimaryKey() on a session bean results in javax.ejb.EJBException been thrown.
Why they have choosen to throw a EJBException and not a IllegalStateException? (if I know the reason I can better remember that stuff).

Regards

Peter
>Peter, Giju is talking about entity beans for which there is no timeout stuff as for stateful session beans

Well of course you are right (I've read over the ejbLoad :roll: ) but the answer is nearly the same, the server doesn't know (care) which method is called and so calls ejbActivate and then ejbRemove (for statefull session and for entity beans).
If the bean is passivated and a timeout occurs the server will not call the ejbRemove (just kill the bean).
If the client calls remove() the server acts in the same way as the client would call another method on the bean, he will call ejbActivate (to serve the client request) and then call the ejbRemove().....
Hi javaranch-people

I've read the HF EJB and now have a Question.
In a stateless session bean it is possible to call getEJBObject in the ejbCreate method (page 228). My Question is, WHY?
Stateless session beans are pooled, the constructor, setSessionContext and the ejbCreate are called before a client calls create on the home interface (if the server pool stateless session beans at the startup). So is it possible to call the getEJBObject in ejbCreate because it doesn't matter which EJBObject is returned? Does the server create one if I call getEJBObject in ejbCreate and when a client invokes create on the home this instance is returned to the client?

Thx for any suggestion

Peter