• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

creating NMR end point to connect two routes in camel

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configures the Camel Context-->

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:osgi="http://www.springframework.org/schema/osgi"
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.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">


<bean id="nmr" class="org.apache.servicemix.camel.nmr.ServiceMixComponent">
<property name="nmr">
<osgi:reference interface="org.apache.servicemix.nmr.api.NMR" />
</property>
</bean>


<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- here is a sample which processes the input files
(leaving them in place - see the 'noop' flag)
then performs content based routing on the message using XPath -->

<camel:route>
<camel:from uri="file:src/data?noop=true"/>
<camel:to uri="nmr:MyRoute"></camel:to>
</camel:route>

<camel:route>
<camel:from uri="nmr:MyRoute"></camel:from>
<camel:choice>
<camel:when>
<camel:xpath>/person/city = 'London'</camel:xpath>
<camel:log message="UK message"/>
<camel:to uri="file:target/messages/uk"/>
</camel:when>
<camel:otherwise>
<camel:log message="Other message"/>
<camel:to uri="file:target/messages/others"/>
</camel:otherwise>
</camel:choice>
</camel:route>
</camel:camelContext>

</beans>

This is my camel-context.xml file where i declare and instantiate NMR end point to connect two routes.


<?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>com.mycompany</groupId>
<artifactId>camel-spring</artifactId>
<packaging>jar</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>
</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>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.10.0.redhat-60024</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.10.0.redhat-60024</version>
</dependency>


<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<version>2.10.0.redhat-60024</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.apache.servicemix.camel</groupId>
<artifactId>org.apache.servicemix.camel.component</artifactId>
<version>4.5.3</version>
</dependency>

</dependencies>


<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<import-Package>
*,
org.apache.servicemix.camel.nmr,
org.apache.servicemix.nmr.api,
org.apache.servicemix.nmr.api.event,
org.apache.servicemix.nmr.api.internal,
org.springframework.beans.factory.config
</import-Package>
<DynamicImport-Package>
org.springframework.jms.*;
org.apache.camel.*
</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</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>

<!-- allows the route to be ran via 'mvn camel:run' -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>2.10.0.redhat-60024</version>
</plugin>
</plugins>
</build>

</project>

This is my pom.xml file



The project is successfully build.
But during running that it shpws the follwing error(in log file of servicemix) mention in below.How to resolve this issue.



ERROR | ExtenderThread-6 | ContextLoaderListener | 115 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=null, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean#0': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class[]' for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.apache.servicemix.nmr.api.NMR]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.osgi.extender.internal.dependencies.startup.MandatoryImporterDependencyFactory.getServiceDependencies(MandatoryImporterDependencyFactory.java:63)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager.doFindDependencies(DependencyServiceManager.java:272)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager.access$700(DependencyServiceManager.java:40)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager$1.run(DependencyServiceManager.java:213)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.util.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:124)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager.findServiceDependencies(DependencyServiceManager.java:209)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:239)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)[115:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)[114:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)[115:org.springframework.osgi.extender:1.2.1]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_51]
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class[]' for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.apache.servicemix.nmr.api.NMR]
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:468)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:494)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:488)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1433)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1392)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[71:org.springframework.beans:3.2.4.RELEASE]
... 16 more
Caused by: java.lang.IllegalArgumentException: Cannot find class [org.apache.servicemix.nmr.api.NMR]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:296)[69:org.springframework.core:3.2.4.RELEASE]
at org.springframework.beans.propertyeditors.ClassArrayEditor.setAsText(ClassArrayEditor.java:68)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:452)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:424)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)[71:org.springframework.beans:3.2.4.RELEASE]
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)[71:org.springframework.beans:3.2.4.RELEASE]
... 22 more
Caused by: java.lang.ClassNotFoundException: org.apache.servicemix.nmr.api.NMR not found from bundle [null]
at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)[114:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)[114:org.springframework.osgi.core:1.2.1]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_51]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)[69:org.springframework.core:3.2.4.RELEASE]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:293)[69:org.springframework.core:3.2.4.RELEASE]
... 27 more
Caused by: java.lang.ClassNotFoundException: org.apache.servicemix.nmr.api.NMR not found by [190]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_51]
at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)[114:org.springframework.osgi.core:1.2.1]
... 31 more
 
reply
    Bookmark Topic Watch Topic
  • New Topic