Announcement Announcement Module
Collapse
No announcement yet.
LazyInitializationException and TransactionProxyFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LazyInitializationException and TransactionProxyFactoryBean

    Hello everybody,

    For Spring-WS i am trying to use TransactionProxyFactoryBean to solve my 'could not initialize proxy - no Session' and Soap fault with LazyInitializationException. Only when I am use it I still get the exception.

    Here is my TransactionProxyFactoryBean:
    Code:
    	<bean id="jobManagerService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="target" ref="jobManager"/>
          
            <property name="transactionManager" ref="transactionManager"/>
            <property name="transactionAttributes">
                <props>
                    <prop key="*">PROPAGATION_REQUIRED</prop>
                </props>
            </property>
        </bean>
    jobManager bean:
    Code:
    	<bean id="jobManager"
    		class="com.inprove.servicefarm.job.JobManager">
    		<property name="jobDao">
    			<ref bean="jobDao" />
    		</property>
    		<property name="gridManager">
    			<ref bean="gridManager" />
    		</property>
    	</bean>
    Code involving to get my object from the db:
    JobManager:
    Code:
    public Job getJob(int id)
    	{
    		return jobDao.getJob(id);
    	}
    JobDao:
    Code:
    public class JobDao extends HibernateDaoSupport implements IJobDao
    {
    public Job getJob(int id)
    	{
    		return (Job) this.getHibernateTemplate().load(Job.class, id);
    
    	}
    }
    Does anybody know how i can solve my exception.

  • #2
    Make sure you use the proxied instance. Also make sure that all the access is done INSIDE the transaction. If you retrieve something and the service method is over the transaction (and in this case also the session!) is over...

    Comment


    • #3
      okey, I found the problem. MarshallingSource caused the problem. TransactionProxyFactoryBean works fine now.

      Comment


      • #4
        Hello everybody,

        I still get LazyInitializationException.
        I retrieve an object:
        Entry entry = organizationRepository.getEntry(entryID);

        organizationRepository is a TransactionProxyFactoryBean .
        But when i do entry.getName(); in my controller I still get a LazyInitializationException.

        Is this normal?

        Comment

        Working...
        X