creating OSGi enabled jar for ORACLE (for Spring Roo - ORACLE db integration)
I'm hitting the Spring Roo / Oracle OSGi driver issue that plenty of others have hit and seem to have solved.
"Springsource currently can't host an OSGi wrapped Oracle driver" so it appears you need to take you existing non-OSGi one a wrap it.
I've been following the steps here with the driver for Oracle 11g, version 2's driver.
Got completely stuck with step 11,
- Remove the faulty OSGI driver from the Felix repository:
- Use “osgi ps” to retrieve the ID of the OSGI bundle to remove.
- Use “osgi headers” to get the Bundle-SymbolicName of the corresponding OSGI bundle. Probably
com.oracle.roo.jdbc.ojdbc5
orcom.oracle.roo.jdbc.ojdbc6
. - Use
osgi uninstall –bundleSymbolicName com.oracle.roo.jdbc.ojdbcx
I've no background with osgi at all and despite getting the com.sun.security.auth.module
missing dependency indicated when you run:
roo> database reverse engineer --shema xxx
can't progress with the osgi phases to uninstall these dependencies from OSGi.
Could anyone console dump the commands to do this, however noddy.
Much appreciated - Roo allows a basic app to b开发者_如何学Ce build real fast, but roo-oracle is a drop of a cliff, compared to the ease and speed of everything else.
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 directory with oracle jar 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.
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)
This shows the id of the com-oracle-roo-jdbc bundle: 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 details for the bundle com-oracle-roo-jdbc (68) and, in particular, the “Bundle-SymbolicName” value
roo> osgi uninstall com.oracle.roo.jdbc.ojdbc5
That’s it. Removed.
So as of 2016 (Spring Roo 1.3.2) for who ever searching how to uninstall OSGi, below is what worked for me.
roo> osgi uninstall --bundleSymbolicName "com.oracle.roo.jdbc.ojdbc6"
Bundle 'com.oracle.roo.jdbc.ojdbc6' : Uninstalled!
精彩评论