使用context.lookup加载远程接口时出现问题 [英] Problems loading remote Interface with context.lookup

查看:222
本文介绍了使用context.lookup加载远程接口时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用过jboss 4.2.3 GA,并且一切正常(至少从客户端调用远程接口)。现在,我尝试使用Jboss 7.0.1 FINAL

I used to work with jboss 4.2.3 GA and there everything worked fine (at least calling the remote interface from the client side). Now I try to deploy that with Jboss 7.0.1 FINAL

我在服务器项目上拥有此类:

I have (on the server project) this class:

@Remote(ConfigurationHelperRemote.class)
@Local(ConfigurationHelperLocal.class)
@Stateless
public class ConfigurationHelper implements ConfigurationHelperRemote,  ConfigurationHelperLocal {
   ...
}

我有远程接口

@Remote
public interface ConfigurationHelperRemote {
  ...
}

现在我曾经借助这样的上下文从客户端调用远程接口:

Now I used to call the remote interface from the client side with the help of context like this:

configurationHelper = (ConfigurationHelperRemote) ctx.lookup("ear-1.0.0/ConfigurationHelper/remote");

但这不再起作用。现在我收到此错误消息

But this isn't working anymore. Now I get this error message

javax.naming.NameNotFoundException: Name 'ear-1.0.0' not found in context ''

我的耳朵文件名为 ear-1.0.0.ear ,内部的客户端称为 client-1.0.0.war ,服务器称为 server-1.0.0.jar

My ear file is called ear-1.0.0.ear and the client inside is called client-1.0.0.war and the server is called server-1.0.0.jar.

这是耳朵文件中application.xml的内容

This is the content of the application.xml inside the ear file

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
   <display-name>ear</display-name>
     <module>
      <web>
       <web-uri>client-1.0.0.war</web-uri>
       <context-root>/client</context-root>
     </web>
    </module>
   <module>
    <ejb>server-1.0.0.jar</ejb>
   </module>
</application>

我在哪里需要配置上下文名称?还是我做错了?

Where do I need to configure the context name? Or what I am doing wrong?

非常感谢,也有很多问候,
Hauke

Thanks a lot and many greetings, Hauke

PS 。::我只是打印出所有JNDI上下文信息,而数据库中只有数据源。我是这样做的:

PS.: I just printed out all JNDI Context Information, and there is only the datasource from the database. I did this:

      public static void showJndiContext( Context ctx, String name, String space )
   {
      if( null == name  ) name  = "";
      if( null == space ) space = "";
      try {
         NamingEnumeration<NameClassPair> en = ctx.list( name );
         while( en != null && en.hasMoreElements() ) {
            String delim = ( name.length() > 0 ) ? "/" : "";
            NameClassPair ncp = en.next();
            System.out.println( space + name + delim + ncp );
            if( space.length() < 40 )
               showJndiContext( ctx, ncp.getName(), "    " + space );
         }
      } catch( javax.naming.NamingException ex ) {

      }
   }


推荐答案

对于便携式JNDI语法,查找名称如下:

for Portable JNDI Syntax, the lookup name like this :


  1. java:global [/应用名称] /模块名称/企业Bean名称[/接口名称]

  2. java:module /企业Bean名称/ [接口名称]

  3. java:app [/模块名称] /企业bean名称[/接口名称]

您可以在 http://java.sun中查看更多详细信息.com / javaee / 6 / docs / tutorial / doc / gipjf.html#girgn

对于您的代码,请尝试

configurationHelper = (ConfigurationHelperRemote) ctx.lookup("java:global/ear-1.0.0/server-1.0.0/ConfigurationHelper");

我在代码中用于远程bean的这种格式...

this format I used in my code for a remote bean...

这篇关于使用context.lookup加载远程接口时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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