Creating a jar with OSGi support for ORACLE (for Spring Roo integration - ORACLE db)

I am solving a problem with the Spring Roo / Oracle OSGi driver, which many others have already solved and seem to have solved.

"Springsource cannot currently host the Oracle driver in the OSGi shell," so it seems you need to wrap the existing non-OSGi.

I followed the steps here with the driver for Oracle 11g, driver version 2.

Stuck in step 11,

  1. Remove the failed OSGI driver from the Felix repository:
    • Use "osgi ps" to get the OSGI package ID to remove.
    • Use the osgi headers to get the Bundle-SymbolicName of the corresponding OSGI package. Maybe com.oracle.roo.jdbc.ojdbc5 or com.oracle.roo.jdbc.ojdbc6 .
    • Use osgi uninstall –bundleSymbolicName com.oracle.roo.jdbc.ojdbcx

I don’t have any experience with osgi at all, and even though you started the missing com.sun.security.auth.module dependency listed below at startup:

 roo> database reverse engineer --shema xxx 

cannot progress with OSGI phases to remove these dependencies from OSGi.

Can anyone console reset the commands to do this, however Noddy.

Very grateful - Roo allows you to create basic applications very quickly, but roo-oracle is a drop of cliff compared to the simplicity and speed of everything else.

+4
source share
3 answers

The commands mentioned in my post (http://nidget.wordpress.com/2011/07/21/how-to-osgify-an-oracle-jdbc-driver-with- spring-roo /) are roo commands.

 roo> osgi ps START LEVEL 99 ID State Level Name [ 0] [Active ] [ 0] System Bundle (3.0.7) [ 1] [Active ] [ 1] jansi (1.5) … [ 68] [Resolved ] [ 1] com-oracle-roo-jdbc (11.2.0.2_0001) 

Package ID of com-oracle-roo-jdbc is displayed here: 68

 roo> osgi headers … com-oracle-roo-jdbc (68) β€”β€”β€”β€”β€”β€”β€”β€” Bnd-LastModified = 1309962402810 Build-Jdk = 1.6.0_07 Built-By = jplandrain Bundle-Description = This bundle wraps the standard Maven artifact: ojdbc5-11.2.0.2. Bundle-License = http://www.oracle.com Bundle-ManifestVersion = 2 Bundle-Name = com-oracle-roo-jdbc Bundle-SymbolicName = com.oracle.roo.jdbc.ojdbc5 Bundle-Vendor = Oracle (wrapped into an OSGi bundle by the Spring Roo project build system) Bundle-Version = 11.2.0.2_0001 Created-By = Apache Maven Bundle Plugin Export-Package = … 

Check the package details com-oracle-roo-jdbc (68) and, in particular, the value "Bundle-SymbolicName"

 roo> osgi uninstall com.oracle.roo.jdbc.ojdbc5 

Here it is. Deleted.

+2
source
 NOTE: "CMD>" indicates from the command prompt, "roo>" indicates from within the roo shell, which can be accessed from the command prompt, by typeing "roo", provided the roo binary in on the environment path. 

To fix this, I did: In the directory with the oracle file:

 [1] CMD> mvn install:install-file -Dfile=ojdbc5-11.2.0.2.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.2 -Dpackaging=jar [2] start roo, and run: roo> addon create wrapper --topLevelPackage com.oracle.roo.JDBC --groupId com.oracle --artifactId ojdbc5 --version 11.2.0.2 --vendorName Oracle --licenseUrl http://www.oracle.com [3] need to remove some dependencies from the generated file (com.oracle.roo.jdbc.ojdbc5-11.2.0.2.0001.jar in this case), open jar in 7zip or other and edit manifest.MF file and remove from the "Import-Package:" bit in MINIFEST.MF: com.sun.security.auth.module oracle.i18n.text, oracle.i18n.text.converter oracle.ons,oracle.security.pki [4] install the following dependencies (get from http://ebr.springsource.com/repository/app/, search on this site for the groupIds below) into mvn: CMD> mvn install:install-file -Dfile=com.springsource.javax.resource-1.5.0.jar -DgroupId=javax.resource -DartifactId=com.springsource.javax.resource -Dversion=1.5.0 -Dpackaging=jar CMD> mvn install:install-file -Dfile=com.springsource.javax.transaction-1.1.0.jar -DgroupId=javax.transaction -DartifactId=com.springsource.javax.transaction -Dversion=1.1.0 -Dpackaging=jar CMD> mvn install:install-file -Dfile=ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.2 -Dpackaging=jar [5] in roo, run roo> osgi install --url file:///c:\users\alex\com.springsource.javax.transaction-1.1.0.jar roo> osgi install --url file:///c:\users\alex\com.springsource.javax.resource-1.5.0.jar roo> osgi install --url file:///c:\path\to\current\dir\oracle\file_generated_by_wrapper.jar [6] to check these files have made it ok type roo> osgi ps gives: [ 62] [Active ] [ 1] Spring Roo - Wrapping - jline (0.9.94.0010) [ 63] [Active ] [ 1] Spring Roo - Wrapping - json-simple (1.1.0.0010) [ 64] [Active ] [ 1] Spring Roo - Wrapping - protobuf-java-lite (2.3.0.0001) [ 65] [Active ] [ 1] Spring User Agent Analysis - Client (1.0.2.RELEASE) [ 69] [Active ] [ 1] Java Resource API (1.5.0) [ 70] [Active ] [ 1] com-oracle-roo-jdbc (11.2.0.2_0001) [ 72] [Installed ] [ 1] Java Transaction API (1.1.0) basically 'Active' is what you want - run: roo> osgi start --url file:///c:\users\alex\com.springsource.javax.transaction-1.1.0.jar to change 'Installed' to 'Active' [7] in roo, run: roo> database reverse engineer --schema <schema> if you get a 'Framework error' then you need to open up the manifest of your jar and delete more oracle imports (the above list *should* be sufficient) - only remove from the imports section tho. once you've changed the jar, reload into OSGi with: roo> osgi uninstall --bundleSymbolicName com.oracle.roo.jdbc.ojdbc5 roo> osgi start --url file:///c:\users\alex\com.oracle.roo.jdbc.ojdbc5-11.2.0.2.0001.jar re-run: roo> database reverse engineer --schema <schema> to verify. Add a table into the schema and get DBA to grant access to get stuff to actually be generated. 
+3
source

So, starting in 2016 (Spring Roo 1.3.2) for those who have ever been looking for how to remove OSGi, below is what worked for me.

roo> osgi uninstall - bundleSymbolicName "com.oracle.roo.jdbc.ojdbc6"

Bundle 'com.oracle.roo.jdbc.ojdbc6': Uninstalled!

0
source

All Articles