On Jun 20, 2011, at 11:01 PM, Scott Marlow wrote:

> 
> On 06/17/2011 07:22 AM, Steve Ebersole wrote:
>> I remember Scott and I discussing this exact issue. Unfortunately I do
>> not remember the specifics. java.util.ServiceLoader#load(Class<S>
>> service) does use the TCCL, but I think that the end result of our
>> discussion was this is ok.
>> 
>> We need to have this call be able to locate services both within the
>> module classloader as well as within the classloader that ikncludes the
>> user app. Scott, is there a single classloader that covers both of those
>> cases that we could use?
> 
> Basically, we need to inject any needed modules into the application.
> 
>> 
>> On 06/16/2011 06:54 AM, Strong Liu wrote:
>>> Hi there,
>>> 
>>> first of all, I have finished this task, and test pass.
>>> but :), i have to make the following changes, i'd like to hear you
>>> guys' thoughts before i go to much away.
>>> 
>>> 1. adding envers into org.hibernate module in as7, so user's app can
>>> see both hibernate and envers class
>>> (with an separate envers module i ran into some cycle dependency issue)
> 
> Well, I forget what you did exactly Strong, but the above statement (1) 
> sounds wrong.  It may be true but what you stated would not give the app 
> classloader, access to the envers module.  Adding envers into the 
> org.hibernate module, means that Hibernate code can load the envers classes.
> 
> Did you get a circular dependency error message?  Or are you just trying to 
> design around possible cycles?

with adding envers into a separate module, we have two options:
1) core module depends on envers module
so, the Integrator can find envers, but envers also need core's classes, so i 
got class not found error for SessionFactory when building envers objects.

2) envers module depends on core
the integrator won't work, since core can't see envers' resource, so i got 
"listeners were not registed" exception

this is what i called "circular dependency"

and adding envers into org.hibernate module, means there will no 
org.hibernate.envers module, and a (jpa) app's classloader can access 
org.hibernate module, right? so it can access envers class too.

> 
> 
> 
>>> 
>>> 2. envers throws "listeners were not registed" exception, means
>>> hibernate's IntegratorServiceImpl can't see envers class/resource
>>> 
>>> IntegratorServiceImpl is using java.util.ServiceLoader#load(Class<S>
>>> service), which internally using TCCL, (I think)
>>> that's the reason why core can't see envers' integrator.
>>> 
>>> so, i created a custom ServiceLoader which use ClassLoaderService to
>>> find the integrator, but this doesn't work either.
>>> since, we need
>>> org.hibernate.service.classloading.internal.ClassLoaderServiceImpl#locateResources
>>> first (META-INF/services/org.hibernate.integrator.spi.Integrator) and
>>> ClassLoaderServiceImpl using resourceClassLoader to do this.
>>> by default, resourceClassLoader is set to applicationClassLoader in
>>> ClassLoaderServiceImpl.
>>> 
>>> then, i changed IntegratorServiceImpl to use
>>> java.util.ServiceLoader#load(Class<S> service,
>>> IntegratorServiceImpl.class.getClassLoader()
>>> ), test pass, but this of course is not the fix.
>>> 
>>> so, i changed the custom ServiceLoader to use classLoaderService to
>>> locateResources first, and using ServiceLoader.class.getClassLoader()
>>> to reload the resource again.
>>> 
>>> here are the changes:
>>> https://github.com/stliu/hibernate-core/commit/09ce5defabea8cfb87d06c3d7b9bc1a2c613f62c
>>> 
>>> https://github.com/stliu/jboss-as/commit/616237755626672157fb2ae565fadb16cf47af89
>>> 
>>> 
>>> thoughts?
>>> 
>>> -----------
>>> Strong Liu<st...@hibernate.org>
>>> http://hibernate.org
>>> http://github.com/stliu
>>> 
>> 
> 


_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to