This exception in general can have a bunch of causes.
In you case though, in Hibernate Search there are several tools at your disposal. All in
HibernateHelper.
For the most part they abstract away Hibernate calls for when we will make Hibernate
Search fully independent of Hibernate Core.
unproxy: returns this or the underlying implementation behind the proxy (could initialize
the proxy by side effect)
getClass: returns the entity class (even in case of proxies)
initialize: intialize the proxy or the collection
isInitialized: returns true if the proxy or the collection is initialized
getClassFromWork: returns the entity class for a given work (probably should be put
somewhere else when we abstract Hibernate truly.
Emmanuel
On 30 nov. 2010, at 21:20, Sanne Grinovero wrote:
Hello,
I'm blocked by the exception mentioned in the subject, this is also
affecting my work in Search:
with the new design I need the object identifier more often than before, and
even our own org.hibernate.search.test.proxy.ProxyTest fails.
Searching for similar exceptions I found many users asking for help
about the same error, also some
comments are quite recent so it would be nice to find a general solution:
HHH-5280
HHH-3399
HHH-1953
HHH-4064
https://forum.hibernate.org/viewtopic.php?t=979408
The error is that I'm invoking getId() via reflection, but the entity
instance is actually a javassist proxy.
Shouldn't org.hibernate.annotations.common.reflection.java.JavaXProperty
"shield" our code from this kind
of complexities?
Suggestions to proceed?
Sanne
stacktrace follows:
org.hibernate.HibernateException: Error while indexing in Hibernate
Search (before transaction completion)
at
org.hibernate.search.backend.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:175)
at
org.hibernate.engine.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:543)
at org.hibernate.engine.ActionQueue.beforeTransactionCompletion(ActionQueue.java:216)
at org.hibernate.impl.SessionImpl.beforeTransactionCompletion(SessionImpl.java:571)
at org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:250)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:138)
at org.hibernate.search.test.proxy.ProxyTest.testProxy(ProxyTest.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at
org.hibernate.testing.junit.functional.annotations.HibernateTestCase.runTest(HibernateTestCase.java:97)
at
org.hibernate.testing.junit.functional.annotations.HibernateTestCase.runBare(HibernateTestCase.java:85)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IllegalStateException: Could not get property value
at org.hibernate.search.util.ReflectionHelper.getMemberValue(ReflectionHelper.java:94)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.getIndexingId(DocumentBuilderIndexedEntity.java:699)
at
org.hibernate.search.engine.WorkPlan$PerClassWork.recurseContainedIn(WorkPlan.java:136)
at org.hibernate.search.engine.WorkPlan.recurseContainedIn(WorkPlan.java:69)
at
org.hibernate.search.engine.AbstractDocumentBuilder.processSingleContainedInInstance(AbstractDocumentBuilder.java:773)
at
org.hibernate.search.engine.AbstractDocumentBuilder.processContainedInInstances(AbstractDocumentBuilder.java:322)
at
org.hibernate.search.engine.WorkPlan$PerEntityWork.processContainedIn(WorkPlan.java:268)
at
org.hibernate.search.engine.WorkPlan$PerClassWork.processContainedIn(WorkPlan.java:130)
at org.hibernate.search.engine.WorkPlan.processContainedIn(WorkPlan.java:62)
at
org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:150)
at
org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.beforeCompletion(PostTransactionWorkQueueSynchronization.java:86)
at
org.hibernate.search.backend.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:172)
... 25 more
Caused by: java.lang.IllegalArgumentException: Invoking id with wrong parameters
at
org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:84)
at org.hibernate.search.util.ReflectionHelper.getMemberValue(ReflectionHelper.java:91)
... 36 more
Caused by: java.lang.IllegalArgumentException: object is not an
instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:74)
... 37 more
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev