2 Replies Latest reply on Oct 13, 2004 4:35 AM by kirannuthati

    Tomcat JNDI Datasource now in JBOSS

    juan110470

      I have an application which has been developed in Tomcat. I configured a datasource in Tomcat in the server.xml that comes with Tomcat.









      ...



      I also have the following entry in the web.xml of my web application:
      <resource-ref>
      DB Connection
      <res-ref-name>jdbc/MySqlDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      These two steps allow my application to gain access to the datasource through the name space:
      java:comp/env/jdbc/securanceDatasource

      My question is how do I configure this exact datasource in jboss so that my application can access it transparently. I have tried this:


      <local-tx-datasource>
      <jndi-name>securanceDatasource</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/securance</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>user</user-name>
      pass
      </local-tx-datasource>


      But this doesn't work. When I try starting jboss I get a huge stacktrace of errors. I am sure that the mysql driver is in the lib folder of the server I am working in.

      Thanks in advance

        • 1. Re: Tomcat JNDI Datasource now in JBOSS
          genman


          1. Use the "Quote" feature around your configuration
          2. Take a look at the example datasource conf. in the docs directory
          3. Post appropriate parts of a stack trace; just saying you get "a huge stacktrace of errors" doesn't really convey much.

          • 2. Re: Tomcat JNDI Datasource now in JBOSS
            kirannuthati

            Hi

            'java:comp/env/jdbc/securanceDatasource'
            If use like this it won't work according to jboss docs u need to use like 'java:/securanceDatasource'

            If u r not intrested to change class files of ur application, u need to modify the method 'public Name parse(String name)' of 'org.jnp.interfaces.NamingParser.class' located in 'jnpserver.jar'

            Modify the method just like this

            public Name parse(String name)
            throws NamingException
            {
            if (name.equals("java:comp/env/jdbc/securanceDatasource")) name="java:/securanceDatasource";
            return new CompoundName(name, syntax);
            }
            It may work for ur application, but to generalize play around it.