-->
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.  [ 10 posts ] 
Author Message
 Post subject: Problem with Hibernate Search
PostPosted: Thu Sep 11, 2008 5:46 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Hi All,

I am trying to search the stored data where, i am getting following error

Caused by: 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.index(FullTextEntityManagerImpl.java:65)
at org.mobite.mucc.action.InstantMessageAction.search(InstantMessageAction.java:61)
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:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
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.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
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.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
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.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
at sun.reflect.GeneratedMethodAccessor178.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
... 89 more


the piece of code where i am trying to fetch the data..

FullTextQuery fullTextQuery= getData();
List<InstantMessage> result = hibQuery.getResultList();


public FullTextQuery getData() {
FullTextEntityManager fullTextEntityManager = Search
.createFullTextEntityManager(em);
String temp = "message";
QueryParser parser = new MultiFieldQueryParser(
new String[] { "message"}, new StandardAnalyzer());
Query query = null;
org.apache.lucene.search.Query luceneQuery= null;
try {
luceneQuery = parser
.parse(getSearchString());
} catch (ParseException parEx) {
parEx.printStackTrace();
}

return ( (FullTextEntityManager) em ).createFullTextQuery(luceneQuery, InstantMessage.class);

}

Any Buddy knows whats worng


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 6:27 am 
Hibernate Team
Hibernate Team

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

shouldn't

Code:
return ( (FullTextEntityManager) em ).createFullTextQuery(luceneQuery, InstantMessage.class);


actually be

Code:
return fullTextEntityManager.createFullTextQuery(luceneQuery, InstantMessage.class);


--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 6:42 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Hi Hardy,

Thanks for your reply :)

I have tried with the changes but no luck still its giving the same error :(

any other solution for it?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 9:50 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Hi Hardy,

Hope this will help you to understand my problem :)

Code:
             FullTextEntityManager fullTextEntityManager = Search
            .createFullTextEntityManager(em);
      
      List<InstantMessage> instantMessages = em.createQuery(
            "select o from InstantMessage as o").getResultList();
      for (InstantMessage instantMessage : instantMessages) {
      
            fullTextEntityManager.index(instantMessage);
         }
      FullTextQuery fullTextQuery= getData();
      javax.persistence.Query hibQuery= fullTextQuery;
       List<InstantMessage> result = hibQuery.getResultList();
      




Code:
public FullTextQuery getData() {
      FullTextEntityManager fullTextEntityManager = Search
            .createFullTextEntityManager(em);
      String temp = "message";
      QueryParser parser = new MultiFieldQueryParser(
            new String[] { "message"}, new StandardAnalyzer());
      Query query = null;
      org.apache.lucene.search.Query luceneQuery= null;
      try {
         luceneQuery = parser
               .parse(getSearchString());
      } catch (ParseException parEx) {
         parEx.printStackTrace();
      }
      return fullTextEntityManager.createFullTextQuery(luceneQuery, InstantMessage.class);
   }





Code:
@Entity
@Indexed
@Analyzer
@Table(name = "INSTANTMESSAGE")
public class InstantMessage implements Serializable {
@DocumentId
   @Id
   @GeneratedValue
   @Column(name = "INSTANTMESSAGEID")
   long id;

@Column(name = "MESSAGE", unique = false, nullable = false, length = 50)
   @Field(index=Index.TOKENIZED, store=Store.NO)
   String message;   

getter and setter.......




Any Idea Now :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 2:32 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you could try using

Code:
@In FullTextEntityManager em;

to get a FullTextEntityManager, no need for casts or calling the Search wrapping method.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2008 2:12 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Still no luck :( :(

this time i tried with the SOP's here are the details of it


FullTextEntityManager fullTextEntityManager = Search
.createFullTextEntityManager(em);

List<InstantMessage> instantMessages = em.createQuery(
"select o from InstantMessage as o").getResultList();
for (InstantMessage instantMessage : instantMessages) {

fullTextEntityManager.index(instantMessage);
}
System.out.println("getData() "+ getData());
FullTextQuery fullTextQuery= getData();
System.out.println("fullTextQuery " + fullTextQuery);
javax.persistence.Query hibQuery= fullTextQuery;
//Line where i am getting error
List<InstantMessage> result = hibQuery.getResultList();






public FullTextQuery getData() {
FullTextEntityManager fullTextEntityManager = Search
.createFullTextEntityManager(em);
String temp = "message";
QueryParser parser = new MultiFieldQueryParser(
new String[] { "message"}, new StandardAnalyzer());
Query query = null;
org.apache.lucene.search.Query luceneQuery= null;
try {
luceneQuery = parser
.parse(getSearchString());
} catch (ParseException parEx) {
parEx.printStackTrace();
}
System.out.println("luceneQuery" + luceneQuery);
return fullTextEntityManager.createFullTextQuery(luceneQuery, InstantMessage.class);
}


Output

getData() test
luceneQuery message:test
fullTextQuery org.hibernate.search.jpa.impl.FullTextQueryImpl@b930e4

and the error
Caused by: 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 ...........................


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 14, 2008 12:36 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you tell us which versions of HSearch and Seam you are using?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2008 12:35 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Hi,

Sure, here is the details of .jar files.

Seam

jboss-seam-debug-2.0.0.GA
jboss-seam-ui-2.0.0.GA

Hibernate

<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>3.0.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.3.1.ga</version>

Any clue now :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 9:24 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I imagine you are using JBoss AS 5, can you try

http://www.hibernate.org/446.html#A6
When I run Hibernate Search in JBoss AS 4.2, I get a NoSuchMethodError?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 10:39 am 
Beginner
Beginner

Joined: Thu Sep 11, 2008 5:33 am
Posts: 28
Hi Emmanuel,

Thanks for your curiosity. Actually i am using JBOSS.2.2.4.GA and thanks to you all of your support i have resolve the problem :)

cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.