<html><body>Hi there,<br><br>I'm trying to make a JSF app call a remote EJB. This EJB is in the same JBoss AS 6.1 instance but was deployed as a standalone EJB-JAR. I wish I could use @Inject or @EJB to inject the remote EJB proxy into the managed bean, but it isn't working.<br><br>Here's the remote interface<br><br>package exemplo;<br>@Remote<br>public interface ClienteDAO<br>{<br>&nbsp;&nbsp;&nbsp; List&lt;String&gt; listaCidades();<br>}<br><br>And the EJB<br><br>package exemplo;<br>@Stateless<br>public class ClienteEJB implements ClienteDAO<br>{<br>// no other annotations<br><br>You see, plain defaults. I can see from jmx-console my EJB is deployed and bound to ClienteEJB/remote on the global JNDI namespace. JBoss logs also show everything is fine when deploying the EJB-JAR file:<br><br>18:57:16,905 INFO&nbsp; [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:<br><br>&nbsp;&nbsp;&nbsp; ClienteEJB/remote - EJB3.x Default Remote Business Interface<br>&nbsp;&nbsp;&nbsp; ClienteEJB/remote-exemplo.ClienteDAO - EJB3.x Remote Business Interface<br><br><br><br>Now here's the managed bean:<br><br>package exemplo;<br>@Named("clientes")<br>@RequestScoped<br>public class ConsultaClientes implements java.io.Serializable {<br>&nbsp;&nbsp;&nbsp; @EJB<br>&nbsp;&nbsp;&nbsp; private ClienteDAO dao;<br>// no other annotations<br><br>When I deploy the WAR containing this, JBoss logs show the error:<br><br>18:51:39,619 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Real: name=vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error during deploy: vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war<br>...<br>Caused by: java.lang.RuntimeException: Could not resolve @EJB reference: [EJB Reference: beanInterface 'exemplo.ClienteDAO', beanName 'null', mappedName 'null', lookupName 'null', owning unit 'AbstractVFSDeploymentContext@1040164109{vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war}'] for environment entry: env/exemplo.ConsultaClientes/dao in unit AbstractVFSDeploymentContext@1040164109{vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war}<br><br><br>I tried adding attribute mappedName to the @EJB annotation. But jboss logs show:<br><br>18:53:46,011 WARN&nbsp; [org.jboss.deployment.MappedReferenceMetaDataResolverDeployer] Unresolved references exist in JBossWebMetaData:[#web-app:AnnotatedEJBReferenceMetaData{name=exemplo.ConsultaClientes/dao,ejb-ref-type=null,link=null,ignore-dependecy=false,mapped/jndi-name=ClienteEJB/remote,resolved-jndi-name=null,beanInterface=interface exemplo.ClienteDAO}]<br>18:53:46,097 INFO&nbsp; [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/clientes<br><br>And when I try to run the web app I get the error:<br><br><pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">javax.servlet.ServletException: Could not resolve reference [EJB Reference: beanInterface 'exemplo.ClienteDAO', beanName '', mappedName 'null'] in AbstractVFSDeploymentContext@1131335075{vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war}
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
        org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
</pre><p style="font-family: Tahoma, Arial, sans-serif; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial; "><b style="font-family: Tahoma, Arial, sans-serif; color: white; background-color: rgb(82, 93, 118); ">root cause</b></p><pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">org.jboss.ejb3.ejbref.resolver.spi.UnresolvableReferenceException: Could not resolve reference [EJB Reference: beanInterface 'exemplo.ClienteDAO', beanName '', mappedName 'null'] in AbstractVFSDeploymentContext@1131335075{vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war}
        org.jboss.ejb3.ejbref.resolver.ejb30.impl.ScopedEJBReferenceResolver.resolveEjb(ScopedEJBReferenceResolver.java:80)<br><br><br></pre>I also tried providing a jboss-web.xml file:<br><br>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;jboss-web&gt;<br>&nbsp;&nbsp;&nbsp; &lt;ejb-ref&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ejb-ref-name&gt;env/exemplo.ConsultaClientes/dao&lt;/ejb-ref-name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;jndi-name&gt;ClienteEJB/remote&lt;/jndi-name&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/ejb-ref&gt;<br>&lt;/jboss-web&gt;<br><br><br>But it also doesn't work. I get the error on jboss logs:<br><br>18:58:48,735 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Real: name=vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error during deploy: vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war<br>...<br>Caused by: java.lang.RuntimeException: Could not resolve @EJB reference: [EJB Reference: beanInterface 'exemplo.ClienteDAO', beanName 'null', mappedName 'null', lookupName 'null', owning unit 'AbstractVFSDeploymentContext@405139541{vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war}'] for environment entry: env/exemplo.ConsultaClientes/dao in unit AbstractVFSDeploymentContext@405139541{vfs:///home/lozano/cursos/labs-jbossas6-adm/jboss-6.1.0.Final/server/default/deploy/clientes.war}<br><br><br>I tried other @EJB attributes but nothing seem to work. The only way I found to make this work so far was explicit looking for my EJB:<br><br>@Named("clientes")<br>@RequestScoped<br>public class ConsultaClientes implements java.io.Serializable {<br>&nbsp;&nbsp;&nbsp; private ClienteDAO dao;<br>&nbsp;&nbsp;&nbsp; @PostConstruct<br>&nbsp;&nbsp;&nbsp; public void inicializa() throws NamingException {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitialContext ctx = new InitialContext();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dao = (ClienteDAO)ctx.lookup("ClienteEJB/remote");<br>&nbsp;&nbsp;&nbsp; }<br><br><br>So, is there a way to make @EJB work to inject a Remote EJB (from the same JBoss AS 6.1 instance) deployed as a stand-aline EJB-JAR into a Managed Bean inside it's own WAR, without packaging both as part of the same EAR?<br><br><br>[]s, Fernando Lozano<br></body></html>