Grails
  1. Grails
  2. GRAILS-4507

GORM: Error creating a second gorm:sessionFactory

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      winXP, java 1.6, groovy 1.6, grails 1.1

      Description

      I am trying to build an app that will connect to two databases. I've configured the datasources in applicationContext.xml without error, but when I add in the second sessionFactory I get the following error:

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'package1.FooValidator': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
      PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'domainClass' threw exception; nested exception is java.lang.NullPointerException
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
      at package1.FooTests.setUp(Unknown Source)
      Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
      PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'domainClass' threw exception; nested exception is java.lang.NullPointerException
      at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
      at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)

      Example config:
      <gorm:sessionFactory id="sessionFactoryOne"
      base-package="package1"
      data-source-ref="dataSourceOne"
      message-source-ref="messageSource">
      <property name="hibernateProperties">
      ...
      </property>
      </gorm:sessionFactory>

      <gorm:sessionFactory id="sessionFactoryTwo"
      base-package="package2"
      data-source-ref="dataSourceTwo"
      message-source-ref="messageSource">
      <property name="hibernateProperties">
      ...
      </property>
      </gorm:sessionFactory>

        Activity

        Hide
        Lance Lavandowska added a comment -

        Attached is a project that will demonstrate the error if the attached applicationContext.xml is put in place of the one contained in the zip.

        Show
        Lance Lavandowska added a comment - Attached is a project that will demonstrate the error if the attached applicationContext.xml is put in place of the one contained in the zip.
        Hide
        Graeme Rocher added a comment -

        There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3

        for 1.2 final only issues considered blocking will now be fixed

        Show
        Graeme Rocher added a comment - There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3 for 1.2 final only issues considered blocking will now be fixed
        Hide
        Robert La Ferla added a comment -

        Being able to connect to multiple databases is very important functionality for enterprise applications.

        Show
        Robert La Ferla added a comment - Being able to connect to multiple databases is very important functionality for enterprise applications.
        Hide
        Burt Beckwith added a comment -

        You can use the Datasources plugin for this: http://grails.org/plugin/datasources

        Show
        Burt Beckwith added a comment - You can use the Datasources plugin for this: http://grails.org/plugin/datasources
        Hide
        Graeme Rocher added a comment -

        This issue is for using GORM outside of Grails in a non-Grails context, so using a Grails plugin is not a viable solution.

        Show
        Graeme Rocher added a comment - This issue is for using GORM outside of Grails in a non-Grails context, so using a Grails plugin is not a viable solution.

          People

          • Assignee:
            Unassigned
            Reporter:
            Lance Lavandowska
          • Votes:
            3 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development