Announcement Announcement Module
Collapse
No announcement yet.
Please Help. Hibernate will not work for me Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    ContextLoader

    How are you loading the app context file?

    Is this a web app or a desktop app?

    %

    Comment


    • #17
      Web App

      Now I see: It's a web app running under Tomcat.

      Put the app context in WEB-INF.

      In your web.xml, you have to configure the DispatcherServlet. If you give it servlet name "foo", you should have an app context file named "foo-servlet.xml" in your WEB-INF.

      You'll also need the ContextLoaderListener to load the context when the app starts up. Tell it to look for all the "foo*.xml" in WEB-INF and Bob's your uncle.

      %

      Comment


      • #18
        sadly my test module is not workign still. i will tinker more with it tonight and see where i get.

        however, is there anyone that has spring and hibernate successfully configured and wanna give me a brief run through of whati s needed in the app context file.

        thanks

        Comment


        • #19
          Code:
          Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in class path resource [config/applicationContext.xml]: Cannot resolve reference to bean 'hbSessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hbSessionFactory' defined in class path resource [config/applicationContext.xml]: Cannot resolve reference to bean 'defaultDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'defaultDataSource' defined in class path resource [config/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
          Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hbSessionFactory' defined in class path resource [config/applicationContext.xml]: Cannot resolve reference to bean 'defaultDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'defaultDataSource' defined in class path resource [config/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
          Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'defaultDataSource' defined in class path resource [config/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
          Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                  at org.springframework.util.ClassUtils.forName(ClassUtils.java:177)
                  at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:313)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:912)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:346)
                  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
                  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
                  at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
                  at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
                  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
                  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
                  at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
                  at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
                  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
                  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
                  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
                  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
                  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
                  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
                  at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
                  at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
                  at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)
                  at spring.hibernate.example.client.TestClient.main(TestClient.java:20)
          Java Result: 1

          Okay, now it claims to not be able to initialize the bean. Any help, again. thanks.

          Comment


          • #20
            somehow. miraculously, hibernate and spring started to get along for me.

            Thansk everyone for your help. I wish I could say I know what i did to make it work, however i don't. I just know i played around a lot and did a lot of tinkering.

            Comment


            • #21
              Ok you must have solved the last problem by adding DBCP to the classpath. As for the other problem, you must have either fixed up the path to the applicationContext.xml or moved the file I would presume.
              Last edited by karldmoore; Aug 27th, 2007, 04:05 PM.

              Comment


              • #22
                I thought I had the problem under control. Everything was workign great. Then, I tried to deploy the application on Ubuntu instead of Vista and now I am back to where I started.

                The application runs great if I remove anything to deal with the hibernate installation from the applicationContext file. As soon as I add it again, I get a tomcat error saying "the page cannot be found".

                What could be the problem? I tripled checked my driver url, username, pword, etc, and it works fine under vista. PLEASE HELP ME TO RESOLVE THIS.

                Thanks For The Time and Suggestions.

                Comment


                • #23
                  YEESH!!!!

                  FOR ANYONE WHO HAS THIS PROBLEM, I HAVE FINALLY FIGURED IT OUT.
                  I was using netbeans, and added a plugin to use the spring-framework. However, with this plugin it does not add 2 jar files which are needed for hibernate. These files are commons-dbcp.jar and commons-pool.jar

                  If you add those, the problem is SOLVED

                  YAY!

                  Comment

                  Working...
                  X