I'd love to share my code.. just make sure to have your Alka-Seltzer ready  :P
This is my original route using Java DSL to solve a small route issue. (I did 
anonymize a few things in the code before sending it out to public view)  I've 
tried to "fortify" it with dependencies and configurations to try and flip it 
over to something Karaf can make heads or tails of.  
Thanks!


________________________________
From: Kerry <[email protected]>
To: [email protected] 
Sent: Tuesday, October 16, 2018 3:03 PM
Subject: Re: Running Camel in a Karaf OSGi container



Hi John,
Are you able to share any of your code or an example project? also are you 
familiar already with OSGi or is it only Karaf that you are new to?
thanks
Kerry


On 16/10/18 19:54, John F. Berry wrote:

New user to Karaf due to the fact that my development work in Apache Camel is 
wanted by people to be installed on a Windows server and to be installed as a 
service.  This led me to the Karaf product.
I've asked the Camel users forum about migration steps, but now I think this is 
more of a Karaf and/or maven deployment thing than a Camel issue.
I have developed a route in Camel using maven and hand writing
       a Java DSL route (no Eclipse or other tool).  I can run the
       jar as a standalone execution fine from a command line.
I did create a OSGi service wrapper in karaf and did have a
       window service instance installed.
I just cannot seem to get Karaf to "deploy" it (a.k.a. pick up
       and run with it under that OSGi container that is running.
Sorry for the generalities, new to the open source community
       and the idea that you need to be fully immersed in every
       Apache offering (Camel, Maven, Felix, ServiceMix, Karaf, 
       etc.) to utilize any one of them  :P    I have felix and
       blueprint dependencies in my POM.. but they been through many
       different forms in an attempt to run it.  It is a Java DSL
       Camel archetype that has been built, but cannot seem to
       generate supporting files for Karaf to recognize my little
       creation.
Ideas?  
Later I attempted to make an "empty" project with maven selecting 
"org.apache.camel.archetypes:camel-archetype-blueprint", but I cannot even get 
that base package to run (the small Hello World code) without java blowing up.  
The one I built, compiled, ran, tested and "jar"ed was from the 
"org.apache.camel.archetypes:camel-archetype-java" maven archetype skeleton.  I 
attempted to merge the two.. but no luck so far!

Thanks!
<?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/maven-v4_0_0.xsd";>

  <modelVersion>4.0.0</modelVersion>

  <groupId>org.somecompany.camel</groupId>
  <artifactId>EDMtoPSoft-java</artifactId>
  <packaging>bundle</packaging>
  <version>1.0.0</version>

  <name>EDM base64 HL7 documents to PeopleSoft</name>

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

  <dependencyManagement>
    <dependencies>
      <!-- Camel BOM -->
      <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-parent</artifactId>
        <version>2.22.1</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-blueprint</artifactId>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <scope>runtime</scope>
    </dependency>

    <!-- testing -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
     <groupId>javax.xml.bind</groupId>
     <artifactId>jaxb-api</artifactId>
     <version>2.2.11</version>
    </dependency>
    <dependency>
     <groupId>javax.activation</groupId>
     <artifactId>activation</artifactId>
     <version>1.1.1</version>
    </dependency>
    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-mllp</artifactId>
     <version>2.21.1</version>
    </dependency>

    <!-- Project stuff -->
    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-hl7</artifactId>
     <version>2.21.1</version>
    </dependency>

    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-netty4</artifactId>
     <version>2.21.1</version>
    </dependency>

    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-base64</artifactId>
    <version>2.21.1</version>
    </dependency>

    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-sql</artifactId>
    <version>2.21.1</version>
    </dependency>
    
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-dbcp2</artifactId>
    <version>2.5.0</version>
    </dependency>

    <dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>7.0.0.jre10</version>
    </dependency>


  </dependencies>

  <build>
    <defaultGoal>install</defaultGoal>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>

      <!-- Allows the example to be run via 'mvn compile exec:java' -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <configuration>
          <mainClass>org.somecompany.camel.MainApp</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
        </configuration>
      </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>org.somecompany.camel.MainApp</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>

                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


<!-- to generate the MANIFEST.MF of the bundle -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>3.5.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- to include MANIFEST.MF in the bundle -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>


    </plugins>
  </build>

</project>

Attachment: MainApp.java
Description: Binary data

Attachment: MyRouteBuilder.java
Description: Binary data

Reply via email to