Grails

Hibernate event listeners cause ArrayStoreException

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.3.6
  • Fix Version/s: 2.0-M2
  • Component/s: Persistence
  • Environment:
    Tried on both windows/Linux

Description

Registering an event listener for "save, update etc" (SaveOrUpdateEventListener) Will cause ArrayStoreException at runtime .
I just tried with "pre-insert" and it works without any issues. I don't know what all other event listeners will cause this issue.

In my sample plugin,

def doWithSpring = {
      	sampleListener(SampleListener)
		hibernateEventListeners(HibernateEventListeners) {
			  listenerMap = ['save':sampleListener]
		   }
    }

Both, sampleListenerand HibernateEventListeners classes are imported.

In integration test

Book b = new Book()
		b.name = "Sample book"
		b.save()	
		
		println "Book ID :" + b.id
		
		b.name = "Name changed"
		
		b.save()

This will cause the exception

Error creating bean with name 'transactionManager': Cannot resolve reference to bean'sessionFactory' while setting
bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creat
ing bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.ArrayStoreExceptio.

For more details, Look at http://grails.1312388.n4.nabble.com/Hibernate-listeners-are-not-called-for-integration-tests-td3546387.html

Activity

Hide
Igor Aguiar added a comment -

I worked on a fix for this issue.
As I am working with version 1.3.7, I created a branch from the v1.3.7 tag of my clone at GitHub and then I fixed the problem, hoping that I could merge the changes in the master later.
Happens that the changed file (ConfigurableLocalSessionFactoryBean.java) was moved to other location in the master.
I am providing two patches, one for grails 1.3.7 and one for the master branch.
Also I made a pull request at GitHub.

Show
Igor Aguiar added a comment - I worked on a fix for this issue. As I am working with version 1.3.7, I created a branch from the v1.3.7 tag of my clone at GitHub and then I fixed the problem, hoping that I could merge the changes in the master later. Happens that the changed file (ConfigurableLocalSessionFactoryBean.java) was moved to other location in the master. I am providing two patches, one for grails 1.3.7 and one for the master branch. Also I made a pull request at GitHub.
Hide
Igor Aguiar added a comment -

Patch for grails 1.3.7

Show
Igor Aguiar added a comment - Patch for grails 1.3.7
Hide
Igor Aguiar added a comment -

Patch for grails 2.0 (master branch)

Show
Igor Aguiar added a comment - Patch for grails 2.0 (master branch)

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: