I'm an intermediate Hibernate user. I am trying to get some traction with Hadoop at my company. I'm using spring-hadoop (https://github.com/SpringSource/spring-hadoop) to configure my application and inject my dependencies.
I'm having a lot of trouble getting Hadoop to respect my hibernate sessions. I'm hitting the legendary LazyInitializationException.
Resolution is a lazy init field on a ServicePoint object that is retrieved with hibernate in the first part of the map task.
org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:108) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:150) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at p.model.ServicePoint$$EnhancerByCGLIB$$181013ec.getReadResolution() at p.service.ResourceService.getStartDate(ResourceService.java:77)
The exception is thrown later on in the map task when I try to work with the ServicePoint object. It is not thrown in the reduce task. Modifying the ServicePoint hibernate mapping is not an option.
I've tried a bunch of approaches suggested by my giant "Java Persistencee with Hibernate" book such as:
1. Opening a session at the beginning of Map:
2. Adding stuff like this to my sessionFactory bean:
Session session = this.sessionFactory.openSession(); session.beginTransaction();
3. @Transactional annotations
prop key="hibernate.connection.release_mode">on_close < /prop>
Before i pull out all stops and try stuff like Conversation Interceptors, can anyone give me a suggestion ? Nothing works and the exception keeps coming.