开发者

Problems loading remote Interface with context.lookup

开发者 https://www.devze.com 2023-04-02 00:07 出处:网络
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 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 {
   ...
}

and I have the remote Interface

@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 ''

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.

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

<开发者_C百科;?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?

Thanks a lot and many greetings, Hauke

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 ) {

      }
   }


for Portable JNDI Syntax, the lookup name like this :

  1. java:global[/application name]/module name/enterprise bean name[/interface name]
  2. java:module/enterprise bean name/[interface name]
  3. java:app[/module name]/enterprise bean name[/interface name]

your can see more detail at http://java.sun.com/javaee/6/docs/tutorial/doc/gipjf.html#girgn

So for yoour code try

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号