我在 Eclipse 中定义了两个项目。其中一个是 EJB(3.0) 项目,另一个是动态 Web 项目。
我已经定义了一个名为 LoginAuthenticator 的无状态会话 bean,并为它创建了两个本地和远程接口。在我的 EJB 项目中,我将 JNDI.properties 文件定义为
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099
我能够在 JBoss 5.0.0 上部署 jar 文件 部署后我在控制台上得到以下输出
LoginAuthenticator/remote - EJB3.x Default Remote Business Interface
LoginAuthenticator/remote-com.SR.enterprise.session.LoginAuthenticatorRemote - EJB3.x Remote Business Interface
LoginAuthenticator/local - EJB3.x Default Local Business Interface
LoginAuthenticator/local-com.SR.enterprise.session.LoginAuthenticatorLocal - EJB3.x Local Business Interface
现在,我从另一个 Web 项目中定义了一个动作类 LoginAction,它将访问我的会话 bean 的公开方法。初始上下文创建为
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(javax.naming.Context.PROVIDER_URL,"jnp://localhost:1099");
props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
我将远程方法称为
LoginAuthenticatorRemote loginAuthenticator = (LoginAuthenticatorRemote) context.lookup("LoginAuthenticator/remote");
当我在 Tomcat 6.0 上运行第二个项目时,我收到以下错误消息
javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.SocketException: Permission denied: connect]]]
service=Naming 下 jmx-console 中的端口值为 1099 service=Naming 下 jmx-console 中的 RmiPort 值为 1098 service=Nameing 下 jmx-console 中的 RmiBindAddress 和 BindAddress 都是 127.0.0.1
我收到错误的原因可能是什么?我还应该为此配置什么?任何帮助将不胜感激。