mongodb - component - ClassNotFoundException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

mongodb - component - ClassNotFoundException

sanbhat
Hi,

I would like to use mongodb component in my camelContext. I have already installed feature camel-mongodb and when I do bundle:list  I get

156 | Active  |  50 | 2.11.3.RELEASE | MongoDB Java Driver

Here's my camelContext

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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.0.0.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/spring"> 
  <!-- <camelContext  xmlns="http://camel.apache.org/schema/blueprint"> -->
    <route>
      <from uri="rabbitmq://localhost:5672/A?username=guest&amp;password=guest&amp;autoDelete=false&amp;routingKey=source_q&amp;queue=source_q&amp;exchangeType=topic"/>
      <bean ref="myTransform" method="transform"/>
      <to uri="mongodb:mongo?database=mongo_poc&amp;collection=camel&amp;operation=save"/>
    </route>
  </camelContext>
  
  <!-- Mongo DB -->
  <bean id="mongo" class="com.mongodb.Mongo">
	<constructor-arg index="0" value="localhost" />
  </bean>

  
</beans>

When I deploy this exception, I get following exception

karaf@root()> Exception in thread "SpringOsgiExtenderThread-8" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel-3': Invocation of init method failed; ne
sted exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mongodb.Mongo] for bean with name 'mongo' defined in URL [bundle://149.23:0/META-INF/spring/
camelContext.xml]; nested exception is java.lang.ClassNotFoundException: com.mongodb.Mongo not found from bundle [demo.camel-bundle]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
        at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
        at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
        at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mongodb.Mongo] for bean with name 'mongo' defined in URL [bundle://149.23:0/META-INF/spring/camelCo
ntext.xml]; nested exception is java.lang.ClassNotFoundException: com.mongodb.Mongo not found from bundle [demo.camel-bundle]
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1275)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1344)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:355)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:334)
        at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1178)
        at org.apache.camel.spring.CamelContextFactoryBean.getBeanForType(CamelContextFactoryBean.java:188)
        at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:145)
        at org.apache.camel.osgi.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:64)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
        ... 14 more
Caused by: java.lang.ClassNotFoundException: com.mongodb.Mongo not found from bundle [demo.camel-bundle]
        at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)
        at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1296)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1267)
        ... 24 more
Caused by: java.lang.ClassNotFoundException: com.mongodb.Mongo not found by demo.camel-bundle [149]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)
        at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)
        at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
        ... 30 more

Please help me. I am not sure what is missing here.