4 Replies Latest reply on Jan 27, 2014 4:57 AM by bruce L

    Where to put jndi.properties file in jBoss AS 7?

    Suchit kumar Newbie

      I am trying to make remote EJB invokation in JBoss AS 7 and I had gone through almost all the articles specified over here but still I am stuck. My Code sample goes like this...

       

      @Override

                 public boolean onEcho(Association as) {

                          String site = as.getRemoteAET();

                          logger.debug( String.format("Echo call from %s", site));

                          System.out.println("One........");

                          //Context context = null;

                    try

                    {

               

                              Properties jndiProperties = new Properties();

                              jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                              jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");

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

                              jndiProperties.put(Context.SECURITY_PRINCIPAL, "login");

                              jndiProperties.put(Context.SECURITY_CREDENTIALS, "password");

                              InitialContext context = new InitialContext( jndiProperties );

                    }

                    catch (NamingException e)

                    {

                      e.printStackTrace();

                    }

                          System.out.println("Two........");

                          return true;

                }

      *******************************************************************************************************************

       

      The error coming is like the InitialContextFactory cannot be instantiated. Thanks in advance.

        • 1. Re: Where to put jndi.properties file in jBoss AS 7?
          jaikiran pai Master

          Welcome to the forums!

           

          Please post the entire exception stacktrace as well as the exact version of the server you are using. What does your application packaging look like and where/when does this lookup happen?

          • 2. Re: Where to put jndi.properties file in jBoss AS 7?
            Suchit kumar Newbie

            Hi Jaikiran

            I am using jboss-as-dist-7.1.0.Final.

            The package goes like the most common way, thats like packages inside which I have all the classes. The session bean is being called from remote machine and the same session bean is calling the EJB to persist the data.

            stack trace I am not able to get it from the command prompt but I have attached a snapshot.snapshot.jpg

            • 3. Re: Where to put jndi.properties file in jBoss AS 7?
              Suchit kumar Newbie

              Hey guys thanks for all the help.....I resolved it on my own

              I put upboth jndi.properties and the jboss-ejb-client.properties

              with the values--

               

              #

              # jndi.properties

              #

              java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

              java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

              java.naming.provider.url=remote://localhost:4447

              java.naming.security.principal=remote

              java.naming.security.credentials=testpassword

               

              #

              # jboss-ejb-client.properties

              #

              remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

              remote.connections=default

              remote.connection.default.host=localhost

              remote.connection.default.port = 4447

              remote.connection.default.username=testuser

              remote.connection.default.password=testpassword

              remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

               

              kept these file in the root directory only under module above every other file.

               

              Kept the dependency of jboss-final.jar from maven repository into the pom file.

              and yes it feels really awesome!!!

              • 4. Re: Where to put jndi.properties file in jBoss AS 7?
                bruce L Newbie

                Hi,

                 

                I'm migrating my application from jboss 4.2.2 to jboss 7.1.1, facing lot of problems.

                 

                Overview:

                 

                I'm Using struts 1.1, EJB 2.1 using xdoclet 1.2.3 jars for generating the dependency files.(which is inevitable to use). I'm also having 2 dependent EAR (B.ear and C.ear)deployed in Jboss7/standalone/deployments. C.ear can able to start independently, and has EJB jars and war in it.. Also has a separate GUI for login. I'm having LDAP server for authenticating the users. Since B.ear has dependency over C.ear, so I did marked my dependencies in "jboss-deployment-structure.xml" in <dependencies> tag in B.ear.

                I've also changed my standalone-full.xml by configuring the datasources etc..

                 

                While starting up the jboss 7 server AS like this..

                 

                > standalone.bat --server-config:standalone-full.xml

                 

                I'm getting the below ERROR, and stopping the server post error.

                 

                11:31:32,042 ERROR [com.bk.bal.web.security.AuthCtextListener] (MSC service thread 1-8) javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Failed to setup EJB remote context]: javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Failed to setup EJB remote context]

                 

                    at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36) [jboss-remote-naming-1.0.2.Final.jar:1.0.2.Final]

                    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121) [jboss-remote-naming-1.0.2.Final.jar:1.0.2.Final]

                    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) [rt.jar:1.6.0_27]

                    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) [rt.jar:1.6.0_27]

                    at javax.naming.InitialContext.init(InitialContext.java:223) [rt.jar:1.6.0_27]

                    at javax.naming.InitialContext.<init>(InitialContext.java:197) [rt.jar:1.6.0_27]

                    at com.bk.bal.ejb.security.RemoveActiveSessionsScheduledJobUtil.lookupHome(RemoveActiveSessionsScheduledJobUtil.java:16) [60babel-ejb.jar:]

                    at com.bk.bal.babel.ejb.security.RemoveActiveSessionsScheduledJobUtil.getJBoss7Home(RemoveActiveSessionsScheduledJobUtil.java:60) [60babel-ejb.jar:]

                    at com.bk.bal.babel.web.security.AuthCtextListener.contextInitialized(AuthCtextListener.java:91) [classes:]

                    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_27]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_27]

                    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_27]

                 

                Caused by: java.lang.RuntimeException: Failed to setup EJB remote context

                    at org.jboss.naming.remote.client.InitialContextFactory.setupEjbContext(InitialContextFactory.java:438) [jboss-remote-naming-1.0.2.Final.jar:1.0.2.Final]

                    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:115) [jboss-remote-naming-1.0.2.Final.jar:1.0.2.Final]

                    ... 15 more

                 

                Caused by: java.lang.reflect.InvocationTargetException

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_27]

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_27]

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_27]

                    at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_27]

                    at org.jboss.naming.remote.client.InitialContextFactory.setupEjbContext(InitialContextFactory.java:420) [jboss-remote-naming-1.0.2.Final.jar:1.0.2.Final]

                    ... 16 more

                 

                Caused by: java.lang.SecurityException: EJB client context selector may not be changed

                    at org.jboss.ejb.client.EJBClientContext.setSelector(EJBClientContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

                    at org.jboss.naming.remote.client.ejb.RemoteNamingEjbClientContextSelector.setupSelector(RemoteNamingEjbClientContextSelector.java:18) [jboss-remote-naming-1.0.2.Final.jar:1.0.2.Final]

                    ... 21 more

                 

                Also, there is a external EJB ref call from one of the EJBs from B.ear files to C.ear.

                I've defined my ejb-external-ref in one of the bean class to generate the xml elements in jboss.xml and ejb-jar.xml by xdoclet.

                 

                @ejb.ejb-external-ref

                *    view-type="remote"

                *    jndi-name="ejb/c/UserFcad"

                *    ref-name="ejb/c/UserFcad"

                *    type="Session"

                *    home="com.bk.c.UserFcadRemoteHome"

                *    business="com.bk.c.UserFcadRemote"

                 

                After referring the forums, I changed the jndi-name and ref-name like this,..

                 

                jndi-name="ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome"

                ref-name="ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome"

                 

                which generates the respective xml elements in

                 

                --jboss.xml

                 

                <ejb-ref>

                            <ejb-ref-name>ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome</ejb-ref-name>

                            <jndi-name>ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome</jndi-name>

                         </ejb-ref>

                 

                --ejb-jar.xml

                 

                <session>

                ...

                 

                <ejb-ref >

                            <ejb-ref-name>ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome</ejb-ref-name>

                            <ejb-ref-type>Session</ejb-ref-type>

                            <home>com.bk.c.UserFcadRemoteHome</home>

                            <remote>com.bk.c.UserFcadRemote</remote>

                         </ejb-ref>

                 

                 

                # jboss-ejb-client.properties

                 

                endpoint.name=client-endpoint

                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.x1.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false

                remote.connection.default.username=bAdmin

                remote.connection.default.password=cimesra

                 

                # jndi.properties

                #

                java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

                java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

                jboss.naming.client.ejb.context=true

                java.naming.provider.url=remote://localhost:4447

                java.naming.security.principal=bAdmin

                java.naming.security.credentials=cimesra

                 

                 

                In console logs,

                 

                12:23:34,019 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.subunit."b.ear"."6b-ejb.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."b.ear"."6b-ejb.jar".INSTALL: Failed to process phase INSTALL of subdeployment "6b-ejb.jar" of deployment "b.ear"

                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_27]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_27]

                    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_27]

                 

                Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011058: Failed to install component AdmnMgr

                    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:100)

                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                    ... 5 more

                 

                Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014544: No EJB found with interface of type 'com.bk.c.UserFcadRemoteHome' for binding java:comp/env/ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome

                    at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:88)

                    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.processBindings(ComponentInstallProcessor.java:245)

                    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deployComponent(ComponentInstallProcessor.java:189)

                    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:93)

                    ... 6 more

                 

                Though, I've added only "ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome" in the jndi-name and ref-name in my facade bean class,

                 

                Jboss 7 is looking up the EJB like this and throwing error.

                 

                Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014544: No EJB found with interface of type 'com.bk.c.UserFcadRemoteHome' for binding java:comp/env/ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome

                 

                Why jboss is appending "java:comp/env/" in front of "ejb:C/24c/UserFcad!com.bk.c.UserFcadRemoteHome" which leads to ERROR.

                 

                Getting EJB Name not found exception while EJB lookups-  javax.naming.NamingException and  java.lang.RuntimeException: Failed to setup EJB remote context etc..

                also, want to know how to deploy my EARs in sequence order?

                I'm using Same JVM, and the EARs are also deployed in same deployments folder in Jboss 7 AS.

                So wonder is my remote calling is correct.

                 

                Any help is welcome.

                 

                Thanks,

                Bruce

                 

                Message was edited by: bruce L