[jboss-user] [JBoss Seam] - seam and hibernate search give Session is closed! Exception

thiagu.m do-not-reply at jboss.com
Tue Nov 20 06:50:14 EST 2007


This is my project environment 

Jboss seam 2.0.0  CR1
jboss-4.2.0.GA

i  am trying for  Hibernate search with seam.

This are my entity bean classes 

  | import org.hibernate.search.annotations.Indexed;
  | import org.hibernate.search.annotations.DocumentId;
  | import org.hibernate.search.annotations.Index;
  | import org.hibernate.search.annotations.IndexedEmbedded;
  | @Entity
  | @Indexed
  | @Table(name="tbl_author")
  | public class TblAuthor implements Serializable {
  | 	@Id
  | 	@DocumentId
  | 	private Long authorId;
  | 
  | 	@Field(index=Index.TOKENIZED)
  | 	private String authorName;	
  | 	
  | 	@OneToMany(mappedBy="bookId",fetch=FetchType.EAGER)
  | 	@IndexedEmbedded
  | 	private Set<TblBook>  bookId;
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public TblAuthor() {
  | 		super();
  | 	}
  | 	.......
  | }
  | 
and 

  | @Entity
  | @Indexed
  | @Table(name="tbl_book")
  | public class TblBook implements Serializable {
  | 	@Id
  | 	@DocumentId
  | 	private Long bookId;
  | 
  | 	@Field(index=Index.TOKENIZED)
  | 	private String bookName;	
  | 	
  | 	@ManyToOne
  | 	@JoinColumn(name="author_Id")
  | 	private TblAuthor  authorId;
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public TblBook() {
  | 		super();
  | 	}
  | 	.......
  | }
  | 
and my persistence.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <!-- Persistence deployment descriptor for dev profile -->
  | <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
  |              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
  |              version="1.0">
  |              
  |    <persistence-unit name="booksearch">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |       <jta-data-source>java:/booksearchDatasource</jta-data-source>
  |       <properties>
  |          <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
  |          <property name="hibernate.hbm2ddl.auto" value="validate"/>
  |          <property name="hibernate.show_sql" value="true"/>
  |          <property name="hibernate.format_sql" value="true"/>
  | 
  | 		<!-- use a file system based index -->
  | 		 <property name="hibernate.search.default.directory_provider"
  | 				value="org.hibernate.search.store.FSDirectoryProvider"/>
  | 		 <!-- directory where the indexes will be stored -->
  | 		 <property name="hibernate.search.default.indexBase"
  | 				value="/booksearch_index"/>
  | 		
  | 		 <property name="hibernate.ejb.event.post-insert" 
  |                    value="org.hibernate.search.event.FullTextIndexEventListener"/>
  |          <property name="hibernate.ejb.event.post-update" 
  |                    value="org.hibernate.search.event.FullTextIndexEventListener"/>
  |          <property name="hibernate.ejb.event.post-delete" 
  |                    value="org.hibernate.search.event.FullTextIndexEventListener"/>
  | 		 
  | 		
  | 
  |          <property name="jboss.entity.manager.factory.jndi.name" value="java:/booksearchEntityManagerFactory"/>
  |          <property name="hibernate.default_schema" value="root"/>
  |       </properties>
  |    </persistence-unit>
  |     
  | </persistence>
  | 
and my application.xml is 

  | <?xml version="1.0" encoding="UTF-8"?>
  | <application xmlns="http://java.sun.com/xml/ns/javaee" 
  |              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
  |              version="5">
  |     
  |    <display-name>booksearch</display-name>
  |    
  |    <module>
  |       <web>
  |          <web-uri>booksearch.war</web-uri>
  |          <context-root>/booksearch</context-root>
  |       </web>
  |    </module>
  |    
  |    <module>
  |       <ejb>booksearch.jar</ejb>
  |    </module>
  |    
  |    <!-- Seam and EL -->
  |    <module>
  |        <ejb>jboss-seam.jar</ejb>
  |    </module>    
  |      <module>
  |        <ejb>hibernate-search.jar</ejb>
  |    </module>
  |    <module>
  |        <ejb>hibernate-commons-annotations.jar</ejb>
  |    </module>
  |    <module>
  |        <ejb>lucene-core-2.2.0.jar</ejb>
  |    </module>
  | 
  | </application>
  | 
