当我尝试访问名为BookingServlet
严重:抓住异常 javax.naming.NamingException:查找失败的' java:global / it.volaconnoi_VolaConNoi_webapp-ear_ear_1.0-SNAPSHOT / it.volaconnoi_VolaConNoi_webapp-ejb_ejb_1.0-SNAPSHOT / BookingBean!it.volaconnoi.logic.BookingBeanInterface'在SerialContext中[myEnv = {java.naming.factory.initial = com.sun.enterprise.naming.impl.SerialInitContextFactory,java.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs = com.sun.enterprise.naming} [根异常是javax.naming.NameNotFoundException:it.volaconnoi_VolaConNoi_webapp-ear_ear_1.0-SNAPSHOT]
这是截图
项目已正确部署,但我不明白为什么会收到此错误。你有什么建议吗?
正如您所看到的那样,预订servlet就在其位置
修改
BookingBeanInterface bookingBean = lookupBookingBeanLocal();
private BookingBeanInterface lookupBookingBeanLocal() {
try {
Context c = new InitialContext();
return (BookingBeanInterface) c.lookup("java:global/it.volaconnoi_volaconnoi-webapp-ear_ear_1.0-SNAPSHOT/it.volaconnoi_volaconnoi-webapp-ejb_ejb_1.0-SNAPSHOT/BookingBean!it.volaconnoi.logic.BookingBeanInterface");
} catch (NamingException ne) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
throw new RuntimeException(ne);
}
}
答案 0 :(得分:0)
真的没有足够的描述,你应该描述你的类BookingBean
所在的位置,以及它在JNDI中注册的方式。但是如果我们假设注册是正确的,您可以尝试使用以下字符串查找它:
c.lookup("java:app/BookingBean/it.volaconnoi.logic.BookingBeanInterface");
点击此处查看更多说明:http://docs.oracle.com/javaee/6/tutorial/doc/gipjf.html