jsf 2 - EJB3 injection into JSF managed beans failed -
i developping maven enterprise application using netbeans, glassfish3.1, ejb3 , jsf2. want inject daofacade ejb jsf managed bean does'nt work. here error message:
caused by: javax.naming.namingexception: exception resolving ejb 'remote ejb-ref name=com.procc.beans.alertcontroller/ejbfacade,remote 3.x interface =com.procc.dao.alertfacade,ejb-link=null,lookup=,mappedname=,jndi-name=com.procc.dao.alertfacade,reftype=session' . actual (possibly internal) remote jndi name used lookup 'com.procc.dao.alertfacade#com.procc.dao.alertfacade' [root exception javax.naming.namingexception: lookup failed 'com.procc.dao.alertfacade#com.procc.dao.alertfacade' in serialcontext[myenv={java.naming.factory.initial=com.sun.enterprise.naming.impl.serialinitcontextfactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.jndistatefactoryimpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [root exception javax.naming.namenotfoundexception: com.procc.dao.alertfacade#com.procc.dao.alertfacade not found]]
daofacade located ejb module , jsf managed bean war module.
+ear-project
--+ejb-module
------alertfacade.java
--+war-module
------alertcontroller.java
i tried inject same ejb servlet , went fine, this:
@webservlet(name = "daoservlet", urlpatterns = {"/daoservlet"}) public class daoservlet extends httpservlet { @ejb private alertfacadelocal alertfacade; @ejb private anomalyfacadelocal anomalyfacade; protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { list alertlist = alertfacade.findall(); out.println("found "+alertlist.size()+" alerts"); } }
here jsf managed bean : @managedbean @viewscoped public class alertcontroller extends abstractcontroller implements serializable {
@ejb private alertfacade ejbfacade; public alertcontroller() { super(alert.class); } @postconstruct public void init() { super.setfacade(ejbfacade); } }
and dao facade ejb:
@stateless public class alertfacade extends abstractfacade<alert> implements alertfacadelocal { @persistencecontext(unitname = "flams_pu") private entitymanager em; @override protected entitymanager getentitymanager() { return em; } public alertfacade() { super(alert.class); } }
i searched internet could'nt resolve problem. please help.
yes, wright! forgot controller managed bean. here is:
@managedbean @viewscoped public class alertcontroller extends abstractcontroller<alert> implements serializable { @ejb private alertfacade ejbfacade; public alertcontroller() { super(alert.class); } @postconstruct public void init() { super.setfacade(ejbfacade); }
}
in jsf page:
<p:datatable var="item" value="#{alertcontroller.items}" paginator="true">
the error thrown injection of ejbfacade alertcontroller.
i faced similar problem , didn't manage resolve it, despite of blogs claim possible, see link. haven't tried suppose possible in web application (war packaging) not in enterprise application (ear packaging).
finally decided use cdi bean manager , injection provider. see these tutorials:
Comments
Post a Comment