1 Reply Latest reply on Jun 25, 2010 6:34 PM by Ondrej Zizka

    Overriding JNDI name with jboss.xml

    Ondrej Zizka Master

      Hi,

       

      I have the typical Calculator example, and I am trying to override the JNDI name it is assigned by JBoss EAP 5.0.1.

       


      public abstract interface Calculator { add/substract() }
      @Remote public abstract interface CalculatorRemote extends Calculator {}
      @Local public abstract interface CalculatorLocal extends Calculator {}
      @Stateless public class CalculatorBean implements CalculatorRemote, CalculatorLocal

       

      and I am trying to affect the JNDI names. But the remote interface still keeps it's "remote".

       

      20:32:56,326 INFO  [JBossASKernel] Created KernelDeployment for: ejb3-calculator-001.jar
      20:32:56,328 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-001.jar,name=Calculator-001,service=EJB3
      20:32:56,328 INFO  [JBossASKernel]   with dependencies:
      20:32:56,328 INFO  [JBossASKernel]   and demands:
      20:32:56,328 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:32:56,328 INFO  [JBossASKernel]   and supplies:
      20:32:56,329 INFO  [JBossASKernel]      jndi:Calculator-001/remote-org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:32:56,329 INFO  [JBossASKernel]      jndi:ejb/Calculator-001
      20:32:56,329 INFO  [JBossASKernel]      jndi:ejb/Calculator-001/xremote
      20:32:56,329 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:32:56,329 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-001.jar,name=Calculator-001,service=EJB3) to KernelDeployment of: ejb3-calculator-001.jar
      20:32:56,329 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-001.jar,name=CalculatorBean,service=EJB3
      20:32:56,329 INFO  [JBossASKernel]   with dependencies:
      20:32:56,329 INFO  [JBossASKernel]   and demands:
      20:32:56,330 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:32:56,330 INFO  [JBossASKernel]   and supplies:
      20:32:56,330 INFO  [JBossASKernel]      jndi:CalculatorBean/remote
      20:32:56,330 INFO  [JBossASKernel]      jndi:CalculatorBean/remote-org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:32:56,330 INFO  [JBossASKernel]      jndi:CalculatorBean/local-org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
      20:32:56,330 INFO  [JBossASKernel]      jndi:CalculatorBean/local
      20:32:56,330 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
      20:32:56,330 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:32:56,330 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-001.jar,name=CalculatorBean,service=EJB3) to KernelDeployment of: ejb3-calculator-001.jar

       


      I've tried this,

       

      <jboss xmlns="http://www.jboss.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="3.0">
      
        <enterprise-beans>
          <session>
            <ejb-name>Calculator${ejb.name.suffix}</ejb-name>
            <jndi-name>ejb/Calculator${ejb.name.suffix}</jndi-name>
            <remote-binding>
              <jndi-name>ejb/Calculator${ejb.name.suffix}/xremote</jndi-name>
            </remote-binding>
          </session>
          <session>
            <ejb-name>CalculatorBean${ejb.name.suffix}</ejb-name>
            <jndi-name>ejb/CalculatorBean${ejb.name.suffix}</jndi-name>
          </session>
        </enterprise-beans>
      
      </jboss>
      

       


      But it creates another CalculatorBean with that JNDI, and the "un-indexed" one is still there, too.

       

      20:38:47,305 INFO  [JBossASKernel] Created KernelDeployment for: ejb3-calculator-001.jar
      20:38:47,305 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-001.jar,name=Calculator-001,service=EJB3
      20:38:47,305 INFO  [JBossASKernel]   with dependencies:
      20:38:47,305 INFO  [JBossASKernel]   and demands:
      20:38:47,305 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:38:47,305 INFO  [JBossASKernel]   and supplies:
      20:38:47,305 INFO  [JBossASKernel]      jndi:Calculator-001/remote-org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:38:47,305 INFO  [JBossASKernel]      jndi:ejb/Calculator-001
      20:38:47,305 INFO  [JBossASKernel]      jndi:ejb/Calculator-001/xremote
      20:38:47,305 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:38:47,305 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-001.jar,name=Calculator-001,service=EJB3) to KernelDeployment of: ejb3-calculator-001.jar
      20:38:47,305 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-001.jar,name=CalculatorBean,service=EJB3
      20:38:47,305 INFO  [JBossASKernel]   with dependencies:
      20:38:47,305 INFO  [JBossASKernel]   and demands:
      20:38:47,305 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:38:47,305 INFO  [JBossASKernel]   and supplies:
      20:38:47,306 INFO  [JBossASKernel]      jndi:CalculatorBean/remote
      20:38:47,306 INFO  [JBossASKernel]      jndi:CalculatorBean/remote-org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:38:47,306 INFO  [JBossASKernel]      jndi:CalculatorBean/local-org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
      20:38:47,306 INFO  [JBossASKernel]      jndi:CalculatorBean/local
      20:38:47,306 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
      20:38:47,306 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:38:47,306 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-001.jar,name=CalculatorBean,service=EJB3) to KernelDeployment of: ejb3-calculator-001.jar
      20:38:47,306 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-001.jar,name=CalculatorBean-001,service=EJB3
      20:38:47,306 INFO  [JBossASKernel]   with dependencies:
      20:38:47,306 INFO  [JBossASKernel]   and demands:
      20:38:47,306 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:38:47,306 INFO  [JBossASKernel]   and supplies:
      20:38:47,306 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
      20:38:47,306 INFO  [JBossASKernel]      jndi:ejb/CalculatorBean-001
      20:38:47,306 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorRemote
      20:38:47,306 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-001.jar,name=CalculatorBean-001,service=EJB3) to KernelDeployment of: ejb3-calculator-001.jar
      20:38:47,332 INFO  [SessionSpecContainer] Starting jboss.j2ee:jar=ejb3-calculator-001.jar,name=Calculator-001,service=EJB3

       


      So I wonder how to rename the CalculatorBean/remote to CalculatorBean/remote-123.

       

      Any ideas?
      Thanks, Ondra

        • 1. Re: Overriding JNDI name with jboss.xml
          Ondrej Zizka Master

          Solved.

           

          Carlo de Wolf adviced me to use JavaEE6JndiBindingPolicy.java from JBoss Metadata 2, which worked. Now I get:

           

          00:34:18,029 INFO  [JBossASKernel] Created KernelDeployment for: ejb3-calculator-003.jar
          00:34:18,029 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-003.jar,name=CalculatorBean,service=EJB3
          00:34:18,029 INFO  [JBossASKernel]   with dependencies:
          00:34:18,029 INFO  [JBossASKernel]   and demands:
          00:34:18,029 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
          00:34:18,029 INFO  [JBossASKernel]   and supplies:
          00:34:18,029 INFO  [JBossASKernel]      jndi:ejb3-calculator-003.jar/CalculatorBean!remote
          00:34:18,029 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
          00:34:18,029 INFO  [JBossASKernel]      jndi:ejb3-calculator-003.jar/CalculatorBean!local
          00:34:18,029 INFO  [JBossASKernel]      jndi:ejb3-calculator-003.jar/CalculatorBean!org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
          00:34:18,029 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-003.jar,name=CalculatorBean,service=EJB3) to KernelDeployment of: ejb3-calculator-003.jar
          00:34:18,029 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=ejb3-calculator-003.jar,name=CalculatorBean-003,service=EJB3
          00:34:18,029 INFO  [JBossASKernel]   with dependencies:
          00:34:18,029 INFO  [JBossASKernel]   and demands:
          00:34:18,030 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
          00:34:18,030 INFO  [JBossASKernel]   and supplies:
          00:34:18,030 INFO  [JBossASKernel]      jndi:ejb3-calculator-003.jar/CalculatorBean-003!local
          00:34:18,030 INFO  [JBossASKernel]      jndi:ejb/CalculatorBean-003
          00:34:18,030 INFO  [JBossASKernel]      Class:org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
          00:34:18,030 INFO  [JBossASKernel]      jndi:ejb3-calculator-003.jar/CalculatorBean-003!org.jboss.qa.eapperf.deployers.ejb3.calc.CalculatorLocal
          00:34:18,030 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=ejb3-calculator-003.jar,name=CalculatorBean-003,service=EJB3) to KernelDeployment of: ejb3-calculator-003.jar

           

           

          Perfect.