multi-tenant / grails-multi-tenant-single-db

Multi Tenant implementation for single database environments - Use grails-filtering and grails-hibernate-hijacker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conflict of Hibernate filters with other plugin

ckthum opened this issue · comments

Hi,

I have encountered the following errors when using this plugin with hibernate-search or grails-melody plugins, seem like they all trying to capture the hibernate events. Any suggestion to solve this issue ? Thx.

Regards,
Thum

| Error 2012-04-26 22:38:28,359 [http-bio-8080-exec-2] ERROR [/iTCM-std].[auEngine] - Servlet.service() for servlet [au
Engine] in context with path [/iTCM-std] threw exception
Message: Unable to notify grails.plugin.multitenant.singledb.hibernate.TenantHibernateFilterEnabler@301fd743 of multiten
ant.set-current-tenant.after because of reflection related exception
Line | Method
->> 44 | onReflectionException in grails.plugins.hawkeventing.MethodEventConsumer


| 37 | consume in ''
| 12 | publish . . . . . . . in grails.plugins.hawkeventing.SyncEventPublisher
| 73 | publishEvent in grails.plugins.hawkeventing.EventBroker
| 62 | publish . . . . . . . in ''
| 30 | set in grails.plugin.multitenant.core.impl.CurrentTenantThreadLocal
| 50 | doFilter . . . . . . in grails.plugin.multitenant.core.servlet.CurrentTenantServletFilter
| 30 | doFilterInternal in org.grails.plugins.zkui.ZkuiGrailsOpenSessionInViewFilter
| 197 | doFilter . . . . . . in net.bull.javamelody.MonitoringFilter
| 171 | doFilter in ''
| 1110 | runWorker . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . in java.lang.Thread

Caused by InvocationTargetException: null
->> 31 | consume in grails.plugins.hawkeventing.MethodEventConsumer


| 12 | publish in grails.plugins.hawkeventing.SyncEventPublisher
| 73 | publishEvent . . . . in grails.plugins.hawkeventing.EventBroker
| 62 | publish in ''
| 30 | set . . . . . . . . . in grails.plugin.multitenant.core.impl.CurrentTenantThreadLocal
| 50 | doFilter in grails.plugin.multitenant.core.servlet.CurrentTenantServletFilter
| 30 | doFilterInternal . . in org.grails.plugins.zkui.ZkuiGrailsOpenSessionInViewFilter
| 197 | doFilter in net.bull.javamelody.MonitoringFilter
| 171 | doFilter . . . . . . in ''
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread

Caused by HibernateException: No such filter configured [multiTenantHibernateFilter]
->> 62 | enableHibernateFilterForTenant in grails.plugin.multitenant.singledb.hibernate.TenantHibernateFilterEnabler


| 51 | updateFilterParameter in ''
| 41 | currentTenantUpdated in ''
| 31 | consume in grails.plugins.hawkeventing.MethodEventConsumer
| 12 | publish . . . . . . . in grails.plugins.hawkeventing.SyncEventPublisher
| 73 | publishEvent in grails.plugins.hawkeventing.EventBroker
| 62 | publish . . . . . . . in ''
| 30 | set in grails.plugin.multitenant.core.impl.CurrentTenantThreadLocal
| 50 | doFilter . . . . . . in grails.plugin.multitenant.core.servlet.CurrentTenantServletFilter
| 30 | doFilterInternal in org.grails.plugins.zkui.ZkuiGrailsOpenSessionInViewFilter
| 197 | doFilter . . . . . . in net.bull.javamelody.MonitoringFilter
| 171 | doFilter in ''
| 1110 | runWorker . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . in java.lang.Thread

How does the other plugins capture Hibernate events? Hibernate Hijacker is designed specially to be as little intrusive as possible.

The error gone after removing hibernate-search and grails-melody. However, I am getting the same error after installing mongodb:1.0.0.RC5. I thought hibernate-hijacker supposed to avoid this kind of conflict ? based on the hibernate-hijacker documentation:

2.4. Listening to Hibernate Events

I was a little unsure whether this was within the scope of this plugin or not. Grails 1.3.4 and JIRA 5725 made it a bit easier to add Hibernate event listeners, but this solution is a bit brittle and not very dynamic. If multiple plugins and/or applications declare this Spring bean they'll end up overwriting each other. So in the end I decided to implement this functionality.

It is indeed designed to at least minimize the chance of conflicts like this, but it's a bit hard to tell why this happens without knowing how the other plugins tap into Hibernate. There are some very, very intrusive ways of doing this.

Also getting this same exception when using multi-tenant-single-db-0.8.2 along with the quartz-1.0-RC4 plugin.

I'm also getting the same error. Using multi-tenant-single-db-0.8.2 and quartz:1.0-RC5. The error does not occur with the quartz2:0.2.3 plugin, but I would prefer to use quartz:1.0-RC5. Any ideas on where to look for the root cause?

I might be getting into Grails development again. If you provide a minimal sample app that reproduces the problem I might find some time to look into it.

Hi Kim,
Thanks so much for the offer to maybe look into it. I am trying to create a sample app that reproduces the issue, but I'm not having much success right now (It seems to work fine using a simple app). I'm in the process of adding all the plugins I'm currently using to see if I can spot a conflict.

One thing I have noticed though - If I make any change to a domain object (e.g. add or modify an attribute in the domain class), then I get a similar error:

Unable to notify grails.plugin.multitenant.singledb.hibernate.TenantHibernateFilterEnabler@7e276928 of hibernate.sessionCreated because of reflection related exception

This is very repeatable in my largish grails app, but I have not been able to reproduce it in a small sample app with a few domains.

BTW - THANKS SO MUCH for your effort on the MultiTenant plugin. It has been a very big help on my project!

will

Nice to know that the plugin is still being used!

The reflection related exception is most likely caused by issues with the reloading agent. I don't know how / if the new Grails event plugin copes with reloading, but it would non the less be a good idea to replace the hawk eventing plugin.

Hi, Did anyone end up resolving or find a work around for this issue? I am running into the reflection exception with the quartz plugin (clustered) and the multi-tenant-single-db plugin installed on my instance..

Thanks-