I am currently preparing for SCBCD exam. I use "Head First EJB" as a text book and
JBoss as an application server. I'd appreciate if you could shed some light on the following issues:
1. The
ejb spec says that stateful sb home and the actual bean must have at least one create method and must start with
string "create" in home and "ejbCreate".
I have created a stateful sb that has one create method:
a) createMe( String ) in home interface
b) ejbCreateMe ( String ) in the actual bean.
When I try to deploy such bean JBoss throws a deployment exception:
-----------------------------------------------------------------
[org.jboss.ejb.EJBDeployer.verifier] EJB spec violation:
Bean : IAmStateful
Section: 6.10.6
Warning: A session bean's home interface must define one or more create(...) methods.
------------------------------------------------------------------
Does it mean that there should be always at least one create method called exactly "create" and "ejbCreate" respectively in home / bean?
2) Why does the ejb spec say that EJBObject can accessed from ejbCreate method of the stateless sb? Stateless sb creation is not linked to the client at all. So what EJBObject are we accessing from ejbCreate? It cannot be EJBObject that is serving the client, can it be?
3) Also I have tried to get EJBObject while in session bean's setSessionContext( SessionContext ) method expecting some sort of error. However, to my surprise there was no error and I could even execute getHandle() on EJBObject!?!? The spec says that EJBObject cannot be accessed from within setSessionContext ( SessionContext ). So what is happening then?
4) In addition, the spec says that EJBObject#getPrimaryKey() can only be called on EntityBeans, or RemoteException is thrown. However, I've got the client that calls getPrimaryKey() on biz interface ( i.e. stub to EJBObject ) and... instead of throwing ex it returns a value that happens to be jndi name ( name used to find session bean's home interface in directory tree ). Is it an expected behaviour?
I greatly appreciate your answers.
Thanks a lot.
Alex.