1 2 Previous Next 18 Replies Latest reply on Feb 22, 2012 5:25 AM by jaikiran

    JBoss 7 Remote JNDI

    nnanda

      Hi Team,

       

      Our project has some use cases wherein the application puts some data into a remote HornetQ queue. This whole set up is working fine in JBoss 5.1. Now, we are having a plan to migrate to JBoss 7.1. But we are blocked by the JBoss 7.1 remote JNDI limitation (explained in the JIRA https://issues.jboss.org/browse/AS7-1338).

       

      I know Jaikiran has explained invoking remote EJB in https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

       

      But this document is very specific to EJB lookups. And the whole big document does not explain anything to fill the blanks as shown below:

       

      jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "");

      jndiProperties.put(Context.URL_PKG_PREFIXES, "");

      jndiProperties.put(Context.PROVIDER_URL, "");

       

      What should be put against these values? Can anyone explain this?

       

      We are right now testing our migration using JBos 7.1 CR1. But as per JIRA, the feature of remote JNDI lookup will be available in JBoss 7.1 Final. I am totally confused what is going on in this thread? And I am not able to get a clear roadmap from JBoss on this feature release.

       

      Appreaciate any help on this.

       

      Thanks,

      Niranjan

        • 1. Re: JBoss 7 Remote JNDI
          jaikiran

          NIranjan Nanda wrote:

           

           

          But this document is very specific to EJB lookups.

          That's correct.

           

           

          NIranjan Nanda wrote:

           

          And the whole big document does not explain anything to fill the blanks as shown below:

           

          jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "");

          jndiProperties.put(Context.URL_PKG_PREFIXES, "");

          jndiProperties.put(Context.PROVIDER_URL, "");

           

          What should be put against these values? Can anyone explain this?

          It does show what value to use for Context.URL_PKG_PREFIXES. The rest of the 2 properties are not required for EJB lookups and hence not set.

           

           

          NIranjan Nanda wrote:

          We are right now testing our migration using JBos 7.1 CR1. But as per JIRA, the feature of remote JNDI lookup will be available in JBoss 7.1 Final. I am totally confused what is going on in this thread? And I am not able to get a clear roadmap from JBoss on this feature release.

           

          Currently except for EJB lookups and invocation from a remote client, nothing else is accessible via JNDI from a remote client. Like the JIRA says, the plan is to make available access to JNDI from a remote client in 7.1.0.Final. That's a clear enough roadmap, IMO.

          • 2. Re: JBoss 7 Remote JNDI
            paata

            hello  jaikiran pai                       

            I have the same problem.

             

            Me Test Project looks like :

             

            1. Remote EJB Interface:

             

            @Remote
            public interface MySingletonBeanRemote {
                public void addItem(String key, String value);
                public String getItem(String key);
            }
            

             

            2. Implementation :

             

            @Singleton
            @Remote(MySingletonBeanRemote.class)
            @Startup
            public class MySingletonBean implements MySingletonBeanRemote {
            
                /**
                 * Default constructor.
                 */
                public MySingletonBean() {
                    System.out.println("MySingletonBean Constructor");
                }
            
                @PostConstruct
                public void startBean() {
                    System.out.println("startBean();");
                }
            
                public void addItem(String key, String value) {
                    System.out.println("addItem();");
                }
            
                public String getItem(String key) {
                    System.out.println("getItem(String key);");
                    return null;
                }
            }
            

             

             

            My JBoss Server logs :

             

            16:30:19,786 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named MySingletonBean in deployment unit deployment "MyEjb31.jar" are as follows:
            
                    java:global/MyEjb31/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanLocal
                    java:app/MyEjb31/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanLocal
                    java:module/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanLocal
                    java:global/MyEjb31/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanRemote
                    java:app/MyEjb31/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanRemote
                    java:module/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanRemote
            
            16:30:19,877 INFO  [stdout] (MSC service thread 1-3) MySingletonBean Constructor
            16:30:19,878 INFO  [stdout] (MSC service thread 1-3) startBean();
            16:30:19,929 INFO  [org.jboss.as.server] (management-handler-threads - 26) JBAS018565: Replaced deployment "MyEjb31.jar" with deployment "MyEjb31.jar"
            
            

             

             

            2. Test Remote Client

             

             

            public class TestMain {
                public static void main(String[] args) {
                    try {
                        Properties jndiProps = new Properties();
                        //jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, "");
                        jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                        jndiProps.setProperty(Context.PROVIDER_URL, "127.0.0.1:4447");
            
                        InitialContext ctx = new InitialContext(jndiProps);
                        MySingletonBeanRemote remote = (MySingletonBeanRemote) ctx.lookup("ejb:app/MyEjb31/MySingletonBean!com.magticom.billing.newb.server.beans.MySingletonBeanRemote");
                        
                        remote.addItem("Paata", "Lominadze");
                        System.out.println("Result = " + remote.getItem("Paata"));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            

             

            I have an error :

             

            javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
                at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
                at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
                at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
                at javax.naming.InitialContext.lookup(InitialContext.java:411)
                at com.magticom.newb.test.TestMain.main(TestMain.java:19)
            

             

             

             

            Did I miss something ???? Is here anything incorrect ???

             

             

            ________________________

            Regards,

            Paata Lominadze.

            • 3. Re: JBoss 7 Remote JNDI
              jaikiran

              I'm heading out and haven't paid much attention, but what happens if you remove this:

               

              jndiProps.setProperty(Context.PROVIDER_URL, "127.0.0.1:4447");

               

              from that client code? Does it work?

              • 4. Re: JBoss 7 Remote JNDI
                nnanda

                Paata,

                 

                I think what you are missing is the jboss-ejb-client.properties in your classpath. If you go through the document Jaikiran has posted, he clearly explains this file. This is a new file which is required with JBoss7. Basically you do not need to specify following in while setting up the properties:

                 

                jndiProps.setProperty(Context.PROVIDER_URL, "127.0.0.1:4447");

                 

                If you read the document, this information is provided in the jboss-ejb-client.properties file. So, remove this from your client code and put that properties file in your classpath. It should work.

                 

                @Jaikiran,

                 

                I still think its a little confusing for all JBoss users on this change. This change of "how to connect to remote JNDI server" is now adding a new learning curve to all JBoss and JavaEE users. EJBs are now treated as first class citizen in JBoss (why? because it provides a special mechanism to connect remote EJBs; and for other remote resources the mechanism is different). Earlier it used to be same for all kinds of JNDI-bound resources.

                 

                And I do not really understand how come remote EJB lookups do not need initial context factory whereas EJBs are remote resources and bound to a JNDI tree. Howcome other resources (like Queues/Topics) need an initial context factory to be explicitly set? I believe setting initial context factory is mandatory while creating InitialContext class.

                 

                I hope such things will be clarified once JBoss 7.1 Final is released for GA.

                 

                Thanks,

                Niranjan

                • 5. Re: JBoss 7 Remote JNDI
                  jaikiran

                  NIranjan Nanda wrote:

                   

                  @Jaikiran,

                   

                  I still think its a little confusing for all JBoss users on this change.

                  I agree. It's going to take a bit of time to understand these changes and once https://issues.jboss.org/browse/AS7-1338 is resolved, I plan to write up some documentation which might help clear things.

                   

                   

                  NIranjan Nanda wrote:

                   

                  This change of "how to connect to remote JNDI server" is now adding a new learning curve to all JBoss and JavaEE users. EJBs are now treated as first class citizen in JBoss (why? because it provides a special mechanism to connect remote EJBs; and for other remote resources the mechanism is different). Earlier it used to be same for all kinds of JNDI-bound resources.

                   

                  This thread might help in providing some context http://community.jboss.org/thread/174414?tstart=0

                   

                   

                  NIranjan Nanda wrote:

                  And I do not really understand how come remote EJB lookups do not need initial context factory whereas EJBs are remote resources and bound to a JNDI tree. Howcome other resources (like Queues/Topics) need an initial context factory to be explicitly set? I believe setting initial context factory is mandatory while creating InitialContext class.

                   

                  The initial context factory isn't required because we register a URLContextFactory for the ejb: URL prefix. The code:

                   

                  jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                   

                  Is what does it. In the presence of a URLContextFactory and lookups for ejb: namespace won't require the InitialContextFactory being set. The reason that the other lookups like queue/topic (which by the way, aren't yet supported in AS7) require the initial context factory is because we do npt set any URLContextFactory for those and those do not (yet) use any specific JNDI namespace prefix.

                   

                  Overall, it all depends on how we implement AS7-1338. I haven't yet thought about some of the requirements raised in that JIRA, but will get to it soon.

                  • 6. Re: JBoss 7 Remote JNDI
                    ktnagel

                    Hello Jaikiran,

                     

                    let me put the question differently (I have a similar problem):

                     

                    which JAR should we compile aginst as remote JNDI client?

                     

                    The module.xml file in

                    (jboss-as7-beta)\build\target\jboss-as-7.1.0.CR1-SNAPSHOT\modules\javax\api\main

                     

                    contains

                     

                    <module xmlns="urn:jboss:module:1.1" name="javax.api">

                        <dependencies>

                            <system export="true">

                                <paths>

                                    ....

                                    <path name="javax/naming"/>

                                    <path name="javax/naming/directory"/>

                                    <path name="javax/naming/event"/>

                                    <path name="javax/naming/ldap"/>

                                    <path name="javax/naming/spi"/>

                    ...

                     

                    but there seems no implementation JAR file to compile the client against.

                    (For the other APIs there is)

                     

                    Regards from Germany

                    Thomas

                    • 7. Re: JBoss 7 Remote JNDI
                      jaikiran

                      Thomas Nagel wrote:

                       

                      Hello Jaikiran,

                       

                      let me put the question differently (I have a similar problem):

                       

                      which JAR should we compile aginst as remote JNDI client?

                      The article https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI has a section (in the end) which lists the jars you need for a remote client, on the client classpath.

                       

                      P.S: For 7.1.0.Final we are planning to have just one client jar.

                      • 8. Re: JBoss 7 Remote JNDI
                        ktnagel

                        Hello Jaikiran,

                        thank you for your kind reply. And sorry for bothering you, but there seems something missing.

                         

                        I had already read that document you named.

                        The archives listed are                                                   contains packages:

                         

                        jboss-transaction-api_1.1_spec-1.0.0.Final.jar        javax.transaction

                        jboss-ejb-api_3.1_spec-1.0.1.Final.jar                       javax.ejb

                        jboss-ejb-client-1.0.0.Beta9.jar                                    org.jboss.ejb.client

                        jboss-marshalling-1.3.4.GA.jar                                    org.jboss.mashalling

                        xnio-api-3.0.0.CR5.jar                                                    org.xnio

                        jboss-remoting-3.2.0.CR6.jar                                      org.jboss.remoting3

                        jboss-logging-3.1.0.CR2.jar                                         org.jboss.logging

                        xnio-nio-3.0.0.CR5.jar                                                    org.xnio.nio

                        jboss-sasl-1.0.0.Beta9.jar                                             org.jboss.sasl

                        jboss-marshalling-river-1.3.4.GA.jar                          org.jboss.marshalling.river

                         

                        in an annex the following was added:

                        jboss-jacc-api_1.4_spec-1.0.1.Final.jar                    javax.security.jacc

                         

                         

                        the packages "javax.naming" are stated to be contained in javax.api, so i thought it should be provided in one of the org.jboss jars, but none of the JARs in the server modules path contained them.

                         

                         

                        Regards, and thanks for your patience,

                        Thomas

                        • 9. Re: JBoss 7 Remote JNDI
                          jaikiran

                          Thomas Nagel wrote:

                           

                           

                           

                          the packages "javax.naming" are stated to be contained in javax.api, so i thought it should be provided in one of the org.jboss jars, but none of the JARs in the server modules path contained them.

                           

                          Actually there are 2 aspects to a remote client server communication. The server side (in this case AS7) is backed by JBoss Modules for classloading and uses the module repository (found under JBOSS_HOME/modules folder) for locating the jars for classloading. So the javax.api "module" (and other such "modules") are applicable only on the server side.

                           

                          On the remote client side you don't have module classloading (in almost all cases, currently). The classloading is done by the Java implementation which expects the jars to be in the "classpath". So those list of jars that are mentioned in that article, are the ones which need to be on the classpath. As for the javax.naming.* classes, those are provided by the Java Runtime Environment (and are available in the rt.jar under your JRE installation). So you don't have to add any jar for those classes.

                          • 10. Re: JBoss 7 Remote JNDI
                            ktnagel

                            Hello Jaikiran,

                            thank you for your kind reply. I have now taken the quickstart/ejb-remote sample as a starting place, and it works better. I can access an EJB 2.1 Session Bean from remote then (although only through reflection so far).

                             

                            I have seen though, that there is a difference in documentation between the above mentioned URL-prefix "ejb:" and the documentation stating it would be "java:global/...", "java:module/..." or "java:app/...". I have tried several veriations, and so far i could only get the "ejb:" naming to work.

                             

                            Oh, btw, is this different between a remote client and a local client (say, a session bean accessing another session bean)?

                             

                            Regards,

                            Thomas

                            • 11. Re: JBoss 7 Remote JNDI
                              jaikiran

                              Thomas Nagel wrote:

                               

                              Hello Jaikiran,

                              thank you for your kind reply. I have now taken the quickstart/ejb-remote sample as a starting place, and it works better. I can access an EJB 2.1 Session Bean from remote then (although only through reflection so far).

                               

                              You don't need reflection for that. Are you running into some problem trying to look it up? What does your code look like?

                               

                               

                              Thomas Nagel wrote:

                               

                              I have seen though, that there is a difference in documentation between the above mentioned URL-prefix "ejb:" and the documentation stating it would be "java:global/...", "java:module/..." or "java:app/...". I have tried several veriations, and so far i could only get the "ejb:" naming to work.

                              If you are in the same server JVM as the deployed beans, then you can use java:global, java:module, java:app namespaces in the right context. However if you are in a different JVM than the deployed beans, then you use the JBoss specific ejb: namespace.

                              • 12. Re: JBoss 7 Remote JNDI
                                paata

                                hello jaikiran

                                Sorry For my misunderstanding , but i can't resolve this problem yet.

                                I'll try to explain my case again.

                                 

                                My Env :

                                1. OS :

                                 

                                paata@paatal:~> lsb_release -a
                                Distributor ID: SUSE LINUX
                                Description:    openSUSE 11.3 (i586)
                                Release:        11.3
                                Codename:       n/a
                                

                                 

                                2. Java :

                                 

                                 

                                paata@paatal:~> java -version
                                java version "1.7.0_02"
                                Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
                                Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode)
                                

                                 

                                3. JBoss AS :

                                 

                                 

                                jboss-as-7.1.0.CR1b
                                

                                 

                                 

                                Here is my example

                                 

                                1. My Remote EJB Interface :

                                 

                                 

                                @Remote
                                public interface TestSessRemote {
                                    public void addItem(String key, String value);
                                    public String getItem(String key);
                                }
                                

                                 

                                 

                                2. Implementation :

                                 

                                 

                                @Singleton
                                @Remote(TestSessRemote.class)
                                @Startup
                                public class TestSessBean implements TestSessRemote {
                                
                                    /**
                                     * Default constructor.
                                     */
                                    public TestSessBean() {
                                        System.out.println("MySingletonBean Constructor ... ");
                                    }
                                
                                    @PostConstruct
                                    public void startBean() {
                                        System.out.println("startBean();");
                                    }
                                
                                    public void addItem(String key, String value) {
                                        System.out.println("addItem();");
                                    }
                                
                                    public String getItem(String key) {
                                        System.out.println("getItem(String key);");
                                        return null;
                                    }
                                }
                                

                                 

                                 

                                3. JBoss App. Log After Deployment :

                                 

                                 

                                paata@paatal:~/InstalledPrograms/JBossAS/jboss-as-7.1.0.CR1b/bin> ./standalone.sh
                                =========================================================================
                                
                                  JBoss Bootstrap Environment
                                
                                  JBOSS_HOME: /home/paata/InstalledPrograms/JBossAS/jboss-as-7.1.0.CR1b
                                
                                  JAVA: /home/paata/InstalledPrograms/JDK/jdk1.7.0_02/bin/java
                                
                                  JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
                                
                                =========================================================================
                                
                                23:21:49,088 INFO  [org.jboss.modules] JBoss Modules version 1.1.0.CR6
                                23:21:49,812 INFO  [org.jboss.msc] JBoss MSC version 1.0.1.GA
                                23:21:49,911 INFO  [org.jboss.as] JBoss AS 7.1.0.CR1b "Flux Capacitor" starting
                                23:21:52,499 INFO  [org.xnio] XNIO Version 3.0.0.CR7
                                23:21:52,501 INFO  [org.jboss.as] Creating http management service using  socket-binding (management-http)
                                23:21:52,579 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.0.CR7
                                23:21:52,626 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.0.CR8
                                23:21:52,664 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
                                23:21:52,754 INFO  [org.jboss.as.clustering] (ServerService Thread Pool -- 30) JBAS010300: Activating Infinispan subsystem.
                                23:21:52,832 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
                                23:21:52,881 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) Activating Security Subsystem
                                23:21:52,976 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
                                23:21:53,032 INFO  [org.jboss.as.security] (MSC service thread 1-3) Picketbox version=4.0.6.Beta2
                                23:21:53,043 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011910: Activating OSGi Subsystem
                                23:21:53,459 INFO  [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.6.Final)
                                23:21:53,488 INFO  [org.jboss.as.naming] (MSC service thread 1-3) JBAS011802: Starting Naming Service
                                23:21:53,545 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 26) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
                                23:21:53,757 INFO  [org.jboss.as.jaxr] (MSC service thread 1-3) Binding JAXR ConnectionFactory: java:jboss/jaxr/ConnectionFactory
                                23:21:53,862 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
                                23:21:54,075 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) Listening on /127.0.0.1:4447
                                23:21:54,117 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - Stack CXF Server 4.0.0.GA
                                23:21:55,410 INFO  [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
                                23:21:56,638 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
                                23:21:56,757 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) Listening on /127.0.0.1:9999
                                23:21:56,815 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "MyEjb31.jar"
                                23:21:56,860 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /home/paata/InstalledPrograms/JBossAS/jboss-as-7.1.0.CR1b/standalone/deployments
                                23:21:57,300 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named TestSessBean in deployment unit deployment "MyEjb31.jar" are as follows:
                                
                                        java:global/MyEjb31/TestSessBean!com.magticom.billing.newb.server.beans.TestSessRemote
                                        java:app/MyEjb31/TestSessBean!com.magticom.billing.newb.server.beans.TestSessRemote
                                        java:module/TestSessBean!com.magticom.billing.newb.server.beans.TestSessRemote
                                        java:global/MyEjb31/TestSessBean
                                        java:app/MyEjb31/TestSessBean
                                        java:module/TestSessBean
                                
                                23:21:57,915 INFO  [stdout] (MSC service thread 1-2) MySingletonBean Constructor ... 
                                23:21:57,915 INFO  [stdout] (MSC service thread 1-2) startBean();
                                23:21:57,954 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "MyEjb31.jar"
                                23:21:57,972 INFO  [org.jboss.as] (Controller Boot Thread) JBoss AS 7.1.0.CR1b "Flux Capacitor" started in 9264ms - Started 165 of 237 services (70 services are passive or on-demand)
                                

                                 

                                 

                                 

                                Now My Client Project (I Use Eclipse - eclipse-jee-indigo-SR1 for development)

                                 

                                1. Client Project Library :

                                 

                                jboss-transaction-api_1.1_spec-1.0.0.Final.jar
                                jboss-ejb-api_3.1_spec-1.0.1.Final.jar
                                jboss-ejb-client-1.0.0.Beta11.jar
                                jboss-marshalling-1.3.4.GA.jar
                                xnio-api-3.0.0.CR7.jar
                                jboss-remoting-3.2.0.CR8.jar
                                jboss-logging-3.1.0.CR2.jar
                                xnio-nio-3.0.0.CR7.jar
                                jboss-sasl-1.0.0.Beta9.jar
                                jboss-marshalling-river-1.3.4.GA.jar
                                jboss-logmanager-1.2.0.GA.jar
                                log4j-1.2.16.jar
                                

                                 

                                2. Client Project screen looks like :

                                JBClientScreen.jpeg

                                 

                                 

                                3. I place jboss-ejb-client.properties everywhere . (becaouse I don't know where to place it), I didn't understant what means "put it on classpath." also I add Program and VM arguments into Eclipse->Run Congfiguration-> Argument :

                                 

                                 

                                -Djboss.ejb.client.properties.file.path=/home/paata/workspaceGWT/MyEjb31Client/jboss-ejb-client.properties
                                

                                 

                                 

                                remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
                                
                                remote.connections=default
                                
                                remote.connection.default.host=127.0.0.1
                                remote.connection.default.port=4447
                                remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
                                
                                remote.connection.two.host=127.0.0.1
                                remote.connection.two.port=4447
                                remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
                                

                                 

                                4. TestMain Class :

                                 

                                 

                                public class TestMain {
                                    @SuppressWarnings("rawtypes")
                                    public static void main(String[] args) {
                                        try {
                                            Properties jndiProps = new Properties();
                                            jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                                            InitialContext ctx = new InitialContext(jndiProps);
                                
                                            NamingEnumeration enumeration = ctx.list("");
                                            while (enumeration.hasMoreElements()) {
                                                Object object = (Object) enumeration.nextElement();
                                                System.out.println("Class Name : "
                                                        + object.getClass().getSimpleName());
                                            }
                                
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }
                                

                                 

                                 

                                But despite all I got the same error when run TestMain class :

                                 

                                 

                                javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
                                    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
                                    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
                                    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
                                    at javax.naming.InitialContext.list(InitialContext.java:455)
                                    at com.magticom.newb.test.TestMain.main(TestMain.java:17)
                                

                                 

                                what is problem or incorrect here ?

                                How I can add jboss-ejb-client.properties  file  into Client project classpath ???

                                 

                                 

                                 

                                Thank you again,

                                 

                                Regards,

                                Paata Lominadze.

                                • 13. Re: JBoss 7 Remote JNDI
                                  jaikiran

                                  Your client application is trying to list the contents of the JNDI. That won't work. The support is only available to lookup ejb: namespace JNDI names from the client side. The beans aren't really bound on the client side JNDI so trying to list them won't work.

                                  • 14. Re: JBoss 7 Remote JNDI
                                    paata

                                    Thank you very much jaikiran . Now it works.

                                     

                                    Working TestMain Class Code :

                                     

                                     

                                    public class TestMain {
                                              public static void main(String[] args) {
                                                        try {
                                                                  Properties jndiProps = new Properties();
                                                                  jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                                                                  InitialContext ctx = new InitialContext(jndiProps); 
                                                                  TestSessRemote remote = (TestSessRemote) ctx.lookup("ejb:/MyEjb31/TestSessBean!com.magticom.billing.newb.server.beans.TestSessRemote");
                                                                  remote.addItem("Paata", "Lominadze");
                                                                  remote.getItem("Paata");
                                                        } catch (Exception e) {
                                                                  e.printStackTrace();
                                                        }
                                              }
                                    }
                                    
                                    

                                     

                                     

                                    Regards,

                                    Paata Lominadze.

                                    1 2 Previous Next