we have issue have superclass annotation (@resource
) , subclasses extend superclass are stateless beans.
very similar this, if superclass , subclass in same module resource injected successfully. if in separate modules resource not injected - seems annotation not processed.
i've verified through reflection annotation "seen" on class, when step resourceinjectionannotationparsingprocessor
, @resource
annotation not show on classes inherit other modules (although show on classes in same module).
the common solution i've been seeing jandex
files , set annotations="true"
seems static modules, not other deployments such in our case.
the other suggestion modules missing dependency on annotations, in example modules involved had dependency on <module name="javax.annotation.api"/>
.
is there other way make these annotations "visible" separate deployments?
as minimal example, if have superclass
import javax.annotation.resource; import javax.ejb.sessioncontext; public class baseresource { @resource private sessioncontext sessioncontext; public string getcontext() { return "context " + sessioncontext; } }
and subclass of
import javax.ejb.stateless; @stateless public class resourcebean extends baseresource { public resourcebean() { system.out.println(getclass().getname() + " created"); } }
if these in same module, sessioncontext
displayed. in separate modules, sessioncontext
null
.
you sessioncontext
workaround. not answer issue can @ least access sessioncontext.
public sessioncontext getsessioncontext() { try { initialcontext ic = new initialcontext(); return (sessioncontext) ic.lookup("java:comp/ejbcontext"); } catch (namingexception ex) { // handle exception } return null; }
excerpt from: http://javahowto.blogspot.com/2006/06/4-ways-to-get-ejbcontext-in-ejb-3.html
Comments
Post a Comment