8 Replies Latest reply on May 16, 2011 5:24 PM by Nicklas Karlsson

    Setting global JNDI naming policy

    Nicklas Karlsson Master

      Hi

       

      I've understood that org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JavaEE6JndiBindingPolicy could be used in ejb3-deployers-jboss-beans.xml for achieving a global jndi naming policy for AS 6. Can anyone fill in the details? I only see the ejb3-deployers-jboss-beans.xml the processor that adds annotations to beans from jboss.xml.

       

      I'm trying to get around the problem where Foo.war and Foo2.war conflict with EJB namings in the same instance...

        • 1. Setting global JNDI naming policy
          jaikiran pai Master

          The jboss.xml allows a jndi-binding-policy element (either at the deployment level or per bean level) to specify the fully quailified name of the class implementing the DefaultJndiBindingPolicy interface. Let us know if you need any more details on this one.

          • 2. Re: Setting global JNDI naming policy
            Nicklas Karlsson Master

            I added a jboss.xml like

             

            <?xml version="1.0" encoding="UTF-8"?>

            <jboss xmlns="http://www.jboss.com/xml/ns/javaee"

                      xmlns:jee="http://java.sun.com/xml/ns/javaee"

                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                      xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"

                      version="5.0">

                      <jndi-binding-policy>org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JavaEE6JndiBindingPolicy</jndi-binding-policy>

            </jboss>

             

            (to both WEB-INF and classpath META-INF in my .war since I wasn't sure where it's supposed to go)

             

            but I still get the binding errors. I thought I read in some JIRA that the JavaEE6JNDIBP would already *be* the default, is there some other policy you could recommend?

             

            Message was edited by: Nicklas Karlsson formatting

            • 3. Re: Setting global JNDI naming policy
              jaikiran pai Master

              Nicklas Karlsson wrote:

               


               

              but I still get the binding errors. I thought I read in some JIRA that the JavaEE6JNDIBP would already *be* the default, is there some other policy you could recommend?

               

               

              That implementation appears to be buggy since it doesn't take into account top level .war deployments and instead considers only top level .ear deployments while generating a the jndi names. Currently I don't see a policy which takes into account deployment of EJBs via top level .war files. I believe we'll have to fix this.

              • 4. Re: Setting global JNDI naming policy
                jaikiran pai Master

                jaikiran pai wrote:

                 

                Nicklas Karlsson wrote:

                 


                 

                but I still get the binding errors. I thought I read in some JIRA that the JavaEE6JNDIBP would already *be* the default, is there some other policy you could recommend?

                 

                 

                That implementation appears to be buggy since it doesn't take into account top level .war deployments and instead considers only top level .ear deployments while generating a the jndi names.

                Let me rephrase that. It isn't really buggy since in EJB3.1 world, an app name corresponds to a .ear name. And from what I see in that implementation, it probably should work for you. Can you please post the entire exception stack trace and also try and make sure that the jndi-binding-policy element has really been picked up?

                • 5. Re: Setting global JNDI naming policy
                  Nicklas Karlsson Master

                  What ouput should I see if it's picked up? I don't see any INFO level  JavaEE6JndiBindingPolicy string at deployment time.

                  • 6. Re: Setting global JNDI naming policy
                    Nicklas Karlsson Master

                    11:59:39,753 INFO  [BeanInstantiatorDeployerBase] Installed org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator@3354037e into MC at org.jboss.ejb.bean.instantiator/test/test/TestBean

                    11:59:39,764 WARN  [InterceptorInfoRepository] EJBTHREE-1852: InterceptorInfoRepository is deprecated

                    11:59:40,219 INFO  [JBossASKernel] Created KernelDeployment for: test.war

                    11:59:40,224 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=test.war,name=TestBean,service=EJB3

                    11:59:40,224 INFO  [JBossASKernel]   with dependencies:

                    11:59:40,224 INFO  [JBossASKernel]   and demands:

                    11:59:40,225 INFO  [JBossASKernel]           jboss.ejb:service=EJBTimerService; Required: Described

                    11:59:40,225 INFO  [JBossASKernel]           jboss-switchboard:appName=test,module=test; Required: Create

                    11:59:40,225 INFO  [JBossASKernel]   and supplies:

                    11:59:40,225 INFO  [JBossASKernel]           jndi:TestBean

                    11:59:40,234 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=test.war,name=TestBean,service=EJB3) to KernelDeployment of: test.war

                    11:59:40,397 INFO  [TomcatDeployment] deploy, ctxPath=/test

                    11:59:40,451 INFO  [SessionSpecContainer] Starting jboss.j2ee:jar=test.war,name=TestBean,service=EJB3

                    11:59:40,478 INFO  [EJBContainer] STARTED EJB: fi.affecto.test.TestBean ejbName: TestBean

                    11:59:40,485 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

                     

                     

                     

                     

                    11:59:40,515 INFO  [AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:TestBean

                     

                     

                              TestBean/no-interface -> EJB3.1 no-interface view

                     

                     

                    11:59:40,523 INFO  [BeanInstantiatorDeployerBase] Installed org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator@3354037e into MC at org.jboss.ejb.bean.instantiator/test2/test2/TestBean

                    11:59:40,524 WARN  [InterceptorInfoRepository] EJBTHREE-1852: InterceptorInfoRepository is deprecated

                    11:59:40,553 INFO  [JBossASKernel] Created KernelDeployment for: test2.war

                    11:59:40,554 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=test2.war,name=TestBean,service=EJB3

                    11:59:40,554 INFO  [JBossASKernel]   with dependencies:

                    11:59:40,554 INFO  [JBossASKernel]   and demands:

                    11:59:40,554 INFO  [JBossASKernel]           jboss.ejb:service=EJBTimerService; Required: Described

                    11:59:40,554 INFO  [JBossASKernel]           jboss-switchboard:appName=test2,module=test2; Required: Create

                    11:59:40,554 INFO  [JBossASKernel]   and supplies:

                    11:59:40,555 INFO  [JBossASKernel]           jndi:TestBean

                    11:59:40,555 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=test2.war,name=TestBean,service=EJB3) to KernelDeployment of: test2.war

                    11:59:40,610 INFO  [TomcatDeployment] deploy, ctxPath=/test2

                    11:59:40,632 INFO  [SessionSpecContainer] Starting jboss.j2ee:jar=test2.war,name=TestBean,service=EJB3

                    11:59:40,633 INFO  [EJBContainer] STARTED EJB: fi.affecto.test.TestBean ejbName: TestBean

                    11:59:40,633 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

                     

                     

                     

                     

                    11:59:40,635 INFO  [AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:TestBean

                     

                     

                              TestBean/no-interface -> EJB3.1 no-interface view

                     

                     

                    11:59:40,636 ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:jar=test2.war,name=TestBean,service=EJB3,type=nointerface-view-jndi-binder state=Create: javax.naming.NameAlreadyBoundException: no-interface

                              at org.jnp.server.NamingServer.bind(NamingServer.java:209) [:5.0.5.Final]

                              at org.jnp.server.NamingServer.bind(NamingServer.java:167) [:5.0.5.Final]

                              at org.jnp.interfaces.NamingContext.bind(NamingContext.java:652) [:5.0.5.Final]

                              at org.jnp.interfaces.NamingContext.bind(NamingContext.java:613) [:5.0.5.Final]

                              at org.jboss.util.naming.Util.bind(Util.java:105) [jboss-common-core.jar:2.2.17.GA]

                              at org.jboss.util.naming.Util.bind(Util.java:91) [jboss-common-core.jar:2.2.17.GA]

                              at org.jboss.ejb3.nointerface.impl.jndi.StatefulBeanNoInterfaceViewBinder.bind(StatefulBeanNoInterfaceViewBinder.java:114) [:6.0.0.Final]

                              at org.jboss.ejb3.nointerface.impl.jndi.AbstractNoInterfaceViewBinder.start(AbstractNoInterfaceViewBinder.java:77) [:6.0.0.Final]

                              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                              at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                              at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:60) [jboss-reflect.jar:2.2.0.GA]

                              at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:168) [jboss-reflect.jar:2.2.0.GA]

                              at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) [jboss-reflect.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:257) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:202) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:894) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:641) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:182) [:2.2.0.GA]

                              at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58) [:2.2.0.GA]

                              at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [:2.2.0.GA]

                              at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.GA]

                              at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.GA]

                              at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.Final]

                              at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]

                              at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2]

                              at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2]

                              at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]

                              at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]

                              at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]

                              at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]

                              at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]

                              at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2]

                              at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2]

                              at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2]

                              at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.0.0.Final]

                              at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.0.Final]

                              at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]

                              at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]

                              at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

                     

                    Is what I get with a simple @Stateful EJB in a war deployed under two names in the same instance.

                    • 7. Re: Setting global JNDI naming policy
                      Carlo de Wolf Master

                      Try deploying your bean in the 'standard' config instead of 'all' or 'default'.

                       

                      The relevant part is in server/standard/deployers/ejb3-deployers-jboss-beans.xml:

                          <bean name="DefaultJNDIBindingPolicyProcessorFactory" class="org.jboss.as.ejb3.metadata.processor.DefaultJNDIBindingPolicyProcessorFactory">
                              <property name="policy">org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JavaEE6JndiBindingPolicy</property>
                          </bean>
                      

                       

                      It doesn't account for the problem that jndi-policy is not picked up from jboss.xml though.

                      • 8. Re: Setting global JNDI naming policy
                        Nicklas Karlsson Master

                        Thanks! Duplicate wars works in the standard instance