1
votes

I'm trying to connect oracle database using org.springframework.jdbc.core.JdbcTemplate in OSGI bundle. When deploying bundle in servicemix , it shows error

org.osgi.framework.BundleException: Unresolved constraint in bundle My Second Service [376]: Unable to resolve 376.0: missing requirement [376.0] package; (package=org.springframework.jdbc.core)

And here is my pom file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.my.service</groupId>
    <artifactId>my-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../my-service/pom.xml</relativePath>
</parent>

<groupId>com.brodos.osgi</groupId>
<artifactId>my-second-service</artifactId>
<packaging>bundle</packaging>
<version>0.0.1-SNAPSHOT</version>

<name>My Second Service</name>
<url>http://example.net</url>

<dependencies>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>2.8.0-fuse-01-13</version>
    </dependency>
    <dependency>
        <groupId>springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>1.2.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <version>1.4.3</version>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>My Second Service</Bundle-SymbolicName>
                    <Bundle-Description>My Second Service</Bundle-Description>
                    <Import-Package>
                        org.apache.servicemix.camel.nmr,
                        org.apache.servicemix.nmr.api,
                        org.apache.servicemix.nmr.api.event,
                        org.apache.servicemix.nmr.api.internal,
                        *
                    </Import-Package>
                    <Private-Package>com.test.osgi.*</Private-Package>
                    <Include-Resource>src/main/resources</Include-Resource>
                    <DynamicImport-Package>*</DynamicImport-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

2

2 Answers

1
votes

You need to install the bundle that exports the org.springframework.jdbc.core package.

1
votes

Jignesh, this may be worth looking at:

Download this jar from ebr.springsource.com:

Since you are in an OSGi environment, you will also require other bundles like org.springframework.osgi.core org.springframework.osgi.io and org.springframework.osgi.extender. These will also require some additional bundles like org.apache.commons. You may have to fiddle a bit with MANIFEST.MF to match versions to make it run.

Take a look at this tutorial to get an idea: I was able to import and run this.

Note* As of now I am doing this integration manually...I hope to use maven as things get clear for me.