[hibernate-issues] [Hibernate-JIRA] Created: (ANN-568) Class cast exception in org.hibernate.search.impl.FullTextSessionImpl<init>(FullTextSessionImpl.java:54)

Adrian Pillinger (JIRA) noreply at atlassian.com
Thu Mar 1 05:41:31 EST 2007


Class cast exception in org.hibernate.search.impl.FullTextSessionImpl<init>(FullTextSessionImpl.java:54)
--------------------------------------------------------------------------------------------------------

         Key: ANN-568
         URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-568
     Project: Hibernate Annotations
        Type: Bug

    Versions: 3.2.1    
 Environment: JBoss 5.0.0 Beta1, Hibernate 3.2.2 GA, Hibernate Annotations 3.2.1 GA, Hibernate Entity Manager 3.2.1 GA
    Reporter: Adrian Pillinger
    Priority: Critical


This issue is also documented in the following thread, but no-one has replied to the original author.
http://forum.hibernate.org/viewtopic.php?t=968907&highlight=fulltextsessionimpl

The following class cast exception occurs inside org.hibernate.search.impl.FullTextSessionImpl.

java.lang.ClassCastException: org.jboss.ejb3.entity.TransactionScopedHibernateSession incompatible with org.hibernate.impl.SessionImpl
	at org.hibernate.search.impl.FullTextSessionImpl.<init>(FullTextSessionImpl.java:54)
	at org.hibernate.search.Search.createFullTextSession(Search.java:17)

This happens because FullTextSessionImpl's constructor is casting the org.hibernate.Session interface passed as an argument to the constructor to org.hibernate.impl.SessionImpl. Of course the jboss class TransactionScopedHibernateSession is not an instance of SessionImpl.

public class FullTextSessionImpl implements FullTextSession {

	private final SessionImpl session;

	private PostTransactionWorkQueueSynchronization postTransactionWorkQueueSynch;



	public FullTextSessionImpl(Session session) {

		this.session = (SessionImpl) session;

	}
...

Also, the method createFullTextQuery constructs an instance of FullTextQueryImpl with the session that the FullTextSessionImpl was instantiated with. The FullTextQueryImpl constructor expects to receive an instance of org.hibernate.engine.SessionImplementor. TransactionScopedHibernateSession and the interface org.hibernate.Session do not implement this interface.  


The following link is an issue in jira for JBoss EJB 3 about the fact it doesn't support SessionImplementor. Though I don't know if JBoss should implement this interface or not - it may well be bad design for JBoss to implement this just to get it working and perhaps some hibernate refactoring is needed to sort these issues out instead.

http://jira.jboss.com/jira/browse/EJBTHREE-714

FYI the class definition of TransactionScopedHibernateSession is as follows...

public class TransactionScopedHibernateSession implements Session, Externalizable
{
...
}


This is critical since the search functionality in 3.2.1GA of annotations cannot be used in JBoss as the Session is proxied by TransactionScopedHibernateSession.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list