Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Conf.xml file contains

XML
<?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:cloud="http://schema.cloudfoundry.org/spring"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:mongo="http://www.springframework.org/schema/data/mongo"
	xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
		http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
		http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.7.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">

	<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
		<constructor-arg ref="mongoDbFactory"/> 	
	</bean>
	<bean id ="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
		<constructor-arg ref="mongo"/>
		<constructor-arg name="databaseName" value="mydb" type="String"/>
	</bean>
	<bean id="mongo" class="com.mongodb.Mongo">
		<constructor-arg name="host" value="127.0.0.1" type="String"/>
		<constructor-arg name="port" value="27017" type="int"/>
	</bean>
	
</beans>


And the Error which is I am getting is as follows

Failed to load application context

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [mongo-conf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]: Constructor threw exception; nested exception is java.lang.IllegalAccessError: tried to access method org.springframework.core.GenericTypeResolver.getTypeVariableMap(Ljava/lang/Class;)Ljava/util/Map; from class org.springframework.data.util.ClassTypeInformation
Posted
Updated 21-Feb-12 2:07am
v2

Quelle Surprise - your config file "mongo-conf.xml" is not ok. But I guess you already figured that.

Do you really provide a DB called "mydb" ?? is it available at localhost? can you address it (ping or so)?
 
Share this answer
 
Comments
NapsterBack 22-Feb-12 3:11am    
Ya it is on localhost , I ping the port it is working. There is database mydb which is created through mongo. And what is wrong in my conf file I am not getting it
i have the same problem. Did you get any resolution to this problem ?

I have posted a similar question on spring forums.
http://forum.springsource.org/showthread.php?124092-spring-data-mongodb-issue-with-mongotemplate-bean-instantiation&p=404778#post404778[^]
 
Share this answer
 
v2
Comments
NapsterBack 16-Apr-12 3:24am    
I hard coded in the core java... Works fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900