4 Replies Latest reply on Apr 24, 2003 11:53 AM by samirny

    Migrating to JBoss 2.3: can't look up data source

    kirillburyak

      How can this code:
      ds = (DataSource) ctx.lookup("java:comp/env/"+jndiName);

      cause this:
      java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrapperDataSource

        • 1. Re: Migrating to JBoss 2.3: can't look up data source
          davidjencks

          Maybe you have more than one copy of DataSource loaded somehow? I'd put some logging in to investigate the superclasses and classloaders of what you look up and the classloader of DataSource.

          • 2. Re: Migrating to JBoss 2.3: can't look up data source
            kirillburyak

            Thanks for your help, David,

            Yes, I did have a classloader problem, javax.sql.DataSource was being loaded from jdbc2_0-stdext.jar (which is a part of Struts distribution)

            After I removed jdbc2_0-stdext.jar, the problem was resolved.

            Kirill

            • 3. Re: Migrating to JBoss 2.3: can't look up data source
              samirny

              Hi,
              I am newbie to Jboss.I am using jboss-3.2.0_tomcat-4.1.24. I got the same exception.I am not using any struts.jar..I am running with default jboss config.
              I created OracleDS Pool as define in examples jca.

              in the web.xml the following config:
              <resource-ref>
              Oracle Datasource example
              <res-ref-name>jdbc/myoracle</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              </resource-ref>

              In the jsp I am using the following code:
              Context ctx = new InitialContext();
              if(ctx == null )
              throw new Exception("- No Context");

              Context envContext = (Context)ctx.lookup("java:OracleDS");
              DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");



              Am I doing something wrong?
              Please reply.
              thanks.

              • 4. Re: Migrating to JBoss 2.3: can't look up data source
                samirny

                my mistake.
                it is working ok now.
                sorry.
                Context ctx = new InitialContext();
                DataSource ds= (DataSource)ctx.lookup("java:/OracleDS");

                Connection conn = ds.getConnection();