[jboss-user] [EJB3] - @EJB(lookup="xx") fails.

Arthur Gerson do-not-reply at jboss.com
Tue Sep 11 15:55:26 EDT 2012

Arthur Gerson [https://community.jboss.org/people/agerson] created the discussion

"@EJB(lookup="xx") fails."

To view the discussion, visit: https://community.jboss.org/message/759096#759096

*Sorry ahead of time if this problem is clarified else where.* 
*Using Eclipse I have created a bean called Foo and a servlet to call it.*

package com.foo.ejb;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
 * Session Bean implementation class Test
public class Foo implements FooRemote, FooLocal {
     * Default constructor. 
    public Foo() {
        // TODO Auto-generated constructor stub
 }//End of file Foo.java

package com.foo.ejb;
import javax.ejb.Local;
public interface FooLocal {
}//End of file FooLocal.java

package com.foo.ejb;
import javax.ejb.Remote;
public interface FooRemote {
}//End of file FooRemote.java

import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jboss.logging.Logger;
import com.foo.ejb.FooRemote;
 * Servlet implementation class TheServlet
public class TheServlet extends HttpServlet {
          private static final long serialVersionUID = 1L;
          private Logger logger = Logger.getLogger(TheServlet.class);

  @EJB( lookup="java:global/FooBean/Foo!com.foo.ejb.FooRemote")
                                  private FooRemote foo ;

     * @see HttpServlet#HttpServlet()
    public TheServlet() {
        // TODO Auto-generated constructor stub

           * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                    logger.info("PlaceBidServlet says hi!");

           * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
          protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                    // TODO Auto-generated method stub
 }//End of file TheServlet.java

*I used the JBoss log to get the global JINI string and placed into the servlet.*
 | java:global/FooBean/Foo!com.foo.ejb.FooRemote |
 | java:app/FooBean/Foo!com.foo.ejb.FooRemote |
 | java:module/Foo!com.foo.ejb.FooRemote |
 | java:jboss/exported/FooBean/Foo!com.foo.ejb.FooRemote |
 | java:global/FooBean/Foo!com.foo.ejb.FooLocal |
 | java:app/FooBean/Foo!com.foo.ejb.FooLocal |
 | java:module/Foo!com.foo.ejb.FooLocal |
 | java:global/FooBean/Foo!com.foo.ejb.Foo |
 | java:app/FooBean/Foo!com.foo.ejb.Foo |
 | java:module/Foo!com.foo.ejb.Foo |

*I am getting the following.*
Caused by: java.lang.NoClassDefFoundError: Lcom/foo/ejb/FooRemote;
Caused by: java.lang.ClassNotFoundException: com.foo.ejb.FooRemote

*This is JBoss version* 
JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
*So I am assuming this type of injection is supported. The test works fine when the client and ejb are in the same project/war but I want to separate them.  Does anybody see what I am doing wrong? Any help would be greatly appreciated.*

*Thanks, Art

Reply to this message by going to Community

Start a new discussion in EJB3 at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120911/175354d7/attachment-0001.html 

More information about the jboss-user mailing list