根据EJB3.1规范:<module-name> is the name of the module in which the session bean is packaged. It defaults to the base name of the bundle with no filename extension, unless specified in the ejb-jar.xml deployment descriptor.
我在ejb.jar中做了如下配置:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<module-name>HelloWorldModule</module-name>
<enterprise-beans>
<session>
<ejb-name>HelloWorldBean</ejb-name>
<remote>com.leon.apps.HelloWorld</remote>
<ejb-class>com.leon.apps.HelloWorldBean</ejb-class>
<session-type>Stateless</session-type>
</session>
</enterprise-beans>
</ejb-jar>可是我在客户端用
HelloWorld h = (HelloWorld) context.lookup("java:global/HelloWorldModule/HelloWorldBean");
怎么都找不到,提示javax.naming.NameNotFoundException: HelloWorldModule
如果我不使用Deployment Description 这种方式,用Annotation是没什么问题,module-name默认为包名。
我对<display-name>和<module-name>搞得始终不太清楚,望高手指点一下。谢谢。
我使用的环境是eclipse+glassfish