Gnana
Gnana

Reputation: 2230

Fuse OSGI + Spring JDBC issue

I am new to OSGI development. I want to insert records to DB using Spring JDBC in Fuse server. I developed standalone SpringJDBC code, it is working good. I have converted to blueprint standard. while installing package in Fuse server, I am getting below mentioned error. I hope that Spring jars are not available in Fuse server. please help me to fix this and appreciate any sample tutorial or code.

Server : Jboss Fuse 6.2.1

Error :

**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 Configuration

<!-- 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>

Upvotes: 4

Views: 1550

Answers (2)

Pratiyush Kumar Singh
Pratiyush Kumar Singh

Reputation: 1997

You would require to install required dependencies.

features:install camel-sql 
features:install camel-jdbc

I see User name and password is missing as well. I did similar things with 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>

Also you should check your location spaces.

    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">    

Upvotes: 0

Alessandro Da Rugna
Alessandro Da Rugna

Reputation: 4695

From JBoss Fuse console, type

features:install spring-jdbc

this will install the required packages. A quick check with

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

will tell you that the bundle 276 is exporting such packages. (the bundle id number may vary in your installation)

If you need some other library, check with features:list command, it may already be distribuited as a feature.

Upvotes: 0

Related Questions