6 Replies Latest reply on Nov 16, 2001 11:39 AM by wdfink

    lookup Datasource / Difference between JBoss 2.2 => 2.4

    wdfink

      The request:
      Normaly work with CMP Beans. Writing SessionsBeans with JDBC access to the CMP data for a better performance.

      My Code:
      public void setSessionContext(SessionContext context) {
      this.ctx = context;
      Context jndiCtx;
      try {
      jndiCtx = new InitialContext();
      myDB = (DataSource)jndiCtx.lookup("java:comp/env/myDB");
      }catch ......

      ejb-jar.xml
      <resource-ref>
      <res-ref-name>jdbc/myDB</res-ref-name>
      <res-type>XADataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      this works properly with JBoss2.2

      After an upgrade to JBoss 2.4 the following Exception occoured:
      javax.naming.NameNotFoundException: iprofileDB not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      . . .

      some attempts with <res-ref-name> like /myDB or myDB produce messages like this during the JBoss startup:

      [Container factory] No resource manager found for myDB

      My Question:
      What is the best way to get a JNDI reference to the CMP database and is the name configurable in the DeploymentDescriptor?

        • 1. Re: lookup Datasource / Difference between JBoss 2.2 => 2.4
          p_d_austin

          in your jboss.xml file you need to prefix the datasource name iprofileDB with java:/ (i.e. java:/iprofileDB). This change was made in 2.4.

          Paul

          • 2. Re: lookup Datasource / Difference between JBoss 2.2 => 2.4
            wdfink

            First of all:
            The Database-name iprofileDB and myDB in my posting mean exactly the same (sorry for cut'n paste)

            in your jboss.xml file . . .
            I can't find a file named jboss.xml.
            you mean jboss.jcml ?

            My jboss.jcml looks like:

            iprofileDB
            org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImpl
            jdbc:oracle:thin:@localhost:1521:ORCL
            jboss
            jboss



            Wolf

            • 3. Re: lookup Datasource / Difference between JBoss 2.2 => 2.4
              ashu

              it the jboss file in your folder wher u keep your CMP beans & ejb-jar.xml files etc....

              • 4. Re: lookup Datasource / Difference between JBoss 2.2 => 2.4
                ashu

                i did try java:/myPoolname...... but it did not work ....getting same erroe while starting jboss..
                [ContanerFactory] no resource manager found for myPoolname

                my jboss.xml file below & a similar ejb-jar.xml file
                <resource-ref>
                <res-ref-name>java:/myPoolname</res-ref-name>
                <res-type>javax.sql.Datasource</res-type>
                <res-auth>Container</res-auth>
                </resource-ref>


                • 5. Re: lookup Datasource / Difference between JBoss 2.2 => 2.4
                  fragata

                  Good evening, I have the same problem, but my jboss version is 2.2. If I use jsp file, I can use ctx.lookup(java:/pool), but if I use standalone application show me:
                  javax.naming.NameNotFoundException: pool not bound

                  at org.jnp.server.NamingServer.getBinding(NamingServer.java:473)

                  at org.jnp.server.NamingServer.getBinding(NamingServer.java:481)

                  at org.jnp.server.NamingServer.getObject(NamingServer.java:487)

                  at org.jnp.server.NamingServer.lookup(NamingServer.java:282)

                  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)

                  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)

                  at javax.naming.InitialContext.lookup(InitialContext.java:350)



                  my code is:

                  private Connection getConnection() throws SQLException
                  {
                  try
                  {
                  Context ctx = new InitialContext();
                  DataSource dataSource = (DataSource)ctx.lookup (poolName);
                  return dataSource.getConnection();
                  }
                  catch (NamingException ne)
                  {
                  ne.printStackTrace();
                  }
                  }


                  If anybody can help me, please contact me:
                  sfragata@bol.com.br

                  • 6. Re: lookup Datasource / Difference between JBoss 2.2 => 2.4
                    wdfink

                    Thanks all for help.

                    The answer was:

                    true
                    <container-configurations></container-configurations>
                    <resource-managers>
                    <resource-manager res-class="">
                    <res-name>jdbc/iprofileDB</res-name>
                    <res-jndi-name>iprofileDB</res-jndi-name> <--- wrong
                    <res-jndi-name>java:/iprofileDB</res-jndi-name> <--- correct
                    </resource-manager></resource-managers>


                    the file was an automatic created descriptor from our Together IDE.
                    JBoss2.2 accept this (with a little hint)
                    JBoss2.4 accept ihis with no Hint, but it didn't work