5 Replies Latest reply on Jun 27, 2017 5:09 AM by Chandra Shekhar Pandey

    What is the best practices to develop in JBoss Fuse with OSGI?

    Celso Agra Newbie

      I'm developing my services and integrations using maven dependencies and run my Camel route. But When I try to deploy my app in the JBoss Fuse, I spend so much time to install all dependencies from OSGI. I understand that I'm doing that by the wrong way. So, is there some way to create a 'pom.xml' file with the osgi configs, and developing my app as I'm used to? Also, I could notice that is not possible to use JBoss Fuse as Wildfly (just adding and removing projects). So, how can I do that without spend some considerable time in this part of development and deployment?

       

      Best regards,

       

      Celso Agra

        • 1. Re: What is the best practices to develop in JBoss Fuse with OSGI?
          Chandra Shekhar Pandey Newbie

          Hi,

           

          I am not sure if you are aware of feature.xml file. You can create a feature.xml once, and you can just install this feature at the time of deployment. One feature.xml can have multiple features. You can add this feature using below command in karaf console.

          features:addurl file://path/to/features.xml

          #Once added, just add the feature you want to install:

          features:install get-started-basic.

          #That's it all bundles or features within this feature will be installed in a single command.

           

          <?xml version="1.0" encoding="UTF-8"?> 
          <features name="get-started">
          <feature name="get-started-basic"> <
          bundle>mvn:org.fusesource.example/cxf-basic/1.0-SNAPSHOT</bundle>
          <bundle>mvn:org.fusesource.example/camel-basic/1.0-SNAPSHOT</bundle>
          </feature>
          <feature name="get-started-cxf">
          <bundle>mvn:org.fusesource.example/cxf-basic/1.0-SNAPSHOT</bundle>
          </feature>
          </features>
          • 2. Re: What is the best practices to develop in JBoss Fuse with OSGI?
            Celso Agra Newbie

            Thanks cpandey !!

            I'll try to do that.

            Also, I'm using this kind of configuration:

            ```

            <plugin>

              <groupId>io.fabric8</groupId>

              <artifactId>fabric8-maven-plugin</artifactId>

              <version>${fabric8.version}</version>

              <configuration>

              <jolokiaUrl>http://xxxxxx:xxxxxx@localhost:8181/jolokia</jolokiaUrl>

              <profile>manager</profile>

              <profileConfigDir>src/main/resources</profileConfigDir>

              <scope>compile</scope>

              <parentProfiles>jboss-fuse-full</parentProfiles>

              <features>camel-jackson camel-jsonpath hibernate-validator camel-http4 camel-restlet fabric-hawtio-swagger</features>

              <bundles>

              wrap:mvn:org.jboss.resteasy/resteasy-jackson2-provider/3.1.3.Final

              wrap:mvn:org.jboss.resteasy/resteasy-jaxrs/3.1.3.Final

              wrap:mvn:org.jboss.resteasy/resteasy-jackson-provider/3.1.3.Final

              wrap:mvn:org.jboss.resteasy/resteasy-multipart-provider/3.1.3.Final

              wrap:mvn:org.jboss.resteasy/resteasy-client/3.1.3.Final

              </bundles>

              </configuration>

            </plugin>

            ```

             

            I did a list about all of problems that I had during the development:

             

             

            1. Integration tests

             

            I found examples

            here -> https://davidvaleri.wordpress.com/2013/09/17/integration-testing-osgi-bundles-in-apache-karafservicemix-with-pax-exam-3/

            and here -> http://blog.christianposta.com/testing/integration-testing-jboss-fuse-6-x-with-pax-exam-part-i/

             

            This seems good. I just simulate my JBoss Fuse environment and could run some tests, but for some reason I got this error below:

            ```

            java.lang.IllegalStateException: No karaf base dir found in extracted distribution.

              at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.searchKarafBase(KarafTestContainer.java:585)

              at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:157)

              at org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:79)

              at org.ops4j.pax.exam.junit.impl.ProbeRunner$2.evaluate(ProbeRunner.java:267)

              at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

              at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

              at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

              at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

              at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

              at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

              at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:98)

              at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)

              at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

              at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

            ```

             

            As I understand, I could test in local environment using specific properties in "camel-context" and parameters

             

            2. Multiple Camel-Context

             

            How Can I create multiple camel-context for different environments? I'd like to do something similiar to Active Providers. Camel-NMR seems to be difficult.

             

             

            3. Debug

             

            Would be possible debug my application with Integration Tests?

            • 3. Re: What is the best practices to develop in JBoss Fuse with OSGI?
              Chandra Shekhar Pandey Newbie

              1. Integration tests

               

              I found examples

              here -> https://davidvaleri.wordpress.com/2013/09/17/integration-testing-osgi-bundles-in-apache-karafservicemix-with-pax-exam-3/

              and here -> http://blog.christianposta.com/testing/integration-testing-jboss-fuse-6-x-with-pax-exam-part-i/

               

              ChandraShekhar: I would suggest to raise a support case with Red Hat JBoss Fuse.

               

               

              2. Multiple Camel-Context

               

              How Can I create multiple camel-context for different environments? I'd like to do something similiar to Active Providers. Camel-NMR seems to be difficult.

               

              ChandraShekhar: Different environments means differents jvm ?

               

              3. Debug

               

              Would be possible debug my application with Integration Tests?

              ChandraShekhar:  Yes it should be.

              • 4. Re: What is the best practices to develop in JBoss Fuse with OSGI?
                Celso Agra Newbie

                cpandey ,

                 

                2. Multiple Camel-Context

                 

                How Can I create multiple camel-context for different environments? I'd like to do something similiar to Active Providers. Camel-NMR seems to be difficult.

                 

                ChandraShekhar: Different environments means differents jvm ?

                 

                Celso: Could be different environments, with different parameters, such as, production is connected to database xxx.xxx.xxx.xxx and stage it is connected in yyy.yyy.yyy.yyy

                • 5. Re: What is the best practices to develop in JBoss Fuse with OSGI?
                  Chandra Shekhar Pandey Newbie

                  Ok, I understood. Here you don't need different camelcontext but different properties file for each environment. What I can think of as a quick solution is to create two properties file like in ${karaf.home}/etc folder:

                   

                  org.fusesource.example.get.started.cfg.prod

                  org.fusesource.example.get.started.cfg.dev

                   

                  Now follow doc[1]. If it prod environment change org.fusesource.example.get.started.cfg.prod to org.fusesource.example.get.started.cfg. Similarly if it dev,  org.fusesource.example.get.started.cfg.dev to org.fusesource.example.get.started.cfg.

                  CamelContext(or route) remains same just configuration changes as per prod/dev/uat.

                   

                  [1]Red Hat JBoss Fuse - Getting Started - Configure the Application