5 Replies Latest reply on Jan 3, 2003 4:16 PM by mark_man

    DataSource lookup fails

    dhumketu

      Hi Everybody

      my Env is :
      JDK 1.3.1
      JBOSS 3.0.0beta / Tomcat 4.0.2
      O/S : win98

      I am new to J2EE/EJB
      I have tried interest example.
      I have created my mySQL Datasource as testDS.
      I am able to get testDS JDBC datasource in my servlet. But when I tried to get a datasource from a standalone java program I am getting the following error

      Got context
      javax.naming.NameNotFoundException: testDS not bound

      I want to know why my lookup fails.(I am executing it from command line as java Test1)

      Please help me.

      Thankx in Advance
      -Dhum
      ----------------------------------------------------------------------------
      contents of my jndi.properties are

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=localhost:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

      ----------------------------------------------------------------------------

      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import javax.sql.*;

      import Interest;
      import InterestHome;

      class Test1
      {
      public static void main(String[] args)
      {
      try
      {
      // Get a naming context
      InitialContext jndiContext = new InitialContext();
      // InitialContext ctx = new InitialContext();
      System.out.println("Got context");


      // Get a reference to the JDBC Context
      DataSource ds = (DataSource) jndiContext.lookup("java:/testDS");
      System.out.println("Got testDS reference\n"+ ds);

      }
      catch(Exception e)
      {
      System.out.println(e.toString());
      }
      }
      }

        • 1. Re: DataSource lookup fails
          feuxeu77

          Hi,

          I think you should look at the URL http://localhost:8082, then select JNDIView and then click on the "list" button. You will all the names bound. May be you will find the name for your Database.

          I don't know why it works in a Servlet and not in a standalone program but I think it's the better solution to use this admin tool to find the Names.

          Regards,
          FX

          • 2. Re: DataSource lookup fails
            dhumketu

            Hi FX
            I was unable to find out what is wrong. I am attaching output of JNDIView

            Please help me finding out what could be the problem.

            One more thing (may not be so imp)
            I am not able to create XADataSource in Jboss3.0.0beta as it was in JBoss 2.4.4

            Thankx in advance
            -Dhum

            list Successful

            The operation

            was successfully invoked for the MBean [jboss:service=JNDIView].
            The operation returned with the value:


            Application: file:/D:/jboss-3.0.0beta/tmp/deploy/102.tomcat-test.jar
            java:comp namespace of the NonOptimized bean:
            +- env (class: org.jnp.interfaces.NamingContext)

            java:comp namespace of the Optimized bean:
            +- env (class: org.jnp.interfaces.NamingContext)

            Application: file:/D:/jboss-3.0.0beta/deploy/ejb-management.jar
            java:comp namespace of the MEJB bean:
            +- env (class: org.jnp.interfaces.NamingContext)
            | +- Server-Name (class: java.lang.String)

            Application: file:/D:/jboss-3.0.0beta/deploy/jmx-ejb-adaptor.jar
            java:comp namespace of the jmx/ejb/Adaptor bean:
            +- env (class: org.jnp.interfaces.NamingContext)
            | +- Server-Name (class: java.lang.String)

            Application: file:/D:/jboss-3.0.0beta/deploy/interest1.jar
            java:comp namespace of the Interest bean:
            +- UserTransaction (class: javax.transaction.UserTransaction)
            +- env (class: org.jnp.interfaces.NamingContext)
            | +- testDS[link -> java:/DefaultDS] (class: javax.naming.LinkRef)

            Application: file:/D:/jboss-3.0.0beta/deploy/interest.jar
            java:comp namespace of the Interest bean:
            +- UserTransaction (class: javax.transaction.UserTransaction)
            +- env (class: org.jnp.interfaces.NamingContext)
            | +- xatestDS[link -> java:/xatestDS] (class: javax.naming.LinkRef)

            java: Namespace
            +- jaas (class: javax.naming.Context)
            +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
            +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
            +- MinervaSharedLocalCMFactory (class: org.jboss.resource.connectionmanager.jboss.MinervaSharedLocalCMFactory)
            +- DefaultDS (class: org.jboss.resource.adapter.jdbc.JDBCDataSource)
            +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
            +- MinervaXACMFactory (class: org.jboss.resource.connectionmanager.jboss.MinervaXACMFactory)
            +- testDS (class: org.jboss.resource.adapter.jdbc.JDBCDataSource)
            +- TransactionManager (class: org.jboss.tm.TxManager)
            +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
            +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
            +- DefaultJMSProvider (class: org.jboss.jms.jndi.JBossMQProvider)
            +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
            +- CounterService (class: org.jboss.varia.counter.CounterService)
            +- Mail (class: javax.mail.Session)
            +- timedCacheFactory (class: javax.naming.Context)
            Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
            +- NoTransDS (class: org.jboss.resource.adapter.jdbc.JDBCDataSource)
            +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
            +- comp (class: javax.naming.Context)
            +- MinervaNoTransCMFactory (class: org.jboss.resource.connectionmanager.jboss.MinervaNoTransCMFactory)

            Global JNDI Namespace
            +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
            +- Optimized (proxy: $Proxy11 implements interface org.jboss.test.tomcat.ejb.interfaces.StatelessSessionHome,interface javax.ejb.Handle)
            +- UserTransactionSessionFactory (class: org.jboss.tm.usertx.server.UserTransactionSessionFactoryImpl)
            +- RMIXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
            +- jmx:abcd-28oyb9oj36:rmi (class: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl)
            +- topic (class: org.jnp.interfaces.NamingContext)
            | +- testTopic (class: org.jboss.mq.SpyTopic)
            +- queue (class: org.jnp.interfaces.NamingContext)
            | +- A (class: org.jboss.mq.SpyQueue)
            | +- testQueue (class: org.jboss.mq.SpyQueue)
            | +- ex (class: org.jboss.mq.SpyQueue)
            | +- DLQ (class: org.jboss.mq.SpyQueue)
            | +- D (class: org.jboss.mq.SpyQueue)
            | +- C (class: org.jboss.mq.SpyQueue)
            | +- B (class: org.jboss.mq.SpyQueue)
            +- NonOptimized (proxy: $Proxy11 implements interface org.jboss.test.tomcat.ejb.interfaces.StatelessSessionHome,interface javax.ejb.Handle)
            +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
            +- RMIConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
            +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
            +- ejb (class: org.jnp.interfaces.NamingContext)
            | +- mgmt (class: org.jnp.interfaces.NamingContext)
            | | +- J2EEDomain (proxy: $Proxy7 implements interface javax.management.j2ee.ManagementHome,interface javax.ejb.Handle)
            | +- jmx (class: org.jnp.interfaces.NamingContext)
            | | +- ejb (class: org.jnp.interfaces.NamingContext)
            | | | +- Adaptor (proxy: $Proxy3 implements interface org.jboss.jmx.adaptor.interfaces.AdaptorHome,interface javax.ejb.Handle)
            +- invokers (class: org.jnp.interfaces.NamingContext)
            | +- abcd-28oyb9oj36 (class: org.jnp.interfaces.NamingContext)
            | | +- jrmp (class: org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy)
            +- interest (class: org.jnp.interfaces.NamingContext)
            | +- Interest (proxy: $Proxy5 implements interface org.jboss.docs.interest.InterestHome,interface javax.ejb.Handle)
            +- interest1 (class: org.jnp.interfaces.NamingContext)
            | +- Interest (proxy: $Proxy9 implements interface InterestHome,interface javax.ejb.Handle)
            +- UILXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
            +- UILConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)

            Back to MBean View Back to Agent View



            • 3. Re: DataSource lookup fails
              davidjencks

              For about the 10,000th time, you CANNOT access a datasource from outside the jboss vm. You might consider looking for previous answers to your questions before posting.

              • 4. Re: DataSource lookup fails
                yohanfer

                I'm having the same problem using a new version of code from CVS. Why is it that you cant access it from a different VM?

                Isn't the whole point of making a datasource available through JNDI is to make it available for lookup remotely by other VM's? Or is this actually in the spec?

                • 5. Re: DataSource lookup fails

                  While it might be frustrating to receive the same question over and over again its equally frustrating to try and follow a tutorial that works with one app server but not the other. JBoss apparently does not support the retrieval of a datasource from a java client application. HP Bluestone (HPAS) and BEA support this feature and a number of books and on-line tutorials recommend this as a quick way to test out your JDBC connection and app server configuration. The other app servers treat the datasource connection as simply another jndi name which can be looked up. Given JBOSS supports the lookup of ejb's using a client app it would only seem reasonable it would allow datasource lookup as well.

                  As a newbie to JBOSS this issue cost me a significant amount of time.

                  Thank you for your help...look forward to learning more.
                  Mark