Как правильно развернуть пакет osgi в ServiceMix?

Я пытаюсь разработать стартовое приложение для Apache ServiceMix, связанное с веб-сервисами.

1) Я создаю приложение (используя команду «mnv install»)

2) Разверните его в ServiceMix (используя команду 'karaf@root> osgi:install mvn:com.company/ws-test-fuse/1.0.0-SNAPSHOT' на консоли сервера)

3) посмотреть, как он был установлен ('osgi:list')

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

4) Я пытаюсь запустить приложение

karaf@root>osgi:start 157

Я получаю это:

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

Как правильно установить пакет, чтобы все зависимости maven загружались и устанавливались автоматически?

Кроме того, я прав, что все зависимости будут развернуты в osgi-контейнере как osgi-bundles?

Мой POM.xml выглядит следующим образом:

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

person snowindy    schedule 25.09.2012    source источник


Ответы (2)


Альтернативой является использование FAB для развертывания в ServiceMix (вам потребуется установить FAB) / Fuse ESB (поставляется с FAB).

FAB способен понять ваш файл maven pom.xml и развернуть необходимые пакеты во время развертывания. Я разместил несколько ссылок для получения более подробной информации и видео по адресу: http://www.davsclaus.com/2012/08/osgi-deployment-made-easy-with-fab.html

Другой альтернативой является создание файла features.xml и установка приложения с использованием функции. Затем в файле функций вы также можете указать пакеты osgi, которые требуются вашему приложению. И вы можете ссылаться на другие функции и т. д. Например, так вы можете установить компоненты Camel с помощью одной команды. Например, чтобы установить компонент Camel FTP, вы можете запустить:

features:install camel-ftp

Поэтому, если у вас есть функция для вашего приложения, вы можете сделать то же самое.

person Claus Ibsen    schedule 25.09.2012
comment
Что ж, у меня есть возможность использовать FAB, но он разрушает мой экземпляр сервера FuseESB, когда я пытаюсь его запустить. (Где-то происходит сбой во время установки FAB. Когда я перезапускаю сервер, он зависает с чем-то вроде «Запуск сервера Fuse» без ответа). - person snowindy; 25.09.2012
comment
Но дело не в FAB и FuseESB. Хуже всего то, что я не понимаю принципа, как ServiceMix управляет зависимостями. Например, «mvn dependency:tree» показывает полное дерево зависимостей. Дерево достаточно большое. Тем не менее, я попытался установить их все. Многие из них не начинались с объяснения типа «org.osgi.framework.BundleException: неразрешенное ограничение в пакете org.apache.camel.camel-core-osgi [199]: невозможно разрешить 199.0: отсутствует требуемый пакет [199.0]; (&(package=org.osgi.service.event)(версия›=1.2.0)(!(версия›=2.0.0)))'. Тем не менее, в дереве операций нет «org.osgi.service.event». - person snowindy; 25.09.2012
comment
Не могли бы вы объяснить, какие deps действительно полезны, а какие необязательны? Не могу поверить, что вы развернули все дерево зависимостей в контейнере tre. Я что-то упускаю? - person snowindy; 25.09.2012
comment
FAB входит в состав Fuse ESB Enterprise. Я предлагаю использовать этот релиз. Установка FAB на чистый Apache ServiceMix и классический Fuse ESB требует немного усилий. Если вы хотите узнать немного больше о FAB, прочитайте ссылки, посмотрите видео и попробуйте примеры из Fuse ESB Enterprise и т. д. - person Claus Ibsen; 25.09.2012
comment
ServiceMix управляет зависимостями, используя функции Karaf. Вы можете прочитать об этом здесь: karaf.apache.org /manual/latest-2.2.x/users-guide/ - person Claus Ibsen; 25.09.2012

Karaf не анализирует ваш pom.xml, для разрешения зависимостей вы должны установить их вручную с помощью functions:install или bundle:install. F.ex. в твоем случае

bundle:install mvn:org.eclipse.persistence/com.springsource.commonj.sdo/2.1.1
person white    schedule 25.09.2012
comment
Проблема здесь в том, что в его проекте Maven SDO имеет версию 2.2.3, а устанавливаемый пакет — другую версию 2.1.1. - person Claus Ibsen; 26.09.2012
comment
вы можете использовать wrap для включения jar, который на самом деле не является пакетом, например, wrap:mvn:... - person white; 26.09.2012