I'm new in Intellij IDEA and I created a test Java EE project in it. First of all in New Project I selected Java Enterprise (Java JDK 7) and added the additional Libraries:
- Web Application (3.1)
- EJB: Enterprise Java Beans (3.2 without ejb-jar.xml)
- Java EE Application (Java EE 7)
The app created successfully. Then I created the Stateless Java Class:
package test.server;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
@Stateless(name = "TestClientEJB")
@LocalBean
public class TestClientBean {
public TestClientBean() {
}
public String getHello() {
return "Hello EJB from Intellij";
}
}
and after it created Servlet:
package test.client;
import test.server.TestClientBean;
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 java.io.IOException;
import java.io.PrintWriter;
@WebServlet(name = "ClientServlet")
public class ClientServlet extends HttpServlet {
@EJB
TestClientBean testClientBean;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.print(testClientBean.getHello());
}
}
As a Application Server I use WildFly 8.1 Final. I setup it with EAR Artifact and it give the URL as:
http://localhost:8080/EJBTestWeb/
when I run it in browser, it show me what I write in index.jsp. but when I write type
http://localhost:8080/EJBTestWeb/ClientServlet
it show me Not Found message. where is the problem? All needed Jars I downloaded
It's worked when in Servlet I changed
to