0

Hi I have 3 projects: EAR, EJB and (dynamic) WEB. I'm using eclipse and wildfly 10.x. Here's what I've got in EJB project:

package q.w.e;

public interface Inter {
    public String s();
}

and

package q.w.e;
public class Ert implements Inter {
    @Override
    public String s() {
        return "hik";
    }
}

Here's what I have in dynamic web project:

package local.bb.lab.servlets;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import q.w.e.*;

public class Home extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @EJB
    Inter ert;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/home.jsp").forward(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}

All very simple. I connected the projects using EAR. The compiler sees the package and classes but I'm having this error:

WFLYEJB0406: No EJB found with interface of type 'q.w.e.Inter' for binding local.bb.lab.servlets.Home/ert

I have no idea why it remains there. This must be some configuration problem but I connected them just as it was shown in tutorials(took literaly the same steps).

Charlie B
  • 303
  • 1
  • 4
  • 12

1 Answers1

0

In my opinion you need to know what the difference between @EJB and @Inject at first, you can check from this : link

Another thing is your code is not EJB that's why you cannot use @EJB annotation, you should use @Inject to dependency injection.

Coder ACJHP
  • 1,940
  • 1
  • 20
  • 34