JBoss AS 6.0上的JNDI查找 [英] JNDI Lookup on JBoss AS 6.0

查看:128
本文介绍了JBoss AS 6.0上的JNDI查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JBoss 6.0 AS上的localhost上部署了一个应用程序。该应用程序有一个名为ExampleEJB的远程EJB bean。现在我正在尝试编写一个使用ExampleEJB的简单客户端应用程序。此客户端应用程序不会部署在任何应用程序服务器上。我们的想法是编写一个简单的Java SE客户端程序。我写了以下尝试执行查找:

I have an application deployed at localhost on JBoss 6.0 AS. This application has one remote EJB bean called ExampleEJB. Now I'm trying to code a simple client application that consumes ExampleEJB. This client application will not be deployed at any application server. The idea is to code a simple Java SE client program. I've written the following trying to perform a lookup:

Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"localhost:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

InitialContext ic = new InitialContext(env);

此时,我尝试了两种方法第一种方法是执行直接查找,例如examplified在Java EE 6教程( http://docs.oracle.com/javaee /6/tutorial/doc/gipjf.html ):

At this point, I've tried two approaches The first one was to perform a direct lookup like examplified at Java EE 6 Tutorial (http://docs.oracle.com/javaee/6/tutorial/doc/gipjf.html):

ExampleEJB exampleEJB = (ExampleEJB) ic.lookup("java:global/myApp/ExampleEJB");

第二次尝试是尝试获取JNDI上下文环境,然后从这个环境中获取所需的bean :

The second attempt was to try to get the JNDI context enviroment and then get the desired bean from this enviroment:

Context envContext  = (Context)ic.lookup("java:/comp/env");
envContext.lookup(...)

问题是我收到了以下异常:javax.naming.NameNotFoundException:global not bound和javax.naming.NameNotFoundException:comp not bound。我无法按要求执行查找。

The problem is that I'm receiving the following exceptions: "javax.naming.NameNotFoundException: global not bound" and "javax.naming.NameNotFoundException: comp not bound" respectively. I'm unable to perform the lookup as desired.

有人有线索吗?

推荐答案

如果您正在使用 java:global / ,然后JNDI名称应如下所示:

If you are using java:global/, then the JNDI name should look like this:

java:global/<application>/<module>/<component>

java:global/<ear>/<ejb-jar>/<ejb-name>

其中 ear 是.ear文件的名称,而 ejb-jar EJB .jar文件的名称。

where ear is the name of the .ear file, and ejb-jar the name of the EJB .jar file.

如果您同时拥有本地和远程接口,使用此方案可以有所不同:

If you have both a local and a remote interface, you can differ using this scheme:

java:global/<ear>/<ejb-jar>/<ejb-name>!<interface>

其中接口包含包和接口名称(例如: abcExampleEJBRemoteIfc )。

where the interface contains the package and the interface name (example: a.b.c.ExampleEJBRemoteIfc).

所以在您的设置中:如果 myApp.ear 包含 myEjb.jar ,其中包含一个名为的ExampleEJB ,然后尝试这个JNDI名称:

So in your setup: If myApp.ear contains myEjb.jar which contains an EJB whose name is ExampleEJB, then try this JNDI name:

java:global/myApp/myEjb/ExampleEJB

java:global/myApp/myEjb/ExampleEJB!a.b.c.ExampleEJBRemoteIfc






无论如何,仔细检查JMX控制台中的JNDI名称:


Anyway, double check the JNDI name(s) in the JMX console:

http://localhost:8080/jmx-console/




  1. 点击服务= JNDIView

  2. 操作列表:单击调用按钮

  3. 在该页面中按EJB名称搜索

  1. Click Service=JNDIView
  2. Operation list: Click invoke button
  3. Search in that page by the EJB name






至于 comp / env 全球 java:comp / env和java:global 之间的关系是什么


As for comp/env vs. global: What is the relationship between java:comp/env and java:global

这篇关于JBoss AS 6.0上的JNDI查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