users@glassfish.java.net

Re: Glassfish V3 with Webbeans/Weld via EAR not working???

From: <glassfish_at_javadesktop.org>
Date: Wed, 14 Jul 2010 14:56:16 PDT

I have similar issue related EAR+Weld+GlassFish configuration.
I used Weld sample "translator" app as starting point. It does work in this configuration.

What is interesting that as soon as I have introduced @Produces producer in this application I've got exception when try to access EJB bean injected into CDI bean:
SEVERE: EJB5070: Exception creating stateless session bean : [SentenceTranslator]
WARNING: A system exception occurred during an invocation on EJB SentenceTranslator method public java.lang.String org.jboss.weld.examples.translator.SentenceTranslator.translate(java.lang.String)
javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
        at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:448)
        at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2467)
        at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1860)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:188)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
        at $Proxy152.translate(Unknown Source)
        at org.jboss.weld.examples.translator.TextTranslator.translate(TextTranslator.java:25)

and here is the code:
// Not annotated
public class TextTranslator implements Serializable {
   @EJB
   private Translator translator;
   ...
   public String translate(String text) {
      ...
      translator.translate(sentence);
      ...
   }

Additionally I figure out that @Resource injection stopped work in EJB beans but not in CDI beans.
I.e. I have factory bean in my EJB module.
If I would mark it with EJB javax.ejb.Singleton annotation it would not work. But when I replaced this with CDI javax.inject.Singleton annotation it works.

This issue not reproducible if an application packaged as WAR.

Any ideas?
[Message sent by forum member 'dmorozov']

http://forums.java.net/jive/thread.jspa?messageID=477681