This content has been marked as final.
Show 4 replies
-
1. Re: CDI and EJB: why is no transaction started?
ljnelson Jul 27, 2010 7:28 AM (in response to ljnelson) -
2. Re: CDI and EJB: why is no transaction started?
pmuir Jul 27, 2010 7:54 AM (in response to ljnelson)Looking at the stack trace from that post, it looks like it isn't being picked up as an EJB. Can you show your code?
-
3. Re: CDI and EJB: why is no transaction started?
ljnelson Jul 27, 2010 8:46 AM (in response to ljnelson)I'll do my best. I apologize in advance for the formatting; the formatter in this odd little forum won't let me use Java generics; it thinks they're invalid HTML. That prevents me from using wiki markup to isolate the code blocks. :-(
Anyway, my servlet has this:
@Inject
private Instance<LEADApplication> application;
The servlet is utterly uninteresting, as it serves merely to connect the interwebs to a Vaadin application instance. That's pretty much it for the servlet.
LEADApplication is defined like this:
@SessionScoped
public class LEADApplication extends Application {
//...
}
Inside it, it has this:
@Inject
private Instance<DAO> daos;
LEADApplication is housed in my .war file in the WEB-INF/classes directory tree. WEB-INF/beans.xml is also there, so it's a bean archive.
Onwards to the EJB business interface.
DAO is a business interface, stored in its own jar file. It is defined (in part) like this (no other annotations or CDI or EJB bits in there):
public interface DAO extends Serializable {
}
That jar file lives in the ear under its lib directory. It does not contain WEB-INF/beans.xml, as it consists entirely of interfaces.
Next up, one of the EJBs.
PersonManagerBean is defined like this:
@Local({ PersonManager.class, DAO.class })
@Stateless
public class PersonManagerBean extends BasePersonManagerBean {
}
It is stored in a jar file at the root of the ear file, and declared as an EJB module in application.xml. It has a META-INF/beans.xml, thus rendering it a bean archive.
BasePersonManagerBean is declared like this:
public class BasePersonManagerBean extends AbstractDAO implements PersonManager {
}
There are no annotations in it. It is stored in its own jar file under the lib directory of the ear file. It has a META-INF/beans.xml, thus rendering it a bean archive.
The AbstractDAO from which it extends is declared like this:
public abstract class AbstractDAO implements DAO, Serializable {
@PersistenceContext
protected EntityManager em;
}
It is housed in a jar file present in the lib directory in the .ear file. Its jar file has a META-INF/beans.xml, thus rendering it a bean archive.
As far as the code goes, that's really about it. I hope this helps get to the bottom of this. Let me know if you need more details.
Best,
Laird -
4. Re: CDI and EJB: why is no transaction started?
ljnelson Jul 27, 2010 10:46 AM (in response to ljnelson)Pete, it appears that there are lots of issues involved here; most seem to be Glassfish-related. Nevertheless, perhaps you could chime in on the discussion over there? You might spot something. Thanks for your help.
Best,
Laird