Problem getting MySQL DataSource in JBoss

Discussions

EJB programming & troubleshooting: Problem getting MySQL DataSource in JBoss

  1. Problem getting MySQL DataSource in JBoss (2 messages)

    I am trying to connect to MySQL in JBoss and have problems in getting the DataSource from the JNDI. I can connect to MySQL from the command line (mysql) though.

    The MySQL JDBC driver jar file is copied to server/default/lib directory.

    I have a mysql-ds.xml copied over to server/default/deploy directory of JBoss with the following entry:

    <datasources>
      <local-tx-datasource>
       <jndi-name>jdbc/MySQLDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/foodb</connection-url>
       <driver-class>org.gjt.mm.mysql.Driver</driver-class>
       <user-name>foo</user-name>
       <password>foo</password>
      </local-tx-datasource>
    </datasources>

    The JBoss Console at http://localhost:8080/jmx-console/index.jsp does show jdbc/MySQLDB:

    name=jdbc/MySQLDS,service=LocalTxCM
    name=jdbc/MySQLDS,service=ManagedConnectionFactory
    name=jdbc/MySQLDS,service=ManagedConnectionPool


    My Java code snippet (which is in an EJB implementation) has:
    Properties env = new Properties();

    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "org.jnp.interfaces.NamingContextFactory");
    env.put(Context.URL_PKG_PREFIXES,
    "jboss.naming:org.jnp.interfaces");
    env.put(Context.PROVIDER_URL, "localhost:1099");
            Context ctx = new InitialContext(env);
            DataSource ds = (DataSource)ctx.lookup("jdbc/MySQLDS");

    I get the following exception.

    javax.naming.NameNotFoundException: jdbc not bound
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
            at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
  2. The JBoss site has a Datasource configuration forum.
    This has been discussed several times there.

    - vineet
  3. That doesn't help...[ Go to top ]

    I have the same question. I looked in the JBoss forums, and somebody posted a smart @ss remark, "look it up with google." I did a search with google, which took me to this page. If you know the answer or have a link to the JBoss thread, please post it.