Ok, I was totally wrong. The whole problem hasn't to do anything with generics tomcat and so on.... Stupidity makes it a lot easier: I just didn't use my wonderfull HibernateUtil to close the session but closed it directly. Sorry!

Regards,
Andi



you were right. The problem was in my HibernateUtil class. I tried to get a session like this:

public static final ThreadLocal<Session> session = new ThreadLocal<Session>();
     public static Session currentSession() throws HibernateException {
       Session s = session.get();
       // If there is no session create one
       if(s==null){
           s = sessionFactory.openSession();
           session.set(s);
       }
       return s;
   }
     public static void closeSession() throws HibernateException {
       Session s = session.get();
       if(s != null){
           s.close();
       }
       session.set(null);
   }

After removing generics and adding the necessary casts it worked (though I don't understand the difference yet).

Regards,
Andi

It seems to me that this is more of a hibernate problem than a pluto
problem.  really, getting hibernate to work within a portlet should be
no different than doing it within a webapp.

Perhaps a stack trace and/or code snippet would help us get more specific.


David
On 12/3/05, Andreas Buechler <[EMAIL PROTECTED]> wrote:
Hi,

in my portlet I'm trying to access the db over hibernate. Unfortunately
this doesn't seem to be very reliable (at least how I configured it...).
After googeling a little I found out that the "Hibernate Reference
Documentation v3.0.5" isn't quite up to date and that you don't have to
use Tomcat's JNDI-bound JDBC connections anymore [2].

My problem is now that it still doesn't work in a  reliable way. The
symptoms are that if I access the portlet for the first time the db
query is (mostly) successful. After that I get NullPointerExceptions. To
make sure it's not my hibernate code, I tried the same query in
standalone application (without Tomcat/Pluto). It worked without any
problems.

Does anybody have a clue what's going wrong here? How did you get
hibernate to work reliable within your portlet? Any hints or suggestions
are highly appreciated!


[1] http://www.hibernate.org/hib_docs/v3/reference/en/html/quickstart.html
[2] http://www.hibernate.org/114.html

Regards,
Andi







Reply via email to