this is my session bean classes for creating index when i deploy my project 

  | public interface Indexer
  | {
  |    
  | 	public String createHsIndex();
  | 	void stop();
  | }
  | 
  | @Name("indexer")
  | @Stateful
  | @Scope(ScopeType.APPLICATION )
  | @Startup
  | public class IndexerAction implements Indexer
  | {
  |   
  | @PersistenceContext
  |    private EntityManager em;  
  | 
  |    @Create
  |    public String createHsIndex(){
  | 		try {
  | 			FullTextEntityManager ftEm = (FullTextEntityManager) em;	
  | 			
  | 			List<TblThreadForum> result =  em.createQuery("select t from TblAuthor t").getResultList();
  | 			
  | 			for ( TblAuthor a : result)
  | 			{
  | 				ftEm.index(a);
  | 			}
  | 			
  | 		} catch (Exception e) {
  | 			return "Exception";
  | 		}
  | 		return "OK";
  | 	}
  | 
  | 
  |    @Remove
  |    @Destroy
  |    public void stop() {}
  |    
  | }
  | 
this is my session bean classes for searching action


  | @Local
  | public interface BookSearch {
  | 	
  | 	
  | 	public String doSearch();
  | 		
  | 	public void destroy();
  | 	public void reset();
  | 
  | }
  | 
  | 
  | @Stateful
  | @Name("booksearch")
  | public class BookSearchAction implements BookSearch,Serializable
  | {			
  | 	private static final long serialVersionUID = -4505302935023794131L;
  | 	
  | 		String searchString;
  | 
  | 		@PersistenceContext
  |    		EntityManager em;		
  | 		@Begin(join = true)
  | 		public String doSearch()
  | 		{
  | 		FullTextEntityManager fullTextEntityManager =(FullTextEntityManager)em;	 
  | 		MultiFieldQueryParser parser = new MultiFieldQueryParser( new 			String[]{"authorId", "authorName",”bookId”}, new StandardAnalyzer());
  | 	Query query = parser.parse( "Java rocks!" );
  | 	org.hibernate.Query hibQuery = fullTextEntityManager.createFullTextQuery( query, TblAuthor.class );
  | List<TblAuthor> result = hibQuery.list();
  | 
  | 			
  | 		} 	 
  | 	   
  | 		
  | 		
  | 	    @Destroy 
  | 	    @Remove
  | 	    public void destroy() {}
  | 	    
  | 	    @End
  | 	    public void reset() {}
  | }
  | 
it creates index successfully 
but the search is works at once
when i try to search second time it gives this Exception 

  | 17:07:00,375 FATAL [application] /bookearch.xhtml @58,71 action="#{forumsearch.doSearch}": javax.ejb.EJBTransactionRolledbackException: Session is closed!
  | javax.faces.el.EvaluationException: /booksearch.xhtml @58,71 action="#{booksearch.doSearch}": javax.ejb.EJBTransactionRolledbackException: Session is closed!
  | 	at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
  | 	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
  | 	at javax.faces.component.UICommand.broadcast(UICommand.java:383)
  | 	at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61)
  | 	at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
  | 	at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
  | 	at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
  | 	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
  | 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  | 	at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
  | 	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
  | 	at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  | 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
  | 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
  | 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
  | 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
  | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  | 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
  | 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  | 	at java.lang.Thread.run(Unknown Source)
  | 
  | 
  | Caused by: javax.ejb.EJBTransactionRolledbackException: Session is closed!
  | 	at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
  | 	at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
  | 	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 	at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
  | 	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  | 	at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:204)
  | 	at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:100)
  | 	at $Proxy173.doSearch(Unknown Source)
  | 	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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
  | 	at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
  | 	at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
  | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
  | 	at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
  | 	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.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
  | 	at org.javassist.tmp.java.lang.Object_$$_javassist_3.doSearch(Object_$$_javassist_3.java)
  | 	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.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
  | 	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341)
  | 	at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
  | 	at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
  | 	at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
  | 	at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
  | 	at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
  | 	... 47 more
  | 
  | 
  | 
  | 
  | Caused by: org.hibernate.SessionException: Session is closed!
  | 	at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
  | 	at org.hibernate.impl.SessionImpl.createCriteria(SessionImpl.java:1508)
  | 	at org.hibernate.search.engine.QueryLoader.load(QueryLoader.java:60)
  | 	at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:244)
  | 	at org.hibernate.search.jpa.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:85)
  | 	at session.beans.BookSearhAction.doSearch(BookSearhAction.java:160)
  | 	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.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:56)
  | 	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.GeneratedMethodAccessor526.invoke(Unknown Source)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  | 	at java.lang.reflect.Method.invoke(Unknown Source)
  | 	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:57)
  | 	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)
  | 	... 87 more
  | 

is there i made any mistake ?
please any one help me how to resolve this problem 

By 
Thiagu.m




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106325#4106325

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106325




More information about the jboss-user mailing list