the UserDaoImpl class refers to hibernateTemplate in multiple statements most 
notably
public User getuser(String password) {
 return (User)getHibernateTemplate().find("from User as u where
 u.password = ?", password).get(0);

you'll need to define the hibernateTemplate bean which ref bean can refer to 
later on
<bean id="hibernateTemplate" 
class="org.springframework.orm.hibernate.HibernateTemplate">
  <property name="sessionFactory">
    <ref bean="sessionFactory"/>
  </property>
</bean>

<bean id="userDao" class="dao.UserDaoImpl">
 <property name="HibernateTemplate">
 <ref bean="HibernateTemplate"></ref>
 </property>
 </bean>

Martin Gainty 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und 
Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> From: bejaouiz...@hotmail.com
> To: user@struts.apache.org
> Subject: RE: Hibernate3+Spring2.5+Struts2
> Date: Thu, 20 Aug 2009 14:19:03 +0100
> 
> This is the definition of my session factory, hibernate properties and data
> source :
> <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>         <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
>         <property name="username" value="root"/>
>         <property name="password" value=""/>
>     </bean>
>     <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>         <property name="dataSource" ref="dataSource"/>
>         <property name="mappingResources">
>             <list>
>                 <value>po/user.hbm.xml</value>
>             </list>
>         </property>
>         <property name="hibernateProperties">
>  
> <value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
>         </property>
>     </bean>
> MY dao is not using hibernate template but sessuin factory I have changed it
> to this:
> 
> bean id="userDao" class="dao.UserDaoImpl">
>         <property name="HibernateTemplate">
>             <ref bean="HibernateTemplate"></ref>
>         </property>
>     </bean>
> Regarding the case consistency I have the table field userName, and the
> variable username, did you see any typing mistake.
> 
> I have run the example and seems that the problem is that hibernate template
> is not define how can i define it please I don’t know the syntax?
> 
> Here is the error:
> SEVERE: Exception sending context initialized event to listener instance of
> class org.springframework.web.context.ContextLoaderListener
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'userDao' defined in ServletContext resource
> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
> 'HibernateTemplate' while setting bean property 'HibernateTemplate'; nested
> exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'HibernateTemplate' is defined
> 
> 
> Thanks for your help 
> 
> 
> 
> -----Original Message-----
> From: Martin Gainty [mailto:mgai...@hotmail.com] 
> Sent: 20 August 2009 13:32
> To: Struts Users Mailing List
> Subject: RE: Hibernate3+Spring2.5+Struts2
> 
> 
> mg>take a look inside all of the provided xml files.. did you
> mg>define a sessionFactory..alternatively implements
> mg><property name="hibernate.properties">
> mg>or mappingResources 
> mg><property name="mappingResources">
> mg>or mappingDirectoryLocations
> mg><property name="mappingDirectoryLocations"/>
> 
> mg>a sessionFactory needs a dataSource jndiName something like
> mg><value>java:comp/env/jdbc/dataSource</value>
> mg>the sessionFactory refers to the datasource later on via property e.g.
> mg><bean id=sessionFactory" class="...LocalSessionFactoryBean"/>
> mg><property name="dataSource">
> mg><ref bean="dataSource"/>
> mg></property>
> mg></bean>
> 
> mg>did you define a HibernateTemplate whose property name="sessionFactory"?
> 
> mg>do your DAO beans use the hibernateTemplate?
> mg><bean id="someDAO" class="...someDaoHibernate">
> mg><property name="hibernateTemplate">
> mg>  <ref bean="hibernateTemplate">
> 
> mg>the hibernateTemplate statement find method is missing the type parameter
> >     public User getUser(String userName) {
> >         return (User)getHibernateTemplate().find("from User as u where
> > u.name = ?", userName).get(0);
> 
> mg>needs to change to 
> mg>public User getUser(String userName) {
> 
> mg>return (User)getHibernateTemplate().find("from User as u where u.name =
> ?", mg>userName,Hibernate.STRING);
> 
> 
> mg>also it is vital to maintain case-consistency for variable names as
> mg>username!=userName!=USERNAME!=Username
> 
> mg>post back those xml files when you get the chance
> 
> thanks,
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
> > From: bejaouiz...@hotmail.com
> > To: user@struts.apache.org
> > Subject: RE: Hibernate3+Spring2.5+Struts2
> > Date: Thu, 20 Aug 2009 11:17:16 +0100
> > 
> > I still have the same exception, I am posting all my code amd my project
> > structure hope you can fix me to fix the problem:
> > 
> > Package action:
> > 
> > package action;
> > 
> > import com.opensymphony.xwork2.ActionSupport;
> > import java.util.Locale;
> > import org.springframework.context.support.ResourceBundleMessageSource;
> > import po.User;
> > 
> > import service.UserService;
> > import service.UserServiceImp;
> > /**
> >  *
> >  * @author ABIS1
> >  */
> > 
> > public class LoginAction extends ActionSupport {
> >     
> >     private UserServiceImp userService;
> >     private String message;
> >     private String username;
> >     private String password;
> >     private ResourceBundleMessageSource messageSource;
> > 
> >     public LoginAction() {
> >     }
> > 
> >     @Override
> >     public String execute() throws Exception {
> >        
> >         
> >         
> >         User usr = userService.getUser(username);
> >        
> >         if(usr != null){
> >             if(usr.getPassword().equals(password)){
> >                 message = messageSource.getMessage("loginSuccess",
> > null,Locale.UK);
> >             }else{
> >                 message = messageSource.getMessage("pswError",
> > null,Locale.UK);
> >             }
> >         }else{
> >             message = messageSource.getMessage("usrError",
> > null,Locale.CHINA);          
> >         }
> >         return SUCCESS;
> >     }
> > 
> >     public void setUserService(UserServiceImp userService) {
> >         this.userService = userService;
> >     }
> > 
> >     public String getMessage() {
> >         return message;
> >     }
> > 
> >     public void setMessage(String message) {
> >         this.message = message;
> >     }
> > 
> >     public String getUsername() {
> >         return username;
> >     }
> > 
> >     public void setUsername(String username) {
> >         this.username = username;
> >     }
> > 
> >     public String getPassword() {
> >         return password;
> >     }
> > 
> >     public void setPassword(String password) {
> >         this.password = password;
> >     }
> > 
> >     public void setMessageSource(ResourceBundleMessageSource
> messageSource)
> > {
> >         this.messageSource = messageSource;
> >     }
> > 
> > }
> >
> ----------------------------------------------------------------------------
> > ----------------------------------------------------------------------
> > Package Dao:
> > 
> > package dao;
> > import po.User;
> > 
> > 
> > /**
> >  *
> >  * @author ABIS1
> >  */
> > public interface UserDao {
> >     
> >     void save(User user) throws Exception;
> >     User getUser(long userId);
> >     User getUser(String userName);
> >     User getuser (String password);
> > 
> > }___________________________________________________________
> > 
> > /*
> >  * To change this template, choose Tools | Templates
> >  * and open the template in the editor.
> >  */
> > 
> > package dao;
> > 
> > import po.*;
> > import dao.UserDao;
> > import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
> > 
> > /**
> >  *
> >  * @author ABIS1
> >  */
> > public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
> >     
> >     public void save(User user) throws Exception
> >     {
> >         try
> >         {
> >             getHibernateTemplate().save(user);
> >         }
> >         catch(Exception err)
> >         {
> >             throw err;
> >         }
> > 
> >     }   
> > 
> >     public User getUser(long userId)
> >     {
> >         return (User)getHibernateTemplate().get(User.class, userId);
> >     } 
> > 
> >     public User getUser(String userName) {
> >         return (User)getHibernateTemplate().find("from User as u where
> > u.name = ?", userName).get(0);
> >     }
> >     
> >     public User getuser(String password) {
> >         return (User)getHibernateTemplate().find("from User as u where
> > u.password = ?", password).get(0);
> >     }
> > 
> > }
> >
> ----------------------------------------------------------------------------
> > --------------------------------------------------------------------
> > Package service:
> > 
> > package service;
> > import dao.UserDaoImpl;
> > import po.User;
> > /**
> >  *
> >  * @author ABIS1
> >  */
> > public interface UserService {
> >     
> >     void addUser(String userName, String password) throws Exception;
> > 
> >     User getUser(long userId);
> >    
> >     User getUser(String userName);
> > 
> >     void setUserDao(UserDaoImpl userDao);
> > 
> > }
> > _____________________________________________________________________
> > 
> > /*
> >  * To change this template, choose Tools | Templates
> >  * and open the template in the editor.
> >  */
> > 
> > package service;
> > import po.User;
> > 
> > /**
> >  *
> >  * @author ABIS1
> >  */
> > public class UserServiceImp implements UserService {
> >     
> >      private dao.UserDao userDao;
> > 
> >     public void addUser(String userName, String password) throws
> Exception{
> >         po.User user = new User();
> >         
> >          
> >         user.setName(userName);
> >         user.setPassword(password);
> >         try
> >         {
> >             userDao.save(user);
> >         }
> >         catch(Exception err)
> >         {
> >             throw err;
> >         }
> >     }
> >     public User getUser(long userId)
> >     {
> >         return userDao.getUser(userId);
> >     }
> > 
> >     public void setUserDao(dao.UserDaoImpl userDao) {
> >         this.userDao = userDao;
> >     }
> > 
> >     public User getUser(String userName) {
> >         return this.userDao.getUser(userName);
> >     }
> > 
> > }
> > 
> > ----------------------------------------------------------------
> > 
> > Package PO:
> > 
> > /*
> >  * To change this template, choose Tools | Templates
> >  * and open the template in the editor.
> >  */
> > 
> > package po;
> > 
> > /**
> >  *
> >  * @author ABIS1
> >  */
> > public class User {
> >     
> >     private String Name; 
> >     private long id;
> >     private String password;
> > //   private int admin;
> > 
> >     public String getName() {
> >         return Name;
> >     }
> > 
> >     public void setName(String Name) {
> >         this.Name = Name;
> >     }
> > 
> >     public long getId() {
> >         return id;
> >     }
> > 
> >     public void setId(long id) {
> >         this.id = id;
> >     }
> > 
> >     public String getPassword() {
> >         return password;
> >     }
> > 
> >     public void setPassword(String password) {
> >         this.password = password;
> >     }
> >     
> >   /*  public void setAdmin (int admin)
> >     {this.admin=admin;}
> >     
> >     public int getAdmin ()
> >     {return admin;}*/
> >     
> >   
> >     
> >     
> > 
> > }
> > 
> >
> ____________________________________________________________________________
> > 
> > User.hbm.xml under po:
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> > 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
> > <hibernate-mapping>
> >   <class dynamic-insert="false" dynamic-update="false" mutable="true"
> > name="po.User" optimistic-lock="version" polymorphism="implicit"
> > select-before-update="false" table="user">
> > <id column="userId" name="id">
> >             <generator class="identity"/>
> >         </id>
> >         
> >         <property column="userName" name="name" type="string"/>
> >        
> >         <property column="password" name="password" type="string"/>
> >         </class>
> > </hibernate-mapping>
> > 
> >
> ----------------------------------------------------------------------------
> > -------------------------
> > 
> > My application context.xml: 
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > "http://www.springframework.org/dtd/spring-beans.dtd";>
> > 
> > <beans default-autowire="autodetect">
> >     <!-- add your spring beans here -->
> >     <bean id="dataSource"
> > class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> >         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
> >         <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
> >         <property name="username" value="root"/>
> >         <property name="password" value=""/>
> >     </bean>
> >     <bean id="sessionFactory"
> > class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> >         <property name="dataSource" ref="dataSource"/>
> >         <property name="mappingResources">
> >             <list>
> >                 <value>po/user.hbm.xml</value>
> >             </list>
> >         </property>
> >         <property name="hibernateProperties">
> >  
> > <value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
> >         </property>
> >     </bean>
> >     <bean id="userDao" class="dao.UserDaoImpl">
> >         <property name="sessionFactory">
> >             <ref bean="sessionFactory"></ref>
> >         </property>
> >     </bean> 
> >     <bean id="userService" class="service.UserServiceImp">
> >         <property name="userDao">
> >             <ref bean="userDao"></ref>
> >         </property>
> >     </bean>
> >     <bean id="messageSource"
> > class="org.springframework.context.support.ResourceBundleMessageSource"> 
> >         <property name="basename" value="messages" /> 
> >     </bean>
> > 
> >     <bean id="loginAction" class="action.LoginAction">
> >         <property name="userService">
> >             <ref bean="userService"></ref>
> >         </property>
> >         <property name="messageSource" ref="messageSource"/>
> >     </bean>
> > </beans>
> > 
> > 
> > Hope this can help.
> >  
> > 
> > 
> > 
> > -----Original Message-----
> > From: Martin Gainty [mailto:mgai...@hotmail.com] 
> > Sent: 20 August 2009 03:36
> > To: Struts Users Mailing List
> > Subject: RE: Hibernate3+Spring2.5+Struts2
> > 
> > 
> > he has his own MessageBundle
> > which was left out 
> > 
> > Martin Gainty 
> > ______________________________________________ 
> > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
> >  
> > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> > dient lediglich dem Austausch von Informationen und entfaltet keine
> > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> > destinataire prévu, nous te demandons avec bonté que pour satisfaire
> > informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie
> > de ceci est interdite. Ce message sert à l'information seulement et n'aura
> > pas n'importe quel effet légalement obligatoire. Étant donné que les email
> > peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> > aucune responsabilité pour le contenu fourni.
> > 
> > 
> > 
> > 
> > > Date: Wed, 19 Aug 2009 13:15:04 -0400
> > > Subject: Re: Hibernate3+Spring2.5+Struts2
> > > From: w...@wantii.com
> > > To: user@struts.apache.org
> > > 
> > > On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<newton.d...@yahoo.com>
> wrote:
> > > > Tommy Pham wrote:
> > > >>
> > > >> [stuff about java object instantiation]
> > > >
> > > > I suggest you review your Spring: Spring handles object instantiation
> > and
> > > > injection; it should *not* be done in the action if Spring is handling
> > > > object creation.
> > > >
> > > >
> > > >>> From: ZiedBejaoui <bejaouiz...@hotmail.com>
> > > >
> > > > Are you using the Spring plugin?
> > > >
> > > > [snip]
> > > 
> > > 
> > > Dave's right, make sure you have the spring plugin installed and that
> > > you have spring's listener configured in your web.xml file
> > > 
> > > 
> > > On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mgai...@hotmail.com>
> wrote:
> > > >
> > > > review your java
> > > >
> > > >>speaking of which
> > > >>did the op display the source for ResourceBundleMessageSource.java?
> > > >>Martin
> > > >
> > > > [snip]
> > > 
> > > @Martin -
> > > 
> > > What in Thor's holy name are you talking about?
> > > 
> > > -- 
> > > Wes Wannemacher
> > > 
> > > Head Engineer, WanTii, Inc.
> > > Need Training? Struts, Spring, Maven, Tomcat...
> > > Ask me for a quote!
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > For additional commands, e-mail: user-h...@struts.apache.org
> > > 
> > 
> > _________________________________________________________________
> > Get back to school stuff for them and cashback for you.
> >
> http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
> > oSchool_Cashback_BTSCashback_1x1
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> > 
> 
> _________________________________________________________________
> Hotmail® is up to 70% faster. Now good news travels really fast. 
> http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:W
> M_HYGN_faster:082009
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

_________________________________________________________________
With Windows Live, you can organize, edit, and share your photos.
http://www.windowslive.com/Desktop/PhotoGallery

Reply via email to