1 2 Previous Next 15 Replies Latest reply on Aug 27, 2012 5:38 PM by Wolfgang Knauf

    Problems with JBoss 7 and remote-interface lookup with context

    Hauke Gulich Newbie

       

      Hello everyone,

       

      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

       

      <?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?

       

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

           
      }
        
      }

       

       

       

      Thanks a lot and many greetings,

      Hauke


        • 1. Re: Problems with JBoss 7 and remote-interface lookup with context
          Wolfgang Knauf Master

          Hi,

           

          you might take a look at this page: https://issues.jboss.org/browse/AS7-1709

           

          it seems that tihs is just a "roadmap", so I hope that I am wrong, but it seems that JNDI lookup for remote EJBs is not possible currently: https://issues.jboss.org/browse/AS7-1338

           

          Best regards

           

          Wolfgang

          1 of 1 people found this helpful
          • 2. Re: Problems with JBoss 7 and remote-interface lookup with context
            Hauke Gulich Newbie

            Thanks Wolfgang for your information.

             

            If I get it right, this is not the right way to access the remote interface anymore?

             

            InitialContext ctx = new InitialContext();

            MyRemote bean = ctx.lookup("java:myserver1/myapp/myJar/OtherBean#MyRemote");

             

            This seems to be a work-around?

             

            What would be the correct way for Jboss 7?

             

            Thanks,

            Hauke

            • 3. Re: Problems with JBoss 7 and remote-interface lookup with context
              Radoslav Husar Master

              This is currently not implemented, we will have to wait for few weeks :-) otherwise your way of accessing them is correct as seen in AS7-1709.

               

              If you are wondering why its not implemented, its because the target was to provide complete EE6 Web Profile (which AS7 certified for) where the "EJB3 Lite" does not need to provide the remote access.

              • 4. Re: Problems with JBoss 7 and remote-interface lookup with context
                Hauke Gulich Newbie

                Hello,

                 

                is there no way to do that with

                 

                @Ejb

                 

                annotation at client side? I think the loading via context lookup (whatever why of lookup) is kind of complicated and if they changed something like the lookup function, the migrating from older project to jboss 7 is almost impossible (for hugh projects).

                 

                Sorry for my question again: Is that in AS7-1709 really the one and only way to access an ejb from the client side?

                 

                Thanks again and many greetings,

                Hauke

                • 5. Re: Problems with JBoss 7 and remote-interface lookup with context
                  Hauke Gulich Newbie

                  Hello agin,

                   

                  I am getting closer now, but I still need some help.

                  I looked around within the jmx console and found this:

                   

                  jbossJNDI.jpg

                  Inside the article (https://issues.jboss.org/browse/AS7-1709) it says:

                   

                   

                  {code}InitialContext ctx = new InitialContext();

                  MyRemote bean = ctx.lookup("java:myserver1/myapp/myjar/myBean#MyRemote");{code}

                   

                   

                  What makes me wondering is java:

                  If you look at the top of the screen you can see java: with only one entry (my database datasource)

                   

                  If you look at java:global you can see my remote and local interface which I want to load with the context.

                   

                  I also tried something like this:

                   

                  java:global:localhost:8080/ear-1.0.0/server-1.0.0/ConfigurationHelper#de.hauke.server.configuration.ConfigurationHelperRemote

                   

                  without any luck.

                   

                  Do I need to pass some paramters to

                   

                  {code}InitialContext ctx = new InitialContext();{code}

                   

                  ? Maybe I need to tell the context, in which it needs to look at.

                   

                  Because I always get this exception

                   

                   

                  {color:#f00}javax.naming.NameNotFoundException: Name 'ConfigurationHelperRemote' not found in context ''{color}

                   

                   

                   

                  and context '' seems to be empty. So Empty might be the default (java:) context !?

                   

                  Or do I need to set up the ejb in which context it should be visible? With some kind of annotation?

                   

                  Thanks a lot and greetings,

                  Hauke

                  • 6. Re: Problems with JBoss 7 and remote-interface lookup with context
                    jaikiran pai Master

                    Don't go by the JIRA description yet. Remote invocation on EJB is not yet supported and I would recommend that you wait for a few weeks before trying this out.

                    • 7. Re: Problems with JBoss 7 and remote-interface lookup with context
                      Hauke Gulich Newbie

                      Is there no way to access the ejb bean from the client at all?

                       

                      Not even with the @EJB annotation on client side?

                       

                      I am really confused because I thought using ejb's from the client application is a common way.

                      • 8. Re: Problems with JBoss 7 and remote-interface lookup with context
                        Radoslav Husar Master
                        I am really confused because I thought using ejb's from the client application is a common way.

                        Actually it may be not. REST and WebServices rule the world these days ;-)

                        • 9. Re: Problems with JBoss 7 and remote-interface lookup with context
                          Hauke Gulich Newbie

                          Radoslav Husar schrieb:

                           

                          I am really confused because I thought using ejb's from the client application is a common way.

                          Actually it may be not. REST and WebServices rule the world these days ;-)

                           

                          Thanks for the word WebServices. That brings a new light to the problem and might be a good solution for that problem!

                          Strange that those kind of feature is missing because I thought that is kind of important!

                           

                          Many greetings,

                          Hauke

                          • 10. Re: Problems with JBoss 7 and remote-interface lookup with context
                            Wolfgang Knauf Master

                            Hauke, if you are still interested in remote clients, take a look at this brand new mail found on the AS7 dev mailing list: http://lists.jboss.org/pipermail/jboss-as7-dev/2011-September/003772.html

                             

                            This should clarify the state of the remote client layer.

                             

                            Best regards

                             

                            Wolfgang

                            • 11. Re: Problems with JBoss 7 and remote-interface lookup with context
                              Hauke Gulich Newbie

                              Dear Wolfgang,

                               

                              thanks for the message.

                               

                              I figured out how it works for me. I just read the logfile and during deployment the following lines where written:

                               

                              java:global/ear-1.0.0/server-1.0.0/confighelper!de.hauke.server.configuration.ConfigurationHelperRemote

                              java:app/server-1.0.0/confighelper!de.hauke.server.configuration.ConfigurationHelperRemote

                              java:module/confighelper!de.hauke.server.configuration.ConfigurationHelperRemote

                              java:global/ear-1.0.0/server-1.0.0/confighelper!de.hauke.server.configuration.ConfigurationHelperLocal

                              java:app/server-1.0.0/confighelper!de.hauke.server.configuration.ConfigurationHelperLocal

                              java:module/confighelper!de.hauke.server.configuration.ConfigurationHelperLocal

                               

                              So I copy and pasted that and it works perfectly!

                               

                              Thanks for your support.

                               

                              Many greetings,

                              Hauke

                              • 12. Re: Problems with JBoss 7 and remote-interface lookup with context
                                Gary Quinn Newbie

                                I don't have the Container option in the front end, how do you enable it?

                                • 13. Re: Problems with JBoss 7 and remote-interface lookup with context
                                  Gary Quinn Newbie

                                  I still can't get mine to work.

                                   

                                  This is from my log file:

                                   

                                  13:08:53,436 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named DepartmentServiceImpl in deployment unit subdeployment "server.jar" of deployment "quinn_ear.ear" are as follows:

                                   

                                   

                                            java:global/quinn_ear/server/DepartmentServiceImpl!za.co.quinn.service.DepartmentService

                                            java:app/server/DepartmentServiceImpl!za.co.quinn.service.DepartmentService

                                            java:module/DepartmentServiceImpl!za.co.quinn.service.DepartmentService

                                            java:global/quinn_ear/server/DepartmentServiceImpl

                                            java:app/server/DepartmentServiceImpl

                                            java:module/DepartmentServiceImpl

                                   

                                  Here is my code:

                                   

                                  Hashtable props = new Hashtable();

                                  props.put("java.naming.factory.initial", "org.jboss.as.naming.InitialContextFactory");

                                  props.put("java.naming.provider.url", "jnp://localhost:1099");

                                   

                                   

                                  InitialContext initialContext = new InitialContext(props);

                                  DepartmentService bean = (DepartmentService)     initialContext.lookup("java:global/quinn_ear/server/DepartmentServiceImpl!za.co.quinn.service.DepartmentService");

                                   

                                  The exception is:

                                   

                                  javax.naming.NameNotFoundException: Name 'global' not found in context ''

                                  • 14. Re: Problems with JBoss 7 and remote-interface lookup with context
                                    dayse rivera Newbie

                                    I'm facing the same problem.

                                     

                                    I'm developing my first ejb 3 client on jboss 7.1. But, I can't make a lookup.
                                    After EJB deploy the following message is shown on console:

                                    11:48:33,718 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1- JNDI bindings for session bean named CalculatorBean in deployment unit subdeployment "EJB3_Chap02.jar" of deployment "TesteEar.ear" are as follows:

                                         java:global/TesteEar/EJB3_Chap02/CalculatorBean!calc.CalculatorRemote
                                         java:app/EJB3_Chap02/CalculatorBean!calc.CalculatorRemote
                                         java:module/CalculatorBean!calc.CalculatorRemote
                                         java:jboss/exported/TesteEar/EJB3_Chap02/CalculatorBean!calc.CalculatorRemote
                                         java:global/TesteEar/EJB3_Chap02/CalculatorBean
                                         java:app/EJB3_Chap02/CalculatorBean
                                         java:module/CalculatorBean


                                    I try to lookup as follow, but it isn't work:

                                    package calc.client;

                                    import java.util.Hashtable;

                                    import javax.naming.Context;
                                    import javax.naming.InitialContext;
                                    import javax.naming.NamingEnumeration;
                                    import javax.naming.NamingException;

                                    import calc.CalculatorRemote;

                                    public class CalculatorClient {
                                         private static CalculatorRemote remote;
                                         public static void main(String[] args) {
                                              try{
                                                   remote = lookupRemoteStatelessCalculator();
                                                             //context.lookup("EJB3_Chap02/" + CalculatorBean.class.getSimpleName() + "/remote");
                                                   System.out.println(remote.add(1, 1));
                                              }catch (Exception e) {
                                                   e.printStackTrace();
                                              }
                                         }

                                         private static CalculatorRemote lookupRemoteStatelessCalculator() throws NamingException {
                                             final Hashtable jndiProperties = new Hashtable();
                                             //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                                             jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                                             jndiProperties.put(Context.PROVIDER_URL, "remote://127.0.0.1:4447");

                                             //jndiProperties.put("remote.connection.default.username","dayserivera");
                                             //jndiProperties.put("remote.connection.default.password", "dayse");
                                             jndiProperties.put(Context.SECURITY_PRINCIPAL, "dayserivera");
                                             jndiProperties.put(Context.SECURITY_CREDENTIALS, "dayse");
                                             /*
                                             jndiProperties.put("endpoint.name", "client-endpoint");
                                             jndiProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
                                             jndiProperties.put("remote.connections", "default");
                                             jndiProperties.put("remote.connection.default.port", "4447");
                                             jndiProperties.put("remote.connection.default.host", "localhost");
                                             */
                                    jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
                                             jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
                                             jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

                                             //jndiProperties.put("jboss.naming.client.ejb.context", true);

                                             final Context context = new InitialContext(jndiProperties);
                                             NamingEnumeration<?> namingEnum = context.list("java");
                                             while(namingEnum.hasMoreElements()){
                                                  Object obj = namingEnum.nextElement();
                                                  System.out.println(obj);
                                             }

                                             System.out.println(context.lookup("ejb:TesteEar/EJB3_Chap02//CalculatorBean!calc.CalculatorRemote"));

                                             // The app name is the application name of the deployed EJBs. This is typically the ear name
                                             // without the .ear suffix. However, the application name could be overridden in the application.xml of the
                                             // EJB deployment on the server.
                                             // Since we haven't deployed the application as a .ear, the app name for us will be an empty string
                                             final String appName = "";
                                             // This is the module name of the deployed EJBs on the server. This is typically the jar name of the
                                             // EJB deployment, without the .jar suffix, but can be overridden via the ejb-jar.xml
                                             // In this example, we have deployed the EJBs in a jboss-as-ejb-remote-app.jar, so the module name is
                                             // jboss-as-ejb-remote-app
                                             final String moduleName = "EJB3_Chap02";
                                             // AS7 allows each deployment to have an (optional) distinct name. We haven't specified a distinct name for
                                             // our EJB deployment, so this is an empty string
                                             final String distinctName = "";
                                             // The EJB name which by default is the simple class name of the bean implementation class
                                             //final String beanName = CalculatorBean.class.getSimpleName();
                                             // the remote view fully qualified class name
                                             final String viewClassName = CalculatorRemote.class.getName();
                                             // let's do the lookup
                                             //return (CalculatorRemote) context.lookup("ejb:" + appName + "/" + beanName);
                                             //return (CalculatorRemote) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);
                                             return (CalculatorRemote) context.lookup("ejb:TesteEar/EJB3_Chap02//CalculatorBean!calc.CalculatorRemote");
                                         }

                                    }

                                    1 2 Previous Next