-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: ClassCastException in Testing But Not Deployment
PostPosted: Tue Jan 15, 2008 4:39 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I am using Hibernate Search in my Seam web application. All my unit tests and integration tests (using SeamTest), which are quite rigorous, are passing with flying colors. However, when I try to use the functionality in my actual application, I get the following:

Code:
java.lang.ClassCastException: org.jboss.seam.persistence.FullTextHibernateSessionProxy
   at org.hibernate.search.impl.FullTextSessionImpl.<init>(FullTextSessionImpl.java:70)
   at org.hibernate.search.Search.createFullTextSession(Search.java:21)
   at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getFullTextSession(FullTextEntityManagerImpl.java:37)
   at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.createFullTextQuery(FullTextEntityManagerImpl.java:60)
   at persistence.search.SearchImpl.getAdvancedSearchResults(SearchImpl.java:185)
   at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
   at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
   at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
   at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
   at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
   at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
   at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
   at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
   at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
   at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
   at persistence.search.SearchImpl_$$_javassist_1.getAdvancedSearchResults()Ljava.util.List;(SearchImpl_$$_javassist_1.java:???)
   at web.SearchAction.doAdvancedSearch(SearchAction.java:186)
   at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
   at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
   at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
   at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)


Any thoughts as to why this may be?

Thanks.


Top
 Profile  
 
 Post subject: ClassCastException in Deployment But Not Testing
PostPosted: Tue Jan 15, 2008 6:47 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
By the way, I meant the title to be "ClassCastException in Deployment But Not Testing." I am an idiot.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 8:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It might be that you use JBoss As 4.2.x. In this case, you need to replace hibernate-annotations.jar (3.3) and add hibernate-commons-annotations.jar in the server lib directory.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 8:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum actually, which version of Seam and Hibernate Search are you using? Can you describe a bit your deployment artefacts

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 9:40 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I am using the Seam 2.0 GA distribution, which includes the Hibernate Search libraries, on WebLogic 9.2. When I get in the office tomorrow, I will give you more specifics on my deployment artifacts. Hopefully we can figure out what is different between my tests and my deployment.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 12:59 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Here is the list of JAR files in my WAR file (most of which are from the Seam 2.0 GA distribution):

Code:
62983 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/activation.jar
  5769 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/ant-antlr.jar
92015 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/antlr-runtime.jar
443432 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/antlr.jar
16777 Tue Jan 15 18:38:30 EST 2008 WEB-INF/lib/asm-attrs.jar
26360 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/asm.jar
324238 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/cglib-nodep.jar
282338 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/cglib.jar
188671 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/commons-beanutils.jar
571259 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/commons-collections.jar
143602 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/commons-digester.jar
38015 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/commons-logging.jar
4014911 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/core.jar
303207 Tue Jan 15 18:38:30 EST 2008 WEB-INF/lib/dom4j.jar
32941 Tue Jan 15 18:38:30 EST 2008 WEB-INF/lib/ejb-api.jar
29309 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/el-api.jar
2105147 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/groovy-all.jar
265130 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/hibernate-annotations.jar
66426 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/hibernate-commons-annotations.jar
116544 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/hibernate-entitymanager.jar
192762 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/hibernate-search.jar
60992 Tue Jan 15 18:38:30 EST 2008 WEB-INF/lib/hibernate-validator.jar
2242529 Tue Jan 15 18:38:30 EST 2008 WEB-INF/lib/hibernate.jar
450470 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/janino.jar
459663 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/javassist.jar
73081 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jaxb-api.jar
23618 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jaxws-api.jar
896119 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-aop.jar
419324 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-common-core.jar
133966 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-el.jar
  7740 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-logging-spi.jar
11588 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-seam-debug.jar
65103 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-seam-ioc.jar
209918 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-seam-ui.jar
835020 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jboss-seam.jar
360347 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jbossxb.jar
658168 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jbpm-jpdl.jar
306089 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jcommon.jar
2005783 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jgroups.jar
26257 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jms.jar
323012 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsf-api.jar
300600 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsf-facelets.jar
1210046 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsf-impl.jar
100636 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsp-api.jar
49672 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsr173_api.jar
  7989 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsr181-api.jar
  5848 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jsr250-api.jar
20801 Tue Jan 15 18:38:30 EST 2008 WEB-INF/lib/jstl.jar
  8812 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/jta.jar
367444 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/log4j.jar
538618 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/lucene-core.jar
388864 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/mail.jar
65638 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/meldware-mailapi.jar
1804086 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/meldware-mailjmx.jar
413756 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/mvel14.jar
1879924 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/ojdbc5.jar
52150 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/persistence-api.jar
111979 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/richfaces-api-3.1.3.GA.jar
1298805 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/richfaces-impl-3.1.3.GA.jar
1787738 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/richfaces-ui-3.1.3.GA.jar
127457 Tue Jan 15 18:38:28 EST 2008 WEB-INF/lib/urlrewritefilter.jar


