7 Replies Latest reply on Jan 16, 2003 11:24 PM by Tom Haywood

    DataSources accessible from a remote application?

    mstarr Newbie

      Since DataSources always seem to be bound to the "java:/" namespace, does this mean you cannot access the datasource from a remote Java application? Is there a way to install a datasource under a different namespace?

      Thanks,
      Mike

        • 1. Re: DataSources accessible from a remote application?
          jun wang Newbie

          Datasource can be called in java client,applet,jsp

          • 2. Re: DataSources accessible from a remote application?
            Juan Pérez Newbie

            > Datasource can be called in java client,applet,jsp

            How? I keep receiving the same "not bound error" if I try to access it from a java client. The only one that has worked to me was to access it from an EJB.

            • 3. Re: DataSources accessible from a remote application?
              Yuri Smychkovich Newbie

              > How? I keep receiving the same "not bound error" if I
              > try to access it from a java client. The only one
              > that has worked to me was to access it from an EJB.

              The same problem. Actually I was able to access datasource from any place INSIDE the server: another ear, war, servlet etc. Could anybody explain how to get it from client?

              Thanks.

              • 4. Re: DataSources accessible from a remote application?
                andres Newbie

                The same problem... even with JBoss 3.0.4.

                This is really a pain! Any solution? I don't want to create a separate connection pool for remote applications!

                • 5. Re: DataSources accessible from a remote application?
                  Joel Vogt Master

                  you should be able to do this without a problem.
                  Are you doing the lookup from 'new InitialContext()'? If so this will only work 'inside' the server as you saw.

                  To do it from outside you will need to do something like:

                  java.util.Hashtable props = new java.util.Hashtable();
                  props.put(Context.INITIAL_CONTEXT_FACTORY,
                  "org.jnp.interfaces.NamingContextFactory");
                  props.put(Context.PROVIDER_URL, <>);
                  props.put("java.naming.rmi.security.manager", "yes");
                  props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");

                  // Get the initial context with given properties
                  Context context = new InitialContext(props);

                  Then do context lookups.

                  Hope this helps you

                  • 6. Re: DataSources accessible from a remote application?
                    Danielle Newbie

                    Hi,

                    I'm having the same problem about accessing data source from a client program. So I took your suggestion by adding the following to the jndi.properties:

                    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                    java.naming.provider.url=jnp://localhost:1099/
                    java.naming.rmi.security.manager=yes
                    java.naming.factory.url.pkgs=org.jboss.naming

                    Unfortunately I'm still getting the same db_source not bound error. Any insights?

                    Thanks!

                    • 7. Re: DataSources accessible from a remote application?
                      Tom Haywood Newbie

                      I know there isn't a lot of value in a me too post, but I have pretty much the same problem. To try and understand why I wrote a simple Java Client that creates an InitialContext and then lists all objects bound to both "" and "java:". When I run this client outside of JBoss I get two identical lists. If I then take the code and put in a JSP and run the JSP from within JBoss I get two different lists. (Which is what I would expect). I also have the same problem as the previous posts, I can not get the default datasource from the Java Client but I can get it from the JSP.

                      Is it my lack of understanding, a misconfiguration or is this the way it is supposed to be?

                      For the Java client I use the aforementioned properties in my jndi.properties, for the JSP I do not provide any configuration and just take whatever is configured within JBoss. Not that I think it matters, but the JSP is running inside Jetty.