Details
-
Question
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.1.0, 4.0.8
-
None
-
None
-
None
-
Windows 10 and CentOS 7.3; Oracle Java 8
Description
I've been trying without success to build and deploy a simple route with Camel and CDI. I'm focused on deploying to ServiceMix 7.0.0, but have also tried this on a plane jane Karaf 4.1.0 and get precisely the same results.
I built a very simple route based on the Camel CDI examples from both 2.16.4 and 2.18.2. I'm excluding some of the testing stuff for now, just trying to get things to work when I deploy it in Karaf/ServiceMix.
My RouteBuilder is:
public class DemoRouteBuilder extends RouteBuilder { Logger log = LoggerFactory.getLogger(DemoRouteBuilder.class); @Override public void configure() { log.info("Starting demo CDI route"); from("timer://cdiTimer?period=5000") .routeId("com.omniprise.demo.cdi.route") .to("log:com.omniprise..demo.cdi.context") .to("mock:end"); } }
I also have the requisite and content in my POM:
<Export-Package>com.omniprise.demo.cdi.builder</Export-Package> <Import-Package>*</Import-Package> <Require-Capability> osgi.extender; filter:="(osgi.extender=pax.cdi)", org.ops4j.pax.cdi.extension; filter:="(extension=camel-cdi-extension)" </Require-Capability>
Complete Java and POM code will be attached.
Note that the camel-cdi feature will fail to install on ServiceMix 7.0.0 due to dependency conflicts:
- ServiceMix 7.0.0 is using Camel 2.16.4
- camel-cdi in 2.16.4 is looking for DeltaSpike [1.5.0,2.0)
- camel-cdi in 2.16.4 is looking for pax-cdi 1.0.0.RC1
- pax-cdi installs DeltaSpike 1.3.1
- ... therefore a unresolved dependency error occurs if all that is done is:
feature:install pax-cdi pax-cdi-weld camel-cdi
Similar issues exist with newer versions of Camel as well when deploying into Karaf 4.1.0.
Note, too, that even with the inclusion of updated DeltaSpike libraries, errors occur with pax-cdi 1.0.0.RC1, possibly due to an issue with Blueprint proxies.
Therefore, these instructions install pax-cdi 1.0.0.RC2 and the latest DeltaSpike 1.7.2, along with camel-cdi (2.16.4 for ServiceMix 7.0.0 and 2.18.2 for Karaf 4.1.0).
To install and run in ServiceMix 7.0.0 (Karaf 4.0.8, Camel 2.16.4)
Start ServiceMix, connect to Karaf Console and install:
feature:repo-add mvn:org.ops4j.pax.cdi/pax-cdi-features/1.0.0.RC2/xml/features install mvn:org.apache.deltaspike.core/deltaspike-core-api/1.7.2 install mvn:org.apache.deltaspike.core/deltaspike-core-impl/1.7.2 feature:install pax-cdi/1.0.0.RC2 feature:install pax-cdi-weld/1.0.0.RC2 feature:install camel-cdi install -s mvn:com.omniprise.demo/camel-osgi-cdi/0.0.1-SNAPSHOT
To install and run in a plain jane Karaf 4.x environment (Camel 2.18.2)
Start Karaf, connect to Karaf Console and install:
feature:repo-add mvn:org.apache.camel.karaf/apache-camel/2.18.2/xml/features feature:repo-add mvn:org.ops4j.pax.cdi/pax-cdi-features/1.0.0.RC2/xml/features install mvn:org.apache.deltaspike.core/deltaspike-core-api/1.7.2 install mvn:org.apache.deltaspike.core/deltaspike-core-impl/1.7.2 feature:install pax-cdi/1.0.0.RC2 feature:install pax-cdi-weld/1.0.0.RC2 feature:install camel/2.18.2 feature:install camel-blueprint/2.18.2 feature:install camel-cdi/2.18.2 install -s mvn:com.omniprise.demo/camel-osgi-cdi/0.0.1-SNAPSHOT
In both cases, the packages are all installed and listed as running, but the Camel Context isn't started:
70 | Active | 80 | 1.0.0.RC2 | OPS4J Pax CDI Bean Bundle API 71 | Active | 80 | 1.0.0.RC2 | OPS4J Pax CDI Extender for Bean Bundles 72 | Active | 80 | 1.0.0.RC2 | OPS4J Pax CDI Portable Extension for OSGi 73 | Active | 80 | 1.0.0.RC2 | OPS4J Pax CDI Service Provider Interface 74 | Active | 80 | 1.0.0.RC2 | OPS4J Pax CDI Weld Adapter ... content removed for brevity 83 | Active | 50 | 2.18.2 | camel-cdi ... content removed for brevity 92 | Active | 80 | 1.8.1 | OPS4J Pax Swissbox :: Tracker 93 | Active | 80 | 0.0.1.SNAPSHOT | Camel CDI OSGi Demo addmin@root()> camel:context-list addmin@root()>
The is only one error in the log associated with camel-cdi installing pax-cdi 1.0.0.RC1 even though pax-cdi 1.0.0.RC2 is already present, and therefore a CDI provider is already registered. At the end of the log, it is clear that the CDI binding is starting up, but there is no Context created, and the Route isn't producing messages - there's nothing indicating there was a problem finding the RouteBuilder or starting it:
2017-03-08T15:50:24,568 | INFO | pipe-feature:install camel-blueprint/2.18.2 | CdiExtender | 71 - org.ops4j.pax.cdi.extender - 1.0.0.RC2 | creating CDI container for bean bundle camel-osgi-cdi [93] with extension bundles [org.apache.camel.camel-cdi [83]] 2017-03-08T15:50:24,575 | INFO | pipe-feature:install camel-blueprint/2.18.2 | AbstractCdiContainer | 73 - org.ops4j.pax.cdi.spi - 1.0.0.RC2 | Starting CDI container for bundle camel-osgi-cdi [93] 2017-03-08T15:50:24,598 | INFO | pipe-feature:install camel-blueprint/2.18.2 | Version | 69 - org.jboss.weld.osgi-bundle - 2.3.5.Final | WELD-000900: 2.3.5 (Final) 2017-03-08T15:50:24,745 | INFO | pipe-feature:install camel-blueprint/2.18.2 | Bootstrap | 69 - org.jboss.weld.osgi-bundle - 2.3.5.Final | WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously. 2017-03-08T15:50:24,810 | WARN | pipe-feature:install camel-blueprint/2.18.2 | Interceptor | 69 - org.jboss.weld.osgi-bundle - 2.3.5.Final | WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled 2017-03-08T15:50:24,811 | WARN | pipe-feature:install camel-blueprint/2.18.2 | Interceptor | 69 - org.jboss.weld.osgi-bundle - 2.3.5.Final | WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled 2017-03-08T15:50:24,938 | INFO | pipe-feature:install camel-blueprint/2.18.2 | Event