为ORACLE创建支持OSGi的jar(适用于Spring Roo - ORACLE db集成)

时间:2011-09-05 23:59:15

标签: spring oracle osgi

我遇到了Spring Roo / Oracle OSGi驱动程序问题,很多其他人已经遇到并且似乎已经解决了这个问题。

“Springsource目前无法托管OSGi包装的Oracle驱动程序”,因此您需要将现有的非OSGi包裹起来。

我一直在使用Oracle 11g驱动程序(版本2的驱动程序)执行步骤here

完全陷入第11步,

  1. 从Felix存储库中删除有问题的OSGI驱动程序:
    • 使用“osgi ps”检索要删除的OSGI包的ID。
    • 使用“osgi headers”获取相应OSGI包的Bundle-SymbolicName。可能是com.oracle.roo.jdbc.ojdbc5com.oracle.roo.jdbc.ojdbc6
    • 使用osgi uninstall –bundleSymbolicName com.oracle.roo.jdbc.ojdbcx
  2. 我根本没有osgi的背景,尽管在你运行时显示com.sun.security.auth.module缺少依赖关系:

    roo> database reverse engineer --shema xxx
    

    无法使用osgi阶段从OSGi中卸载这些依赖项。

    任何人都可以通过控制台转储执行此操作的命令,但不是很笨拙。

    非常感谢 - Roo允许基本的应用程序快速构建,但与其他所有内容的易用性和速度相比,roo-oracle是一滴悬崖。

3 个答案:

答案 0 :(得分:3)

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.     

为了解决这个问题我做了:     在带有oracle jar文件的目录中:

[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. 

答案 1 :(得分:2)

我的帖子中提到的命令(http://nidget.wordpress.com/2011/07/21/how-to-osgify-an-oracle-jdbc-driver-with-spring-roo/)是roo命令

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)

这显示了com-oracle-roo-jdbc包的id: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 = …

检查bundle com-oracle-roo-jdbc(68)的详细信息,特别是“Bundle-SymbolicName”值

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

就是这样。除去。

答案 2 :(得分:0)

截至2016年(Spring Roo 1.3.2),谁曾经搜索过如何卸载OSGi,下面是对我有用的。

  

袋鼠&GT; osgi uninstall - bundleSymbolicName “com.oracle.roo.jdbc.ojdbc6”

     

捆绑'com.oracle.roo.jdbc.ojdbc6':已卸载!