5 Replies Latest reply on Mar 19, 2013 2:09 AM by paulc8712

    hooking up JDBC datasource

    paulc8712

      Hi again.

       

      Another step (not sure if forwards or backwards) on the road to getting JPA working.  Having resolved my JDBC bundle package importing (and actually seeing it working), I am now getting the following weird error when I install my bundle into FuseESB:

       

      Found bean: dataSource in BlueprintContainer: org.apache.aries.blueprint.container.BlueprintContainerImpl@11c2555 of type: org.springframework.jdbc.datasource.SimpleDriverDataSource

      expected type was:

      interface javax.sql.DataSource

       

      This is confusing me. I thought that SimpleDriverDataSource implemented the javax.sql.DataSource interface.  Could it be that I am somehow importing an incorrect bundle or have an incorrect dependency?

       

      Any help would be greatly appreciated.

        • 1. Re: hooking up JDBC datasource
          ffang

          Hi,

           

          This generally means you have two copy of javax.sql.DataSource in your container, but loaded by different classloaders.

           

          Most likely your customer bundle embed jar which have javax.sql.DataSource or some other bundle also export it.

           

          You can use "packages:exports |grep javax.sql"

          to check it out,  it should be from system bundle 0, and your customer bundle should Import-Package javax.sql, also your customer bundle shouldn't embed javax.sql.DataSource .

           

          Freeman

          • 2. Re: hooking up JDBC datasource
            paulc8712

            I checked which packages export 'javax.sql' using packages:exports |grep javax.sql.

            It turns out package 0, and my JDBC driver wrapper package both do.

            I changed my package to not export javax.sql, and I still have the same issue.

             

            I then checked which packages include the SimpleDriverDataSource class:

            FuseESB:admin@root> osgi:find-class SimpleDriverDataSource

             

            Spring JDBC (253)

            org/springframework/jdbc/datasource/SimpleDriverDataSource.class

            org/springframework/jdbc/datasource/embedded/SimpleDriverDataSourceFactory$1.class

            org/springframework/jdbc/datasource/embedded/SimpleDriverDataSourceFactory.class

             

            Spring ORM (255)

            org/springframework/jdbc/datasource/SimpleDriverDataSource.class

             

            OpenJPA Aggregate Jar (256)

            org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.class

             

            MyApplication (267)

            org/springframework/jdbc/datasource/SimpleDriverDataSource.class

             

            Could this be a problem?

            • 3. Re: hooking up JDBC datasource
              ffang

              Yes, it could be

              At least MyApplication bundle shouldn't embed Spring JDBC.

               

              Freeman

              • 4. Re: hooking up JDBC datasource
                paulc8712

                This is no doubt showing my ignorance here - what what do you mean by 'embed'? A dependency listed in the POM file?

                • 5. Re: hooking up JDBC datasource
                  paulc8712

                  I seem to have my JDBC working .. however getting it started is convoluted, and I do not understand why what I do works.

                   

                  install my fuse package (packaged as a 'jar') via FAB with the -s option (to start):

                  osgi:install -s fab:mvn:com.mycompany/myapplication/1.0.0-SNAPSHOT

                  this fails.  however if i do not sopeciify the -s option, the following steps do not work.

                   

                  dev:dynamic-import <ID>

                   

                  resolve <ID>

                   

                  packages:imports <ID>

                   

                  This now lists my JDBC bundle as an import.  I can now start the package.

                   

                  start <ID>

                   

                  FWIW, I am specifying the <DynamicImport-Package>, but it seems to be making no difference. I will obviously need to come pack and work out why this is happening, but I have a basic JDBC connection working, so I nede to move on to try and get some productive development done.  I am expecting some pain with JPA, which is my next step.