Я новичок в Java EE.Недавно я работаю над проектом, использующим компонент без сохранения состояния, но я получил следующую ошибку
Bean:
@Stateless(mappedName = "FlightServiceBean")
public class FlightServiceBean {
public FlightServiceBean() {
}
// data
}
Servlet:
private FlightServiceBean fs = null;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PrintWriter out = response.getWriter();
out.println("The flights details servlet has been called ...");
try
{
Context context = new InitialContext();
fs = (FlightServiceBean) context.lookup("java:global/ejb1/FlightServiceBean!com.airline.service.FlightServiceBean");
// here where I got the exception
}
catch (NamingException e)
{
System.out.println("Naming Exception has occurred when trying to lookup the flightService EJB");
e.printStackTrace();
}
javax.naming.NamingException: не удалось выполнить поиск для 'java: global / ejb1 / FlightServiceBean! com.airline.service.FlightServiceBean' в SerialContext [myEnv = {java.naming.factory.initial = com.sun.enterprise.naming.impl.SerialInitContextFactjava.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs = com.sun.enterprise.naming} [Исключением корня является javax.naming.NameNotFoundException: ejb1]
![This is my project structure](https://i.stack.imgur.com/JFbgu.png)
Примечание: я использую Glassfish 5.0 и JDK 1.8.0