我是OSGI开发的新手。我想在Fuse服务器中使用Spring JDBC将记录插入到DB中。我开发了独立的SpringJDBC代码,它运行良好。我已经转换为蓝图标准。在Fuse服务器中安装软件包时,我收到了下面提到的错误。我希望Fuse服务器中没有Spring jar。请帮我解决这个问题并感谢任何示例教程或代码。
服务器:Jboss Fuse 6.2.1
错误:
**Error executing command: Error installing bundles:
Unable to start bundle file:My repositorypath/myapplication.jar Unresolved constraint in bundle homeloan [302]: Unable to resolve 302.0: missing requirement [302.0] osgi.wiring.package; (osgi.wiring.package=org.springframework.jdbc.core)**
POM配置
<!-- to generate the MANIFEST-FILE of the bundle -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>homeloan</Bundle-SymbolicName>
<Private-Package>org.blogdemo.homeloan.*</Private-Package>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
MANIFAEST
**DynamicImport-Package: *
Export-Package: org.blogdemo.homeloan.model;uses:="javax.xml.bind.annota
tion";version="1.0.0.SNAPSHOT",org.blogdemo.homeloan.processor;uses:="o
rg.blogdemo.homeloan.model,org.apache.camel,javax.sql,org.springframewo
rk.jdbc.core";version="1.0.0.SNAPSHOT"
Import-Package: javax.sql,javax.xml.bind.annotation,org.apache.activemq.
camel.component;version="[5.9,6)",org.apache.camel;version="[2.12,3)",o
rg.osgi.service.blueprint;version="[1.0.0,2.0.0)",org.springframework.j
dbc.core,org.springframework.jdbc.datasource
Tool: Bnd-1.50.0**
blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61617" />
<property name="userName" value="admin" />
<property name="password" value="admin" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
>
<property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
<property name="url" value="jdbc:derby://localhost:1527/c:/temp/db/FAQ/doldb;create=true"/>
</bean>
<bean id="myProcessor" class="org.blogdemo.homeloan.processor.MyProcessor">
<property name="dataSource" ref="dataSource" />
</bean>
答案 0 :(得分:0)
从JBoss Fuse控制台,输入
features:install spring-jdbc
这将安装所需的包。快速检查
JBossFuse:karaf@root> exports | grep springframework.jdbc
276 org.springframework.jdbc; version=3.2.12.RELEASE
276 org.springframework.jdbc.core.simple; version=3.2.12.RELEASE
276 org.springframework.jdbc.core.namedparam; version=3.2.12.RELEASE
....
将告诉您捆绑包276正在导出此类包。 (软件包ID号可能会因安装而异)
如果您需要其他库,请查看features:list
命令,它可能已经作为功能分发。
答案 1 :(得分:0)
您需要安装所需的依赖项。
features:install camel-sql
features:install camel-jdbc
我看到用户名和密码也丢失了。 我和Oracle做过类似的事情。
<bean id="oracleConnectionCacheProperties" class="java.util.Properties">
<argument>
<props>
<prop key="MinLimit" value="${database.connectionCache.minLimit}" />
<prop key="MaxLimit" value="${database.connectionCache.maxLimit}" />
<prop key="ValidateConnection" value="${database.connectionCache.validateConnection}" />
<prop key="InactivityTimeout" value="${database.connectionCache.inactivityTimeout}" />
</props>
</argument>
</bean>
<bean id="oracleInstance" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
<property name="URL" value="${oracleDataSource.url}" />
<property name="user" value="${database.user}" />
<property name="password" value="${database.password}" />
<property name="connectionCachingEnabled" value="true" />
<property name="connectionCacheProperties" ref="oracleConnectionCacheProperties" />
</bean>
<bean id="sqlComponentInstance" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="oracleInstance" />
</bean>
另外,您应该检查您的位置空间。
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd">