Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

Hibernate and Struts

Anoop

2008-10-14

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,
We are looking forward to integrating struts with hibernate in our web
application project. Could you guide us on how to to integrate them. I
tried the hibernate plugin as recommended on the hibernate website,
however that throws a null pointer exception(when i try to instantiate
a session) when i test it in tomcat.

Relevant piece of code
in struts-config.xml
<plug-in
     className="de.laliluna.hibernate.plugin.HibernatePlugIn">
     <set-property
       property="configFilePath"
       value="/hibernate.cfg.xml" />
     <set-property
       property="storeInServletContext"
       value="true" />

In struts action
try{ServletContext context = request.getSession().getServletContext();
     SessionFactory _factory = (SessionFactory)
       context.getAttribute(HibernatePlugIn.SESSION_FACTORY_KEY);      
     Session ses = _factory.openSession(); <---this line throws exception
--
Anoop Dhanvijay
DA-IICT

"Most of man's failures were when they didn't realize how close they
were to success, when they finally gave up!"

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.