-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: LazyInitException on Transient Indexed field
PostPosted: Tue Jan 24, 2012 1:09 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

I'm getting a lazy init exception in the MassIndexer on a field that is marked as
@Transient
@Field(index=Index.NO,store=Store.YES)
public String getLabel(){
return name + this.getRegion().getLabel();//region is @ManyToOne, fetch=FetchType.LAZY
}

I expect it has to do with the fact that the field is Transient but at the same time, the error does surprise me

Code:
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
   at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
   at nl.project.model.Region_$$_javassist_66.getRegionCode(Region_$$_javassist_66.java)
   at nl.project.model.City.getLabel(City.java:319)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:74)
   at org.hibernate.search.util.ReflectionHelper.getMemberValue(ReflectionHelper.java:91)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:477)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:552)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:552)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:443)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:380)
   at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.index(EntityConsumerLuceneworkProducer.java:160)
   at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.indexAllQueue(EntityConsumerLuceneworkProducer.java:128)
   at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.run(EntityConsumerLuceneworkProducer.java:99)
   at org.hibernate.search.batchindexing.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:107)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[MSA] ERROR [2012-01-24 15:07:17,988] EntityConsumerLuceneworkProducer.run(103) | error during batch indexing:
java.lang.IllegalStateException: Could not get property value
   at org.hibernate.search.util.ReflectionHelper.getMemberValue(ReflectionHelper.java:94)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:477)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:552)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:552)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:443)
   at org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:380)
   at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.index(EntityConsumerLuceneworkProducer.java:160)
   at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.indexAllQueue(EntityConsumerLuceneworkProducer.java:128)
   at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.run(EntityConsumerLuceneworkProducer.java:99)
   at org.hibernate.search.batchindexing.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:107)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Unable to invoke label
   at org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:87)
   at org.hibernate.search.util.ReflectionHelper.getMemberValue(ReflectionHelper.java:91)
   ... 12 more
Caused by: java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:74)
   ... 13 more
Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
   at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)


Kind regards,
Marc


Top
 Profile  
 
 Post subject: Re: LazyInitException on Transient Indexed field
PostPosted: Thu Jan 26, 2012 6:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

looking at the stacktrace it looks like getLabel is getting called after the session is closed. Are you sure your session is still open when you make the call?
The transient annotation will ensure that there is no value loaded or stored for this property. I don't think this is a problem in combination with @Field.

--Hardy


Top
 Profile  
 
 Post subject: Re: LazyInitException on Transient Indexed field
PostPosted: Thu Jan 26, 2012 12:34 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
It looks like the Transient aspect was irrelevant. The problem seems related to the use of optional=true in a ManyToOne relation.
I described everything in more detail in this thread:
viewtopic.php?f=9&t=1012487


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.