8 Replies Latest reply on Mar 18, 2003 8:37 AM by srinivas_rc

    cmp on jboss-3.0.6_tomcat-4.1.18 with mysql

    bipin_deshpande

      On server it shows
      15:09:22,551 INFO [LocalTxConnectionManager] Starting
      15:09:22,571 INFO [MySqlDS] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/MySqlDS'

      On Client it shows
      javax.naming.NameNotFoundException: MySqlDS 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 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)
      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.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:484)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:463)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at MyClient.main(MyClient.java:27)
      Exception: MySqlDS not bound

      If it is showing bounded on server why i a m unable to connect it from myserver

        • 1. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
          bipin_deshpande

          i mean to say why I am unable to connect it from "myclient"

          • 2. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
            srinivas_rc

            Why dont you attach your 'ejb-jar.xml' and the part of client code, which is doing the lookup. That may help.

            Srini

            • 3. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
              bipin_deshpande

              Is there any need to edit ejb-jar zml for data source ?
              Because I have added mysql-service xml and added application policy name MySqlDB in login-config.xml.

              • 4. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
                bipin_deshpande

                Is there any need to ejb-jar.xml?In case of Datasource?
                I have added mysql-service.xml in my deploy directory.
                And also added application policy name "MySqlDS" in login-config.xml.

                My client code is
                import javax.naming.Context;
                import javax.naming.InitialContext;
                import java.util.Hashtable;
                import first.*;
                import java.sql.*;
                import javax.sql.*;
                import java.util.*;

                public class MyClient
                {
                public static void main( String [] args )
                {
                Connection conn = null;
                DataSource ds = null;
                Hashtable env = new Hashtable();
                env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
                env.put(Context.PROVIDER_URL, "comp180:1099");
                env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
                try
                {
                InitialContext ctx = new InitialContext(env);
                System.out.println(ctx);
                Enumeration e = ctx.list("java:/");
                while(e.hasMoreElements()){
                System.out.println(""+e.nextElement());
                }
                ds = (DataSource)ctx.lookup("java:/MySqlDS");

                conn = ds.getConnection();
                }
                catch ( Exception e )
                {
                e.printStackTrace();
                System.out.println( "Exception: " + e.getMessage() );
                }
                }
                }

                • 5. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
                  bipin_deshpande

                  Is there any need to ejb-jar.xml?In case of Datasource?
                  I have added mysql-service.xml in my deploy directory.
                  And also added application policy name "MySqlDS" in login-config.xml.



                  My Client code :

                  import javax.naming.Context;
                  import javax.naming.InitialContext;
                  import java.util.Hashtable;
                  import first.*;
                  import java.sql.*;
                  import javax.sql.*;
                  import java.util.*;

                  public class MyClient
                  {
                  public static void main( String [] args )
                  {
                  Connection conn = null;
                  DataSource ds = null;
                  Hashtable env = new Hashtable();
                  env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
                  env.put(Context.PROVIDER_URL, "comp180:1099");
                  env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
                  try
                  {
                  InitialContext ctx = new InitialContext(env);
                  System.out.println(ctx);
                  Enumeration e = ctx.list("java:/");
                  while(e.hasMoreElements()){
                  System.out.println(""+e.nextElement());
                  }
                  ds = (DataSource)ctx.lookup("java:/MySqlDS");

                  conn = ds.getConnection();
                  }
                  catch ( Exception e )
                  {
                  e.printStackTrace();
                  System.out.println( "Exception: " + e.getMessage() );
                  }
                  }
                  }

                  • 6. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
                    srinivas_rc

                    Oh! So you are not using ejb. You just want to use a DataSource from a client java program (that is may be within or outside jboss).

                    If that is the case, First I will suggest you see your JNDI Tree (using JndiView MBEAN available from http://localhost:8080/jmx-console).

                    Use the method list() or listXml() to see all the bindings done, and see what is the exact path ...in ur case u assume it is :

                    MySqlDS

                    If it is in 'Java' Namespace, I think you can use it only from within Jboss. You can do a lookup with

                    Context rootCtx = getInitialContext();
                    DataSource ds = (DataSource) rootCtx.lookup("java:/MySqlDS");


                    If it is in global jndi namespace, then you can do lookup from client outside jboss env.

                    DataSource ds = (DataSource) rootCtx.lookup("MySqlDS");

                    Hope this helps.

                    • 7. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
                      bipin_deshpande

                      this is what I get from my
                      http://localhost:8080/jmx-console/index.jsp

                      jboss.jca
                      name=JBoss LocalTransaction JDBC Wrapper,service=RARDeployment
                      name=JMS Adapter,service=RARDeployment
                      name=Minerva JDBC XATransaction ResourceAdapter,service=RARDeployment
                      name=MySqlDS,service=LocalTxCM
                      name=MySqlDS,service=LocalTxDS
                      name=MySqlDS,service=LocalTxPool
                      name=hsqldbDS,service=LocalTxCM
                      name=hsqldbDS,service=LocalTxDS
                      name=hsqldbDS,service=LocalTxPool
                      name=jmsra,service=XaTxCM
                      name=jmsra,service=XaTxDS
                      name=jmsra,service=XaTxPool
                      service=CachedConnectionManager
                      service=RARDeployer

                      It clearly shows that MySqlDS is bound

                      Even if I am unable to get it from my client by the same name 'MySqlDS'.

                      Is there any problem of classpath or something ?


                      • 8. Re: cmp on jboss-3.0.6_tomcat-4.1.18 with mysql
                        srinivas_rc

                        This is fine. But sometime, you want to see whether this is bound to which jndi name in "java:" namespace. For that you have to run JndiView MBean (which u can see in the jmx-console.


                        Also, you did not mentioned, from where you are running the client? are you running it from outside the Jboss?? or from within the jboss?? I have tested from within jboss like, jsp, session bean, etc. and it works fine.