5 Replies Latest reply on May 16, 2003 8:27 AM by richardye

    Accessing a DataSource

    Geoff Seel Newbie

      Expected to find this in FAQs but can't, so apologise if it's a dumb question.

      Have set up a DataSource for a Pointbase database which the log tells me is bound as 'java:/PointbaseDS'.

      Have tried context.lookup with java:comp/env/PointbaseDS, java:/PointbaseDS and java:comp/PointbaseDS and get 'PointbaseDS not bound' naming error on all of them.

      How should I be accessing or is the log misledaing me about having bound the DataSource?

      Thanks

        • 1. Re: Accessing a DataSource
          David Jencks Master

          Are you accessing from within the jboss vm and are you sure the jndi is configured to not go through rmi? (normally this means you just say new InitialContext and dont put any jndi.properties anywhere in a deployable)

          • 2. Re: Accessing a DataSource
            Geoff Seel Newbie

            David

            Thanks for response.

            Yes running inside the JBoss vm. Actually running as a stateless session bean wanting to use DAOs for persistence.

            Relevant code is:

            context = new InitialContext();
            dataSourceName = (String) context.lookup("java:/PointbaseDS");
            dataSource = (DataSource) context.lookup(dataSourceName);

            Have done a list on the context and it lists a number of names (e.g. XAConnectionFactory and queue) but nothing like java or PointbaseDS.

            Thanks

            • 3. Re: Accessing a DataSource
              Geoff Seel Newbie

              Looks like the classic copying code without understanding it error. Got rid of the two stage lookup and I think it's working. Now can't get a connection because of 'no principal' but that just sounds like a config problem in my stuff.

              Thanks.

              • 4. Re: Accessing a DataSource
                richardye Newbie

                I have the same problem while trying to access data source within jboss vm using JBoss_3.2.1. I have done the following:

                1) change the oracle_ds.xml to include my data source info
                <jndi-name>DevDs</jndi-name>
                my oracle url</connection-url>
                then put the oracle_ds.xml into deploy directory

                2) I define System property in properties-service.xml

                DataSourceJndi=java:/DevDs


                3) In my stateless session bean I call one of my application class JndiDataSource(JndiDataSource is included in my application library jar, the jar is simply deployed into deploy directory) as
                JndiDataSource.getConnection() {
                String jndiName = System.getProperty("DataSourceJndi");
                InitialContext initialContext = new InitialContext();
                Object jndiDataSrc = initialContext.lookup(jndiName);
                }

                then I got DevDs not bound error even though I saw the log file says 'java:/DevDs' is bound to WrapperDataSource
                and I don't believe I have any jndi.properties in deploy directory

                ****** client side error ********
                DevDs not bound
                at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
                at sun.rmi.transport.Transport$1.run(Transport.java:148)
                at java.security.AccessController.doPrivileged(Native Method)
                at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                at java.lang.Thread.run(Thread.java:536)
                at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
                at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
                at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
                at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
                at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
                at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:87)
                at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
                at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
                at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
                at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
                at $Proxy1.load(Unknown Source)************

                ======== log msg =============
                Binding object 'org.jboss.resource.adapter.jdbc.WrapperDataSource@4b9a74' into JNDI at 'java:/SempraDevDs'

                DevDs not bound
                at JndiDataSource.getConnection()(JndiDataSource.java:22)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
                at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:273)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
                at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
                at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
                at org.jboss.ejb.Container.invoke(Container.java:674)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
                at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                at sun.rmi.transport.Transport$1.run(Transport.java:148)
                at java.security.AccessController.doPrivileged(Native Method)
                at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                at java.lang.Thread.run(Thread.java:536)
                ============================

                • 5. Re: Accessing a DataSource
                  richardye Newbie

                  In the message posted by RichardYe before

                  the first line of log msg should read as

                  ======== log msg =============
                  Binding object 'org.jboss.resource.adapter.jdbc.WrapperDataSource@4b9a74' into JNDI at 'java:/DevDs'