3

I try to develop a starter application for Apache ServiceMix dealing with web services.

1) I build the app (using 'mnv install' command)

2) Deploy it to ServiceMix (using 'karaf@root> osgi:install mvn:com.company/ws-test-fuse/1.0.0-SNAPSHOT' command at server console)

3) watch how it got installed ('osgi:list')

[ 157] [Installed  ] [            ] [       ] [   60] A Camel Spring Route (1.0.0.SNAPSHOT)

4) I try to start the app

karaf@root>osgi:start 157

I get this:

org.osgi.framework.BundleException: Unresolved constraint in bundle com.company.ws-test-fuse [157]: Unable to resolve 157.0: missing requirement [157.0] package; (&(package=commonj.sdo)(version>=2.1.0)(!(version>=3.0.0)))

What is a correct way to install a bundle so all the maven dependencies get downloaded and installed automatically?

Also, I am right that all the dependencies will be deployed to the osgi-container as osgi-bundles too?

My POM.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
    license agreements. See the NOTICE file distributed with this work for additional 
    information regarding copyright ownership. The ASF licenses this file to 
    You under the Apache License, Version 2.0 (the "License"); you may not use 
    this file except in compliance with the License. You may obtain a copy of 
    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. -->
<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>

    <groupId>com.company</groupId>
    <artifactId>ws-test-fuse</artifactId>
    <packaging>bundle</packaging>
    <version>1.0.0-SNAPSHOT</version>

    <name>A Camel Spring Route</name>
    <url>http://www.myorganization.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <repositories>
        <repository>
            <id>release.fusesource.org</id>
            <name>FuseSource Release Repository</name>
            <url>http://repo.fusesource.com/nexus/content/repositories/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
        <repository>
            <id>snapshot.fusesource.org</id>
            <name>FuseSource Snapshot Repository</name>
            <url>http://repo.fusesource.com/nexus/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
        <repository>
            <id>ea.fusesource.org</id>
            <name>FuseSource Early Access Repository</name>
            <url>http://repo.fusesource.com/nexus/content/groups/ea</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>release.fusesource.org</id>
            <name>FuseSource Release Repository</name>
            <url>http://repo.fusesource.com/nexus/content/repositories/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
        <pluginRepository>
            <id>snapshot.fusesource.org</id>
            <name>FuseSource Snapshot Repository</name>
            <url>http://repo.fusesource.com/nexus/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
        <pluginRepository>
            <id>ea.fusesource.org</id>
            <name>FuseSource Early Access Repository</name>
            <url>http://repo.fusesource.com/nexus/content/groups/ea</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>

        <!-- Core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.9.0.fuse-7-061</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>2.9.0.fuse-7-061</version>
        </dependency>

        <!-- Apache Cxf -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
            <version>2.9.0.fuse-7-061</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jetty</artifactId>
            <version>2.9.0.fuse-7-061</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>2.5.0.fuse-7-061</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-databinding-sdo</artifactId>
            <version>2.5.0.fuse-7-061</version>
        </dependency>


        <!-- Apache tuscany SDO -->
        <dependency>
            <groupId>org.apache.tuscany.sdo</groupId>
            <artifactId>tuscany-sdo-api-r2.1</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tuscany.sdo</groupId>
            <artifactId>tuscany-sdo-impl</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tuscany.sdo</groupId>
            <artifactId>tuscany-sdo-lib</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tuscany.sdo</groupId>
            <artifactId>tuscany-sdo-tools</artifactId>
            <version>1.1.1</version>
        </dependency>

        <!-- SDO Support -->

        <dependency>
            <groupId>org.eclipse.xsd</groupId>
            <artifactId>xsd</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.xsd</groupId>
            <artifactId>xsd</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>ecore</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>ecore-change</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>ecore-xmi</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>common</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>codegen-ecore</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.emf</groupId>
            <artifactId>codegen</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>backport-util-concurrent</groupId>
            <artifactId>backport-util-concurrent</artifactId>
            <version>3.0</version>
        </dependency>


        <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>

        <!-- testing -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-test</artifactId>
            <version>2.9.0.fuse-7-061</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <defaultGoal>install</defaultGoal>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <!-- allows the route to be ran via 'mvn camel:run' -->
            <plugin>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-maven-plugin</artifactId>
                <version>2.9.0.fuse-7-061</version>
            </plugin>

            <!-- Maven bundle plugin -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.7</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Import-Package>*,org.apache.camel.osgi</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
рüффп
  • 5,172
  • 34
  • 67
  • 113
snowindy
  • 3,117
  • 9
  • 40
  • 54

2 Answers2

4

An alternative is to use FAB to deploy to ServiceMix (you would need to install FAB) / Fuse ESB (comes with FAB).

FAB is capable of understanding your maven pom.xml file and deploy needed bundles at deployment time. I posted some links for more details and videos at: http://www.davsclaus.com/2012/08/osgi-deployment-made-easy-with-fab.html

Another alternative is to create a features.xml file, and install your application using a feature. Then in the features file you can specify the osgi bundles your application requires as well. And you can refer to other features etc. For example this is how you can install Camel components, using a single command. For example to install the Camel FTP component you can run:

features:install camel-ftp

So if you have a feature for your application you could do similar.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Well, I've a possibility of using FAB but it ruins my FuseESB server instance once I try to run it. (It fails somewhere during FAB installation. When I restart the server it hungs up with something like 'Starting Fuse server' with no responce). – snowindy Sep 25 '12 at 13:17
  • But FAB and FuseESB is not the case. The worst thing is I don't understand the principle how ServiceMix manages dependencies. For example, 'mvn dependency:tree' shows full tree of dependencies. The tree is quite large. Still, I tried to install them all. Many of them did not start with explanation like 'org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.camel.camel-core-osgi [199]: Unable to resolve 199.0: missing requireme nt [199.0] package; (&(package=org.osgi.service.event)(version>=1.2.0)(!(version>=2.0.0)))'. Though, no 'org.osgi.service.event' in the dep tree – snowindy Sep 25 '12 at 13:21
  • Can you please explain which deps are really useful and which are optional? Can't believe you deploy the whole deps tree to tre container. Am I missing something? – snowindy Sep 25 '12 at 13:23
  • FAB comes in the Fuse ESB Enterprise. I suggest to use that release. Installing FAB on pure Apache ServiceMix and the classic Fuse ESB takes a bit of work. If you want to understand a bit more about FAB then read the links, watch the videos, and try the examples from Fuse ESB Enterprise etc. – Claus Ibsen Sep 25 '12 at 13:53
  • ServiceMix managements dependencies using Karaf features. You can read about this here: http://karaf.apache.org/manual/latest-2.2.x/users-guide/provisioning.html – Claus Ibsen Sep 25 '12 at 13:54
2

Karaf does not parse your pom.xml, to resolve dependencies you must install them manually with features:install or bundle:install. F.ex. in your case

bundle:install mvn:org.eclipse.persistence/com.springsource.commonj.sdo/2.1.1
white
  • 1,823
  • 2
  • 12
  • 20
  • A problem here is that in his Maven project the SDO is version 2.2.3, and the bundle being installed is a different version 2.1.1. – Claus Ibsen Sep 26 '12 at 06:17
  • you can use wrap to include jar that is not actually a bundle, like this wrap:mvn:... – white Sep 26 '12 at 09:57