4 Replies Latest reply on Sep 10, 2003 2:14 AM by juha

    Cannot locate PostgresDS

    thegiantsquid

      I have sucessfully configured a postgres installation:


      <local-tx-datasource>
      <jndi-name>PostgresDS</jndi-name>
      <connection-url>jdbc:postgresql://devsun:5432/test</connection-url>
      <driver-class>org.postgresql.Driver</driver-class>
      <user-name>xxx</user-name>
      xxx
      </local-tx-datasource>



      Yet, the following code:
      // cheat a little and pack the JNDI properties
      Properties jndiProps = new Properties();
      jndiProps.setProperty(
      "java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");
      jndiProps.setProperty(
      "java.naming.provider.url",
      "jnp://localhost:1099");
      jndiProps.setProperty(
      "java.naming.factory.url.pkgs",
      "org.jboss.naming:org.jnp.interfaces");

      Context initial = new InitialContext(jndiProps);

      DataSource ds = (DataSource) initial.lookup("java:/PostgresDS");


      yields:
      javax.naming.NameNotFoundException: PostgresDS not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at com.ieminc.met.dao.MetReadingFinder.getMetReadingsBetween(MetReadingFinder.java:53)
      at com.ieminc.met.client.JDBCClient.main(JDBCClient.java:38)

      I have successfully deployed entity beans using this configuration, yet I cannot lookup a Datasource...


      Any ideas?

        • 1. Re: Cannot locate PostgresDS
          thegiantsquid

          Also, the startup log yields this:


          14:28:49,009 INFO [PostgresDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=PostgresDS to JNDI name 'java:/PostgresDS'

          • 2. Re: Cannot locate PostgresDS
            thegiantsquid

            And....

            if I yank server\default\jnpserver.jar out of the runtime classpath, i get:

            java.lang.NoClassDefFoundError: org/jnp/server/NamingServer
            at org.jboss.naming.java.javaURLContextFactory.(javaURLContextFactory.java:37)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:217)
            at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:50)
            at com.sun.naming.internal.ResourceManager.getFactory(ResourceManager.java:371)
            at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:570)
            at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:528)
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:275)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at com.ieminc.met.dao.MetReadingFinder.getMetReadingsBetween(MetReadingFinder.java:53)
            at com.ieminc.met.client.JDBCClient.main(JDBCClient.java:38)

            • 3. Re: Cannot locate PostgresDS
              thegiantsquid

              Welp, apparently, I cannot remotely lookup DataSources, as I can only use the "java:/" prefix when I'm in the same VM, which I suppose, means I need to deploy this app as a stateless SessionBean.

              Thanks, I guess, to whomever read this.

              • 4. Re: Cannot locate PostgresDS

                That's correct, and you're welcome ;-)

                -- Juha