Announcement Announcement Module
Collapse
No announcement yet.
Using database introspection with DB2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using database introspection with DB2

    Hi,

    I am new to Spring Roo and am looking into it to see if it would be useful for an upcoming project. I would like to use the database introspection add on to generate the entities. From the documentation I have read, in order to accomplish this I need to convert the db2jcc4.jar to osgi. I found some posts on this subject. However, I am running into issues in doing the maven bundle:bundle. The errors I am getting are posted below. I have tried to google this issue, but have not found any resolution. Does anyone know how I can resolve this problem?

    I have been following http://forum.springsource.org/showth...spection-fails in order to use introspection with DB2. Specifically:
    1. I created a wrapper project
    2. I started roo and ran the following command (consequently, I renamed the existing pom.xml first as it initially complained that it already existed): addon create wrapper --topLevelPackage com.ibm.db2.roo.jdbc --groupId com.ibm --artifactId db2jcc4 --version 9.7.2 --vendorName IBM --licenseUrl http://www-01.ibm.com/software/data/db2
    3. I editied the pom.xml to include the following line:
    Import-Package>COM.ibm.db2os390.*;resolution:=optional,co m.ibm.websphere.*;resolution:=optional,javax.*;res olution:=optional,org.wc.*;resolution:=optional,or g.xml.*;resolution:=optional,sqlj.*;resolution:=op tional,org.ietf.jgss;resolution:=optional,sun.*;re solution:=optional</Import-Package>
    4. I did a maven bundle:bundle - I understand this step should create the osgi jar for db2. I am getting errors on this step


    5. Once step four is complete, I should be able to run: osgi start --url file:///tmp/org.springframework.roo.wrapping.db2jcc4-9.7.2.0001.jar
    5. Setup persistence: persistence setup --provider HIBERNATE --database DB2_EXPRESS_C
    6. Now should be able to run the database introspect and database reverse engineer commands


    === here are the errors I am getting from running maven bundle:bundle ======
    mvn bundle:bundle
    [INFO] Scanning for projects...
    [WARNING] POM for 'biz.aQute:bndlibom:1.15.0:runtime' is invalid.

    Its dependencies (if any) will NOT be available to the current build.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building com-ibm-db2-roo-jdbc
    [INFO] task-segment: [bundle:bundle]
    [INFO] ------------------------------------------------------------------------
    Downloading: http://repo1.maven.org/maven2/com/ib...jcc4-9.7.2.pom
    [INFO] Unable to find resource 'com.ibm:db2jcc4om:9.7.2' in repository central (http://repo1.maven.org/maven2)
    Downloading: http://repo1.maven.org/maven2/com/ib...e_cu-1.3.1.pom
    [INFO] Unable to find resource 'com.ibm.db2:db2jcc_license_cuom:1.3.1' in repository central (http://repo1.maven.org/maven2)
    [INFO] [bundle:bundle {execution: default-cli}]
    [WARNING] Warning building bundle com.ibm.db2.roo.jdbc:com.ibm.db2.roo.jdbc.db2jcc4: bundle:9.7.2.0001 : Split package META-INF
    Use directive -split-package:=(merge-first|merge-last|error|first) on Export/Private Package instruction to get rid of this warning
    Package found in [Jar:db2jcc4, Jar:db2jcc_license_cu]
    Reference from C:\Documents and Settings\i026526\.m2\repository\com\ibm\db2\db2jcc _license_cu\1.3.1\db2jcc_license_cu-1.3.1.jar
    Classpath [Jar:db2jcc4, Jar:db2jcc_license_cu]
    [ERROR] Error building bundle com.ibm.db2.roo.jdbc:com.ibm.db2.roo.jdbc.db2jcc4: bundle:9.7.2.0001 : Unresolved references to [com.ibm.zos.batch.contai
    ner.support, com.ibm.zos.batch.container.support.transaction] by class(es) on the Bundle-Classpath[Jar:dot]: [com/ibm/db2/jcc/t2zos/i.class, com/ibm/d
    b2/jcc/t2zos/T2zosBatchContainerSupport.class]
    [ERROR] Error(s) found in bundle configuration
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Error(s) found in bundle configuration

    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3 seconds
    [INFO] Finished at: Sun May 22 17:14:23 EDT 2011
    [INFO] Final Memory: 9M/21M
    [INFO] ------------------------------------------------------------------------
    C:\Documents and Settings\i026526\Documents\workspace-sts-2.6.1.RELEASE\wrapper>


    ======= Here is my pom for the wrapper project ================


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ibm.db2.roo.jdbc</groupId>
    <artifactId>${project.groupId}.${pkgArtifactId}</artifactId>
    <packaging>bundle</packaging>
    <version>${osgiVersion}</version>
    <name>com-ibm-db2-roo-jdbc</name>
    <description>This bundle wraps the standard Maven artifact: ${pkgArtifactId}-${pkgVersion}.</description>
    <properties>
    <pkgArtifactId>db2jcc4</pkgArtifactId>
    <pkgVersion>9.7.2</pkgVersion>
    <osgiVersion>${pkgVersion}.0001</osgiVersion>
    <pkgVendor>IBM</pkgVendor>
    <pkgDocUrl/>
    <pkgLicense>http://www-01.ibm.com/software/data/db2</pkgLicense>
    <repo.folder>com/ibm/db2/roo/jdbc</repo.folder>
    <google.code.project.name>${project.name}</google.code.project.name>
    </properties>

    <dependencies>
    <dependency>
    <groupId>com.ibm</groupId>
    <artifactId>db2jcc4</artifactId>
    <version>9.7.2</version>
    <optional>true</optional>
    </dependency>
    </dependencies>
    <scm>
    <connection>scm:svn:https://${google.code.project.name}.googlecode.com/svn/trunk</connection>
    <developerConnection>scm:svn:https://${google.code.project.name}.googlecode.com/svn/trunk</developerConnection>
    <url>http://code.google.com/p/${google.code.project.name}/source/browse</url>
    </scm>
    <distributionManagement>
    <repository>
    <id>Google Code</id>
    <url>dav:https://${google.code.project.name}.googlecode.com/svn/repo</url>
    </repository>
    </distributionManagement>
    <build>
    <extensions>
    <extension>
    <groupId>org.apache.maven.wagon</groupId>
    <artifactId>wagon-webdav-jackrabbit</artifactId>
    <version>1.0-beta-6</version>
    </extension>
    </extensions>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>1.1</version>
    <executions>
    <execution>
    <id>sign-artifacts</id>
    <phase>verify</phase>
    <goals>
    <goal>sign</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
    <remoteOBR>true</remoteOBR>
    <bundleUrl>httppgp://${google.code.project.name}.googlecode.com/svn/repo/${repo.folder}/${project.artifactId}/${project.version}/${project.artifactId}-${project.version}.jar</bundleUrl>
    <instructions>
    <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
    <Export-Package>*;version=${pom.version}</Export-Package>
    <Bundle-Vendor>${pkgVendor} (wrapped into an OSGi bundle by the Spring Roo project build system)</Bundle-Vendor>
    <Bundle-DocURL>${pkgDocUrl}</Bundle-DocURL>
    <Bundle-License>${pkgLicense}</Bundle-License>
    <Import-Package>COM.ibm.db2os390.*;resolution:=optional,co m.ibm.websphere.*;resolution:=optional,javax.*;res olution:=optional,org.w3c.*;resolution:=optional,o rg.xml.*;resolution:=optional,sqlj.*;resolution:=o ptional,org.ietf.jgss;resolution:=optional,sun.*;r esolution:=optional</Import-Package>
    </instructions>
    </configuration>
    </plugin>
    </plugins>
    </build>
    </project>

  • #2
    I think this is your problem:

    Originally posted by greenek View Post
    Downloading: http://repo1.maven.org/maven2/com/ib...jcc4-9.7.2.pom
    [INFO] Unable to find resource 'com.ibm:db2jcc4om:9.7.2' in repository central (http://repo1.maven.org/maven2)


    As far as i know, the only legal way to get IBM's DB2 jdbc driver is from IBM itself. You can download the Express-C version of the database for free (google "download ibm db2"), and that's the easiest way to get the driver. Once you have db2jcc4.jar, you need to put it into your local Maven repository:

    Code:
    mvn install:install-file -Dfile=db2jcc4.jar -DgroupId=com.ibm -DartifactId=db2jcc4 -Dversion=9.7.2  -Dpackaging=jar -DgeneratePom=true
    and the rest should work as described.

    Comment


    • #3
      Thanks for your response. I tried that. The issue I believe is that some classes in db2jcc4.jar import ibm.zos.batch classes such as com.ibm.zos.batch.container.support.transaction.BC DSynchronization. These classes are not included in this jar nor any other jar included in the db2express installation.

      For now, I am going to plan B, which is to generate the entity beans and have spring roo generate the schema. Hopefully osgi drivers are not required for that.

      Comment


      • #4
        Which version of db2jcc4.jar do you use?

        The ImportPackage element in the pom is meant to resolve just that type of issue. You might try to add com.ibm.zos.batch.*;resolution:=optional to the list.

        Comment


        • #5
          Thanks!!! That was it. I added that import and now I got the entities to generate. Thanks much!

          Comment

          Working...
          X