Folks;
in the midst of slowly migrating to Java EE, I'm still struggling with,
well, rather basic EJB3 related questions, hope asking them around here is
not all that stupid (sorry if it is, after all):
So far, using Spring in webapps, I used to build a shared "-api" .jar
project to contain most of my domain classes along with DAO interfaces
allowing to get them off some backend storage implementation. Having each
relevant applications depending upon these "-api" .jars, coding seemed
rather easy.
Switching to EJB3 however, I tried to do the same thing in a rather simple way:
- Built a "-api" .jar containing EJB3 entity beans representing my domain
classes as stored in the backend DB along with ...FacadeRemote interfaces.
- Created a set of EJB3 modules, one ("-service") to implement the
...FacadeRemote interfaces, and one ("-consumer"), both depending upon the
"-api" one.
- Created a stateless session bean in "-consumer" doing nothing more than
trying to make use of the ...FacadeRemote interface in order to fetch an
entity bean off the backend. Exposed this bean as a @WebService.
Using the GFv2 web administration console's Web Service Tester for the
@WebService in "-consumer", then, makes the whole mess fail dumping an error
like this:
[...]
Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown
from bean; nested exception is: java.lang.IllegalArgumentException: Unknown
entity
bean class: class foo.entities.MyEntity, please verify that this class has
been marked with the @Entity annotation.
[...]
Tried this so far in various combinations, each and every time again
stumbling across errors like this (or others - having a ...FacadeRemote
implementation in a different "project" than the Entity itself while trying
to access a NamedQuery making the EntityManager complain about the
NamedQuery being unknown).
So, from that point of view: Is there a way of creating a module structure
like this in EJB3, having entity beans known to a set of other modules
depending upon them? I am not sure whether or not this question is simple,
but after all it seems most of the tutorials (including the EJB3 books on my
shelf) seem to be limited to different EJB modules distributed at the very
least in a common .ear application which is not the case in my environment
however.
Help, anyone? :)
TIA and all the best,
Kristian