1 Reply Latest reply on Mar 3, 2004 1:34 PM by Renaat Van Hee

    Trying to return an unknown connection (hibernate)

    Renaat Van Hee Newbie

      platform :
      hibernate 2.1
      jboss 3.2.2
      mysql 4.0

      situation
      Accessing the database through hibernate from a stateless sessionbean throws an illegalStateException : Trying to return an unknown connection

      case
      When a user logs on to the application I need to verify the user and create an application-session (not to confuse with hibernate session) in the database recording the login. The id of the generated session is returned to the caller so it can be used in later communications.

      setup
      * 2 DAO classes (User and Session) for accessing the relevant tables. The hibernate session used within these objects is determined by means of the ThreadLocal pattern as described on the Hibernate site. At the end of every operation a session.close is triggered.
      * 2 stateless session beans form a front to the DAO's (UserMgr and SessionMgr)
      * 1 stateless session bean communicates with the 2 session beans (SessionPresentation)

      communication
      1) A user logs in the application by triggering a login method on the SessionPresentation bean. This first checks if the user is known in the system by triggering a select on the UserDAO object. The user is retrieved correctly.
      2) The next step is that an application session is created by triggering a method on the SessionMgr bean. This uses the SessionDAO to create the session in the database and returns the id of the generated session.
      3) The sessionPresentation then triggers a method on the SessionMgr (by means of the local interface) to retrieve the newly generated application session. At this moment the exception is thrown ....

      I already looked at several postings within the forum but couldn't find an answer.

      Thx to anybody who replies

      Renaat