Here is my persistence.xml:

Code:
<properties>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
         <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory"/>
         <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
         <property name="hibernate.search.default.indexBase" value="C:/search/indexes"/>
         <property name="hibernate.search.analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
</properties>


Let me know if you need further information. Thanks for any insight.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 7:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Did you try that:
Quote:
It might be that you use JBoss As 4.2.x. In this case, you need to replace hibernate-annotations.jar (3.3) and add hibernate-commons-annotations.jar in the server lib directory.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 11:31 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
No I didn't since I am not running on JBoss AS 4.2.x. I am running on WebLogic 9.2 as I mentioned previously. All the Hibernate libraries I am using are in the Seam 2.0 GA distribution. Are you suggesting that I should still get rid of hibernate-annotations.jar and just keep hibernate-commons-annotations.jar?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 11:41 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Perhaps I should mention that I am using JPA powered by Hibernate rather than Hibernate itself. The following represents what I am doing:

Code:
@In       //JPA EntityManager injected by Seam
private EntityManager em;
.
.
.
fullTextEntityManager = Search.createFullTextEntityManager(em);
.
.
.
fullTextQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, Widget.class);


Let me know if you need anything else.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 12:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I sort of understand why this could happen, but I don't understand why it does not in your unit tests.
Can you try not to use Search.createFTEM() but instead cast you em to a (FullTextEntityManager)?

If it does not work, try and do @In FullTextEntityManager em; to get an ftem injected directly

Is there a way you could strip down your app to the bare minimum so that I can test it myself?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 1:12 am 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Well, in my unit tests, Seam isn't really involved. Remember that the class that the "bad" cast is being performed on is a Seam class. It is related to Hibernate Search, but it isn't part of the Hibernate Search library. When I am testing, the interaction between Seam and Hibernate Search isn't tested. This might be a flaw in my testing approach in hindsight. I figured testing my Hibernate Search stuff in isolation and then testing the ability of my Seam-managed classes to find mock versions of my Hibernate Search stuff would be enough. After all, if Seam can find and use the mocks, and the Hibernate Search code finds everything well, then what could go wrong when the mocks are replaced by the real thing?

Oh how naive!

What configuration must I apply (presumably to components.xml) to either allow me to cast my em to ftem or to get the ftem injected directly?

I appreciate the offer, but it will be tough to strip down my app. Then again, if the other measures don't work, then I will give it a shot.

I will try your suggestions and get back to you.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 9:05 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes I always have been unomfortable with mocking esp since you can run an in memory DB and use the HSearch RamDirectoryProvider

No configuration is needed to cast or inject a FTEM
http://docs.jboss.com/seam/2.0.1.CR1/reference/en/html/search.html

What really puzzles me is that the DVDStore example does more or less what you're doing and there is not CCE.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 3:21 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I suppose I need to verify this, but if no configuration is needed, then I must be injecting an ftem anyway. So when I call this

Code:
Search.createFullTextEntityManager(em);


...the method should be returning the same em instance injected into the component but simply downcast. Assuming I understand your code correctly.

In my unit tests, I am bootstrapping an em and calling setField in SeamTest to simulate injection. Then Search.createFullTextEntityManager() is called to get me the ftem from the em.

In the case of the deployment, because I have added all the right JARs, the ftem itself should be injected directly, and the call to Search.createFullTextEntityManager() should just return the same object.

So I don't see how anything I am doing is "wrong." Has the DVDStore example been tried on WebLogic? Is it possible something wacky is happening with JAR files?

Well, the hunt for the answer continues.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 3:02 am 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I forgot to mention also that if you look at the top of the stack trace, all the fun starts with the class org.hibernate.search.jpa.impl.FullTextEntityManagerImpl. If that is the class of object that is supposed to be injected with

Code:
@In
private FullTextEntityManager entityManager


then it would seem that I obtained the FullTextEntityManager successfully. I suppose the issue is if in fact I got the right FullTextEntityManager implementation by doing it the current way. Or if "my" way somehow contradicts the expectation of Gavin's code in FullTextHibernateSessionProxy.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 21, 2008 3:22 am 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
Incidentally, it looks also like the instance of FullTextHibernateSessionProxy is what is returned from the call to em.getDelegate() when Hibernate Search is enabled. Is this so? I see nothing in the documentation about this class, so what purpose does it serve?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 17 posts ]  Go to page 1, 2  Next

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.