0
votes

Hello I am new to servicemix and cannot start a simple self-programmed bundle.

My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

<!-- Generated by Apache ServiceMix Archetype -->

<modelVersion>4.0.0</modelVersion>

<groupId>de.rupp</groupId>
<artifactId>test</artifactId>
<packaging>bundle</packaging>
<version>1.0-SNAPSHOT</version>
<name>test</name>

<properties>
   <camel.version>3.0.0-M3</camel.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <defaultGoal>install</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4.3</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.6</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Import-Package>*</Import-Package>
                    <Private-Package>de.rupp</Private-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

My camel-context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:camel="http://camel.apache.org/schema/spring"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://camel.apache.org/schema/spring
  http://camel.apache.org/schema/spring/camel-spring-2.10.3.xsd">
<camelContext id="Merda" xmlns="http://camel.apache.org/schema/spring">
    <packageScan>
         <package>de.rupp</package>
     </packageScan>
 </camelContext>
 </beans>

I only have one simple class

public class TestRoute extends RouteBuilder {

@Override
public void configure() throws Exception {
    from("file:in")
        .id("file-in")
        .log("Nachricht: ${body}")
        .to("file:out");

}

}

The resulting MANIFEST.MF is

Manifest-Version: 1.0
Bnd-LastModified: 1560848195732
Build-Jdk: 1.8.0_181
Built-By: bla
Bundle-ManifestVersion: 2
Bundle-Name: test
Bundle-SymbolicName: test
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: de.rupp;uses:="org.apache.camel.builder,org.apache.camel
 .model";version="1.0.0.SNAPSHOT"
Import-Package: org.apache.camel.builder;version="[3.0,4)",org.apache.ca
 mel.model;version="[3.0,4)"
Tool: Bnd-1.50.0

when I copy the jar to the deploy folder and use bundle:list I see it installed 225 | Installed | 80 | 1.0.0.SNAPSHOT | test

However I cannot start it.

karaf@root>start 225

Error executing command: Error executing command on bundles:
        Error starting bundle 225: Unable to resolve test [225](R 225.14): missi
ng requirement [test [225](R 225.14)] osgi.wiring.package; (&(osgi.wiring.packag
e=org.apache.camel.builder)(version>=3.0.0)(!(version>=4.0.0))) Unresolved requi
rements: [[test [225](R 225.14)] osgi.wiring.package; (&(osgi.wiring.package=org
.apache.camel.builder)(version>=3.0.0)(!(version>=4.0.0)))]

Any help would be greatly appreciated. Does anyone know a good tutorial for writing camel bundles?

Thanks,

Hans

2

2 Answers

1
votes

You should use the Camel version that ServiceMix is using (ships with out of the box). ServiceMix does NOT support Camel 3.

Also I wonder suggest to look at just using Apache Karaf or alternative runtimes for Camel (Spring Boot, Quarkus, Tomcat, Standalone Camel via Camel Main) as ServiceMix is not so active anymore.

0
votes

Replace your property with this:

<properties>
   <camel.version>2.16.5</camel.version>
</properties>