• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJBObject, EJBHome and SessionBean methods

Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
author & internet detective
Posts: 40035
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many app servers don't implement the spec to the letter. For example, all of the app servers that I have used want the methods to be create() and ejbCreate() rather than just start with it.
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, Jeanne. Now it is clear to me why some things in Jboss do not work as defined in the spec.
I still can't get what EJBObject are given access to when in ejbCreate(...) method of stateless sb? Stateless sb is not linked to the client's call to create(...) on home interface. In theory, container creates stateless bean when there is no EJBObject( client ) to associate with the bean.
    Bookmark Topic Watch Topic
  • New Topic