我遇到了 Spring Roo/Oracle OSGi 驱动程序问题,很多其他人都遇到过并且似乎已经解决了这个问题。
“Springsource 当前无法托管 OSGi 包装的 Oracle 驱动程序”,因此您似乎需要将现有的非 OSGi 驱动程序包装起来。
我一直在按照步骤操作 here使用 Oracle 11g 驱动程序,版本 2 的驱动程序。
完全卡在第 11 步,
com.oracle.roo.jdbc.ojdbc5
或 com.oracle.roo.jdbc.ojdbc6
. osgi uninstall –bundleSymbolicName com.oracle.roo.jdbc.ojdbcx
我根本没有 osgi 的背景,尽管得到了
com.sun.security.auth.module
运行时指示缺少依赖项:roo> database reverse engineer --shema xxx
无法通过 osgi 阶段从 OSGi 卸载这些依赖项。
任何人都可以控制台转储执行此操作的命令,但是点头。
非常感谢 - Roo 允许快速构建一个基本的应用程序,但与其他一切的易用性和速度相比,roo-oracle 是一个悬崖峭壁。
最佳答案
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.
关于spring - 为 ORACLE 创建启用 OSGi 的 jar(用于 Spring Roo - ORACLE db 集成),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7313722/