Results 1 to 6 of 6

Thread: Spring 3 and Mongo Configuration help

  1. #1

    Default Spring 3 and Mongo Configuration help

    Hello there,

    I'm new to Spring and Mongo so please bare with me for silly questions.

    I read through a few blogs, Spring doc and went over a few examples. I've successfully installed MongoDB, which I tested through Java program. I tried to setup and configure basic helloworld example using Spring-MongoDB, which did not work.

    This is what my sys configuration is:
    1. I'm using Eclipse 3.6 (Helios)
    2. Spring M3
    3. MongoDB 1.6.5

    What I'm not using is:
    1. Maven
    2. Spring Editor

    My questions are:
    1. Can I work with only Eclipse, Spring JARs and MongoDB (without Maven)?
    2. Getting errors like pasted below. Thanks for your help.


    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongo' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.document.mongodb.MongoFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/document/UncategorizedDocumentStoreException
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at amol.test.App.main(App.java:19)

  2. #2
    Join Date
    Jul 2010
    Posts
    139

    Default

    Looks like you're missing a dependency (org.springframework.data.document.UncategorizedDo cumentStoreException). Try adding the appropriate Spring Data Commons jar to your classpath. Just curious, why not use Maven to manage your dependencies? This would remove trivial problems like these from being your concern.

  3. #3

    Default

    Thanks for your reply. I seem to have following commons Jars. Are there any other that I'm missing? Where can I get a list of ALL required Jars for Spring-Mongo configuration.

    spring-data-commons-core-1.0.0.RELEASE.jar
    spring-data-commons-core-1.1.0.jar

    Appreciate your help. Thank you.

  4. #4
    Join Date
    Jul 2010
    Posts
    139

    Default

    It's hard for me to tell without knowing which version of Spring Data MongoDB you are using. You would need to look at the .pom file for that project to see what dependencies and which versions of those dependencies it requires. If you don't use Maven, then you may find this browsable repository helpful. This would allow you to see, for instance, Spring Data MongoDB 1.0.0.M3 pom file to check it's dependencies. Looks like for Spring Data Commons it uses 1.1.0.M1.
    Last edited by jzcfk9; Jul 19th, 2011 at 05:15 AM.

  5. #5

    Default

    Hi, thanks for the info and suggestions. I could identify most dependencies expect this one below. I'm not able to find the JAR associated with org/springframework/data/mapping/model/PersistentProperty. I dont seem to have this class in the following jars too:


    spring-data-mongodb-1.0.0.M3.jar
    spring-data-commons-core-1.0.0.M1.jar

    The error is:

    Code:
    INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@496614e7: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mongoTemplate,mongo,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/PersistentProperty
    	at java.lang.Class.getDeclaredConstructors0(Native Method)
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    	at java.lang.Class.getDeclaredConstructors(Class.java:1836)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:229)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:930)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:903)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    	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:580)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at amol.test.App.main(App.java:19)
    Caused by: java.lang.ClassNotFoundException: org.springframework.data.mapping.model.PersistentProperty
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	... 18 more

  6. #6

    Default

    OK, its under the spring-data-commons-core-1.1.0.M1.jar. Resolved all dependencies. Thank you so much! Appreciate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •