I run into this exact same issue by defining net.sf.ehcache.configurationResourceName in my unit test configs. Hopefully this provides a new avenue for investigation..
I just took the code from AbstractServiceRegistryImpl.applyInjections() and executed it in a standalone class. Surprisingly, it gave the same result: annotations are not found when the class is loaded from the ehcache lib (apart from the latest version, I tried a couple of older ones as well from maven central - all resulted the same)
To me this indicates that maybe there is something wrong with the building of `hibernate-ehcache*.jar'?
import java.lang.reflect.Method;
import org.hibernate.cache.ehcache.EhCacheRegionFactory;
import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
import org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport;
import org.hibernate.service.spi.InjectService;
public class AnnoTst {
public static void main(String[] args) {
AnnoTst tst = new AnnoTst();
tst.tst(new EhCacheRegionFactory());
tst.tst(new DatasourceConnectionProviderImpl());
tst.tst(new StandardRefCursorSupport());
}
private void tst(Object service) {
System.out.println(service.getClass().getName());
System.out.println(service.getClass().getProtectionDomain().getCodeSource());
for (Method method : service.getClass().getMethods()) {
InjectService injectService = method.getAnnotation(InjectService.class);
if (injectService == null) {
System.out.println(" - " + method);
continue;
}
System.out.println("@@@@FOUND: " + method);
}
System.out.println();
}
}
|