5 Replies Latest reply on Jun 6, 2006 4:22 PM by Ed Ross

    data source is null

    Ed Ross Newbie

      I'm trying to configure a datasource for jboss and the tomcat web container.

      My problem is I'm allways getting a null when I do a ctx.lookup.

      I've added a postgres-ds.xml in the deploy directory
      I've added a jboss-web.xml in webapp/WEB-INF
      I've added a reference in the web.xml
      I've added a context.xml in the WEB_INF/META-INF
      I've copied the driver jar to about every directory in the world

      I've read about everything I can think of and still get a null datasource in a sample startup app.

      code snip
      public void init() {
      try{
      Context ctx = new InitialContext();

      if (ctx == null)
      throw new Exception("Opps - No Context");
      System.out.println("CTX Name in space "+ctx.getNameInNamespace());
      Object obj = ctx.lookup("java:/jdbc/GiftDevel");
      Context context = (Context)ctx.lookup("java:");

      DataSource ds = (DataSource) context.lookup("java:/jdbc/GiftDevel");
      if(ds != null){
      System.out.println(" ds is not null ");
      }

      I don't get lookup errors - just nulls.


      The logs all state the daasource is bound to java:jdbc/GifgDevel

      setting property: ConnectionURL to value jdbc:postgresql://localhost:5432
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] set property ConnectionURL to value jdbc:postgresql://localhost:5432
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] setting property: DriverClass to value org.postgresql.Driver
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] set property DriverClass to value org.postgresql.Driver
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] setting property: UserName to value edross
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] set property UserName to value edross
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] setting property: Password to value xxxx
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] set property Password to value xxxxx
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] Not setting config property 'TrackStatements'
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] setting property: ConnectionProperties to value DatabaseName=gift
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] set property ConnectionProperties to value DatabaseName=gift
      2006-06-06 15:45:09,234 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] Started jboss.jca:service=ManagedConnectionFactory,name=jdbc/GiftDevel
      2006-06-06 15:45:09,234 DEBUG [org.jboss.system.ServiceController] Starting dependent components for: jboss.jca:service=ManagedConnectionFactory,name=jdbc/GiftDevel dependent components: [ObjectName: jboss.jca:service=ManagedConnectionPool,name=jdbc/GiftDevel


      Everything seems to work but my application.

      I've tried about a billion different configurations, and all are the same

      Jboss 4.0.3SP1

      Anyone??

      thx


        • 1. Re: data source is null
          Weston M. Price Master

          The jar file should be in your <server-config>/lib and nowhere else.

          Could you post the *-ds.xml file, web.xml, etc. Also, please post context.xml

          • 2. Re: data source is null
            Weston M. Price Master

            The jar file should be in your <server-config>/lib and nowhere else.

            Could you post the *-ds.xml file, web.xml, etc. Also, please post context.xml

            • 3. Re: data source is null
              Ed Ross Newbie

              postgresql-ds.xml

              <?xml version="1.0" encoding="UTF-8"?>

              <local-tx-datasource>
              <jndi-name>jdbc/GiftDevel</jndi-name>

              <connection-url>jdbc:postgresql://localhost:5432</connection-url>
              <connection-property name="DatabaseName">gift</connection-property>
              <user-name>edross</user-name>
              xxxx
              <min-pool-size>5</min-pool-size>
              <max-pool-size>20</max-pool-size>
              <idle-timeout-minutes>0</idle-timeout-minutes>
              <track-statements/>
              <driver-class>org.postgresql.Driver</driver-class>

              </local-tx-datasource>



              <jboss-web>
              <context-root>/gift</context-root>
              <security-domain>java:/jaas/gift-web</security-domain>

              <resource-ref>
              <res-ref-name>jdbc/GiftDevel</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <jndi-name>jdbc/GiftDevel</jndi-name>
              </resource-ref>


              </jboss-web>


              from web.xml

              <resource-ref>
              <res-ref-name>jdbc/GiftDevel</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              </resource-ref>


              context.xml

              <?xml version="1.0" encoding="utf-8" ?>






              • 4. Re: data source is null
                Ed Ross Newbie

                oops the context.xml didn't fit in the last post




                <?xml version="1.0" encoding="utf-8" ?>



                • 5. Re: data source is null
                  Ed Ross Newbie

                   

                  <?xml version="1.0" encoding="utf-8" ?>
                  <Context docBase="gift-admin" path="/">
                   <Resource name="jdbc/GiftDevel"
                   auth="Container"
                   type="javax.sql.DataSource"
                   factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
                   username="edross"
                   password="xxxx"
                   driverClassName="org.postgresql.Driver"
                   url="jdbc:postgresql://localhost:5432/gift" />
                   <ResourceLink
                   name="jdbc/GiftDevel"
                   global="jdbc/GiftDevel"
                   type="javax.sql.DataSource" />
                  </Context>



                  sorry - the xml caused only part to post