Announcement Announcement Module
Collapse
No announcement yet.
Mongo DB M4 Template error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mongo DB M4 Template error

    I am trying to build no sql application with latest M4 Jar files using maven. But iam getting class not found error when loading template.
    HTML Code:
    <dependency>
    			<groupId>org.mongodb</groupId>
    			<artifactId>mongo-java-driver</artifactId>
    			<version>2.5.2</version>
    		</dependency>
     
    		<dependency>
    			<groupId>org.springframework.data</groupId>
    			<artifactId>spring-data-mongodb</artifactId>
    			<version>1.0.0.M4</version>
    		</dependency>
     
    this is code in my application context .
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mongo="http://www.springframework.org/schema/data/mongo"
        xsi:schemaLocation="http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-3.0.xsd
              http://www.springframework.org/schema/data/mongo
              http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
              http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
            <mongo:mongo host="localhost"/>

        
        
        <mongo:db-factory id="mongoDbFactory" dbname="database" mongo-ref="mongo"/>

    <bean id="template" class="org.springframework.data.document.mongodb.MongoTemplate">
      <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
    </bean>


     
        <!-- To translate any MongoExceptions thrown in @Repository annotated classes -->
        
     
    </beans>
    When i try to load the application context iam getting class not found error . What could be went wrong .
    org.springframework.beans.factory.CannotLoadBeanCl assException: Cannot find class [org.springframework.data.document.mongodb.MongoTem plate] for bean with name 'template' defined in ServletContext resource [/WEB-INF/beans.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.data.document.mongodb.MongoTem plate
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1250)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.predictBeanType(Abstrac tAutowireCapableBeanFactory.java:576)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :1319)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :885)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:562)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 47)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(St andardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(St andardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: org.springframework.data.document.mongodb.MongoTem plate
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1521)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:257)
    at org.springframework.beans.factory.support.Abstract BeanDefinition.resolveBeanClass(AbstractBeanDefini tion.java:408)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doResolveBeanClass(AbstractBeanFactory .java:1271)
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1242)
    ... 17 more

  • #2
    the template has been changed package
    <mongo:mongo host="localhost"/>



    <mongo:db-factory id="mongoDbFactory" dbname="database" mongo-ref="mongo"/>

    <bean id="template" class="org.springframework.data.mongodb.core.Mongo Template">
    <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
    </bean>

    Comment

    Working...
    X