4 Replies Latest reply on Sep 25, 2003 5:19 AM by neerajvyas

    Datasource not reached from web bean

    malian

      I am using Jboss3.2.1 with imbedded Tomcat 4.1.24.

      I have setup a Solid Database connection by creating solid-ds.xml file under deploy directory like this:


      <local-tx-datasource>
      <jndi-name>jdbc/solidJDBC</jndi-name>
      <!--NOTE: Solid wants the username/password in the URL, it will
      ignore the specific arguments.-->
      <connection-url>jdbc:solid://155.55.5.55:1555/user/pass</connection-url>
      <driver-class>solid.jdbc.SolidDriver</driver-class>
      </local-tx-datasource>



      I tried to reach this connection in my web bean that gets called from a JSP with this code:

      DataSource solidDS = (DataSource) envCtx.lookup("jdbc/solidJDBC");

      But I get this error:


      javax.naming.NamingException: Could not dereference object. Root exception is
      java.lang.NullPointerException
      at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:925)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:577)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
      at netrio.smc.util.DataConnectionBean.getSolidConnection(Unknown Source)


      I know that you can't access a datasource defined in jboss from classes running in the web container when tomcat and jboss are running separately. But I am running jboss+tomcat together in the same VM. I have searched the mailing list and looked in the documentation thoroughly, but can't figure out what's the problem. Please help if anyone has the solution!

      Thanks,
      Malia

        • 1. Re: Datasource not reached from web bean

          Do you declare the <resource-ref> for the lookup name in web.xml and map that to the correct JNDI name in your jboss-web.xml?

          • 2. Re: Datasource not reached from web bean
            malian

            Yes, I defined resource-ref in my web.xml like this:

            <resource-ref>
            resource for db connection pooling for solid db
            <res-ref-name>jdbc/solidJDBC</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            </resource-ref>

            and my jboss-web.xml looks like this:

            <resource-ref>
            <res-ref-name>jdbc/solidJDBC</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <jndi-name>java:jdbc/solidJDBC</jndi-name>
            </resource-ref>


            I would appreciate your help very much! BTW, now I am getting this error:

            org.jboss.util.NestedSQLException: Apparently wrong driver class specified for URL: class: solid.jdbc.SolidDriver, url: jdbc:solid://155.55.5.55:1555/user/pass; - nested throwable: (org.jboss.resource.JBossResourceException: Apparently wrong driver class specified for URL: class: solid.jdbc.SolidDriver, url: jdbc:solid://155.55.5.55:1555/user/pass)
            at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:106)
            at netrio.smc.util.DataConnectionBean.getSolidConnection(Unknown Source)


            thank you for replying!
            Malia

            • 3. Re: Datasource not reached from web bean
              arabin

              Have you solved the problem?
              How can I connect using the file solid-ds.xml? Can you explain me in details?

              Is the file solid-service.xml required?
              I just thought I need solid-service.xml to connect. Isn't it true?

              For instance, when I connected to postgres, I user the file postgres-service.xml

              Also, the reference http://sourceforge.net/project/shownotes.php?release_id=111113 says I should have solid-service.xml already, starting 3.2.0RC4
              I have 3.2.2RC3, and I do not see the file solid-service.xml there.

              Any ideas?

              • 4. Re: Datasource not reached from web bean
                neerajvyas

                Try out with following

                In Datasource XML file
                <jndi-name>solidJDBC</jndi-name>

                In your bean code:
                DataSource solidDS = (DataSource) envCtx.lookup("java:/solidJDBC");