• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJBObject, EJBHome and SessionBean methods

 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Alex.
 
author & internet detective
Posts: 42103
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alex,
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic