RE: Hibernate3+Spring2.5+Struts2
property name=sessionFactoryref bean=sessionFactory //property /bean bean id=userDao class=dao.UserDaoImpl property name=hibernateTemplate ref bean=hibernateTemplate/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 Struts.xml struts include file=example.xml/ !-- Configuration for the default package. -- package name=default extends=struts-default action name=login class=action.LoginAction resultexample/message.jsp/result /action /package /struts Thannks. -Original Message- From: Wes Wannemacher [mailto:w...@wantii.com] Sent: 20 August 2009 19:44 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. You were on the right track before, you just want the following in your class - -snippet private UserService userService; public void setUserService(UserService userService) { this.userService = userService; } - end snippet I am curious if it's 'userService' that is null... This would mean that your action isn't being wired with the service from Spring. I snipped all the previous messages from this email, so i can't look through it for you, but I will say that this sort of thing is generally a simple property misspelling or some other detail (decimal point? I always mess up some mundane detail). If it's username that is null, you might want to check that your form is properly setup in your JSP. -Wes -- 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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
hi wes, I have changed the code but still have the same exception, would you min if I send you my whole code maybe you can find out the problem? cheers, -- From: Wes Wannemacher w...@wantii.com Sent: Thursday, August 20, 2009 7:44 PM To: Struts Users Mailing List user@struts.apache.org Subject: Re: Hibernate3+Spring2.5+Struts2 On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. You were on the right track before, you just want the following in your class - -snippet private UserService userService; public void setUserService(UserService userService) { this.userService = userService; } - end snippet I am curious if it's 'userService' that is null... This would mean that your action isn't being wired with the service from Spring. I snipped all the previous messages from this email, so i can't look through it for you, but I will say that this sort of thing is generally a simple property misspelling or some other detail (decimal point? I always mess up some mundane detail). If it's username that is null, you might want to check that your form is properly setup in your JSP. -Wes -- 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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
sure, zip it up and email it to me -Wes On Fri, Aug 21, 2009 at 10:00 AM, ZiedBejaouibejaouiz...@hotmail.com wrote: hi wes, I have changed the code but still have the same exception, would you min if I send you my whole code maybe you can find out the problem? cheers, -- From: Wes Wannemacher w...@wantii.com Sent: Thursday, August 20, 2009 7:44 PM To: Struts Users Mailing List user@struts.apache.org Subject: Re: Hibernate3+Spring2.5+Struts2 On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. You were on the right track before, you just want the following in your class - -snippet private UserService userService; public void setUserService(UserService userService) { this.userService = userService; } - end snippet I am curious if it's 'userService' that is null... This would mean that your action isn't being wired with the service from Spring. I snipped all the previous messages from this email, so i can't look through it for you, but I will say that this sort of thing is generally a simple property misspelling or some other detail (decimal point? I always mess up some mundane detail). If it's username that is null, you might want to check that your form is properly setup in your JSP. -Wes -- 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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- 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
RE: Hibernate3+Spring2.5+Struts2
no problem FYI: most email agents have a 10mb attach limit so send only java,xml and properties in compressed zip or gzip.tar 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: Fri, 21 Aug 2009 15:00:44 +0100 hi wes, I have changed the code but still have the same exception, would you min if I send you my whole code maybe you can find out the problem? cheers, -- From: Wes Wannemacher w...@wantii.com Sent: Thursday, August 20, 2009 7:44 PM To: Struts Users Mailing List user@struts.apache.org Subject: Re: Hibernate3+Spring2.5+Struts2 On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. You were on the right track before, you just want the following in your class - -snippet private UserService userService; public void setUserService(UserService userService) { this.userService = userService; } - end snippet I am curious if it's 'userService' that is null... This would mean that your action isn't being wired with the service from Spring. I snipped all the previous messages from this email, so i can't look through it for you, but I will say that this sort of thing is generally a simple property misspelling or some other detail (decimal point? I always mess up some mundane detail). If it's username that is null, you might want to check that your form is properly setup in your JSP. -Wes -- 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 - 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
Re: Hibernate3+Spring2.5+Struts2
I will split it into 3 war files. Cheers -- From: Martin Gainty mgai...@hotmail.com Sent: Friday, August 21, 2009 3:35 PM To: Struts Users Mailing List user@struts.apache.org Subject: RE: Hibernate3+Spring2.5+Struts2 no problem FYI: most email agents have a 10mb attach limit so send only java,xml and properties in compressed zip or gzip.tar 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: Fri, 21 Aug 2009 15:00:44 +0100 hi wes, I have changed the code but still have the same exception, would you min if I send you my whole code maybe you can find out the problem? cheers, -- From: Wes Wannemacher w...@wantii.com Sent: Thursday, August 20, 2009 7:44 PM To: Struts Users Mailing List user@struts.apache.org Subject: Re: Hibernate3+Spring2.5+Struts2 On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. You were on the right track before, you just want the following in your class - -snippet private UserService userService; public void setUserService(UserService userService) { this.userService = userService; } - end snippet I am curious if it's 'userService' that is null... This would mean that your action isn't being wired with the service from Spring. I snipped all the previous messages from this email, so i can't look through it for you, but I will say that this sort of thing is generally a simple property misspelling or some other detail (decimal point? I always mess up some mundane detail). If it's username that is null, you might want to check that your form is properly setup in your JSP. -Wes -- 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 - 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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Hibernate3+Spring2.5+Struts2
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 valuepo/user.hbm.xml/value /list /property property name=hibernateProperties valuehibernate.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 Newtonnewton.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
RE: Hibernate3+Spring2.5+Struts2
mgtake a look inside all of the provided xml files.. did you mgdefine a sessionFactory..alternatively implements mgproperty name=hibernate.properties mgor mappingResources mgproperty name=mappingResources mgor mappingDirectoryLocations mgproperty name=mappingDirectoryLocations/ mga sessionFactory needs a dataSource jndiName something like mgvaluejava:comp/env/jdbc/dataSource/value mgthe sessionFactory refers to the datasource later on via property e.g. mgbean id=sessionFactory class=...LocalSessionFactoryBean/ mgproperty name=dataSource mgref bean=dataSource/ mg/property mg/bean mgdid you define a HibernateTemplate whose property name=sessionFactory? mgdo your DAO beans use the hibernateTemplate? mgbean id=someDAO class=...someDaoHibernate mgproperty name=hibernateTemplate mg ref bean=hibernateTemplate mgthe 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); mgneeds to change to mgpublic User getUser(String userName) { mgreturn (User)getHibernateTemplate().find(from User as u where u.name = ?, mguserName,Hibernate.STRING); mgalso it is vital to maintain case-consistency for variable names as mgusername!=userName!=USERNAME!=Username mgpost 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
RE: Hibernate3+Spring2.5+Struts2
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 valuepo/user.hbm.xml/value /list /property property name=hibernateProperties valuehibernate.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 dont 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 mgtake a look inside all of the provided xml files.. did you mgdefine a sessionFactory..alternatively implements mgproperty name=hibernate.properties mgor mappingResources mgproperty name=mappingResources mgor mappingDirectoryLocations mgproperty name=mappingDirectoryLocations/ mga sessionFactory needs a dataSource jndiName something like mgvaluejava:comp/env/jdbc/dataSource/value mgthe sessionFactory refers to the datasource later on via property e.g. mgbean id=sessionFactory class=...LocalSessionFactoryBean/ mgproperty name=dataSource mgref bean=dataSource/ mg/property mg/bean mgdid you define a HibernateTemplate whose property name=sessionFactory? mgdo your DAO beans use the hibernateTemplate? mgbean id=someDAO class=...someDaoHibernate mgproperty name=hibernateTemplate mg ref bean=hibernateTemplate mgthe 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); mgneeds to change to mgpublic User getUser(String userName) { mgreturn (User)getHibernateTemplate().find(from User as u where u.name = ?, mguserName,Hibernate.STRING); mgalso it is vital to maintain case-consistency for variable names as mgusername!=userName!=USERNAME!=Username mgpost 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
RE: Hibernate3+Spring2.5+Struts2
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 valuepo/user.hbm.xml/value /list /property property name=hibernateProperties valuehibernate.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 mgtake a look inside all of the provided xml files.. did you mgdefine a sessionFactory..alternatively implements mgproperty name=hibernate.properties mgor mappingResources mgproperty name=mappingResources mgor mappingDirectoryLocations mgproperty name=mappingDirectoryLocations/ mga sessionFactory needs a dataSource jndiName something like mgvaluejava:comp/env/jdbc/dataSource/value mgthe sessionFactory refers to the datasource later on via property e.g. mgbean id=sessionFactory class=...LocalSessionFactoryBean/ mgproperty name=dataSource mgref bean=dataSource/ mg/property mg/bean mgdid you define
RE: Hibernate3+Spring2.5+Struts2
Hi Martin, Thanks for your help, i have de fined the hibernate template like this like this: bean id=hibernateTemplate class=org.springframework.orm.hibernate3.HibernateTemplate property name=sessionFactoryref bean=sessionFactory //property /bean And then use it in the DAO: I couldnt change this line by adding the parameter cause it shows an error so kept it like this: public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); } Now when running I get this error: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'messageSource' of bean class [action.LoginAction]: Bean property 'messageSource' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? And yes my getter and setter for message take both a String parameter. -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 mgtake a look inside all of the provided xml files.. did you mgdefine a sessionFactory..alternatively implements mgproperty name=hibernate.properties mgor mappingResources mgproperty name=mappingResources mgor mappingDirectoryLocations mgproperty name=mappingDirectoryLocations/ mga sessionFactory needs a dataSource jndiName something like mgvaluejava:comp/env/jdbc/dataSource/value mgthe sessionFactory refers to the datasource later on via property e.g. mgbean id=sessionFactory class=...LocalSessionFactoryBean/ mgproperty name=dataSource mgref bean=dataSource/ mg/property mg/bean mgdid you define a HibernateTemplate whose property name=sessionFactory? mgdo your DAO beans use the hibernateTemplate? mgbean id=someDAO class=...someDaoHibernate mgproperty name=hibernateTemplate mg ref bean=hibernateTemplate mgthe 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); mgneeds to change to mgpublic User getUser(String userName) { mgreturn (User)getHibernateTemplate().find(from User as u where u.name = ?, mguserName,Hibernate.STRING); mgalso it is vital to maintain case-consistency for variable names as mgusername!=userName!=USERNAME!=Username mgpost 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
RE: Hibernate3+Spring2.5+Struts2
snip action.LoginAction contents: public void setMessageSource(ResourceBundleMessageSource messageSource) { this.messageSource = messageSource; }since messageSource is private LoginAction will require getMessageSource e.g. public ResourceBundleMessageSource getMessageSource() { return this.messageSource; } 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 14:41:18 +0100 Hi Martin, Thanks for your help, i have de fined the hibernate template like this like this: bean id=hibernateTemplate class=org.springframework.orm.hibernate3.HibernateTemplate property name=sessionFactoryref bean=sessionFactory //property /bean And then use it in the DAO: I couldn’t change this line by adding the parameter cause it shows an error so kept it like this: public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); } Now when running I get this error: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'messageSource' of bean class [action.LoginAction]: Bean property 'messageSource' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? And yes my getter and setter for message take both a String parameter. -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 mgtake a look inside all of the provided xml files.. did you mgdefine a sessionFactory..alternatively implements mgproperty name=hibernate.properties mgor mappingResources mgproperty name=mappingResources mgor mappingDirectoryLocations mgproperty name=mappingDirectoryLocations/ mga sessionFactory needs a dataSource jndiName something like mgvaluejava:comp/env/jdbc/dataSource/value mgthe sessionFactory refers to the datasource later on via property e.g. mgbean id=sessionFactory class=...LocalSessionFactoryBean/ mgproperty name=dataSource mgref bean=dataSource/ mg/property mg/bean mgdid you define a HibernateTemplate whose property name=sessionFactory? mgdo your DAO beans use the hibernateTemplate? mgbean id=someDAO class=...someDaoHibernate mgproperty name=hibernateTemplate mg ref bean=hibernateTemplate mgthe 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); mgneeds to change to mgpublic User getUser(String userName) { mgreturn (User)getHibernateTemplate().find(from User as u where u.name = ?, mguserName,Hibernate.STRING); mgalso it is vital to maintain case-consistency for variable names as mgusername!=userName!=USERNAME!=Username mgpost 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
Re: Hibernate3+Spring2.5+Struts2
Hi martin, Thanks again the template are message source problems are solved, however now I am getting a NullPointerException in the Login Action class in this line: User usr= userService.getUser(username); Here is the setter of userService: Public void SetUserService (UserServiceImp userService) { this.userService=userService; } I cant find out what is the reaosn of the NPE. Cheers, -- From: Martin Gainty mgai...@hotmail.com Sent: Thursday, August 20, 2009 2:48 PM To: Struts Users Mailing List user@struts.apache.org Subject: RE: Hibernate3+Spring2.5+Struts2 snip action.LoginAction contents: public void setMessageSource(ResourceBundleMessageSource messageSource) { this.messageSource = messageSource; }since messageSource is private LoginAction will require getMessageSource e.g. public ResourceBundleMessageSource getMessageSource() { return this.messageSource; } 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 14:41:18 +0100 Hi Martin, Thanks for your help, i have de fined the hibernate template like this like this: bean id=hibernateTemplate class=org.springframework.orm.hibernate3.HibernateTemplate property name=sessionFactoryref bean=sessionFactory //property /bean And then use it in the DAO: I couldn’t change this line by adding the parameter cause it shows an error so kept it like this: public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); } Now when running I get this error: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'messageSource' of bean class [action.LoginAction]: Bean property 'messageSource' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? And yes my getter and setter for message take both a String parameter. -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 mgtake a look inside all of the provided xml files.. did you mgdefine a sessionFactory..alternatively implements mgproperty name=hibernate.properties mgor mappingResources mgproperty name=mappingResources mgor mappingDirectoryLocations mgproperty name=mappingDirectoryLocations/ mga sessionFactory needs a dataSource jndiName something like mgvaluejava:comp/env/jdbc/dataSource/value mgthe sessionFactory refers to the datasource later on via property e.g. mgbean id=sessionFactory class=...LocalSessionFactoryBean/ mgproperty name=dataSource mgref bean=dataSource/ mg/property mg/bean mgdid you define a HibernateTemplate whose property name=sessionFactory? mgdo your DAO beans use the hibernateTemplate? mgbean id=someDAO class=...someDaoHibernate mgproperty name=hibernateTemplate mg ref bean=hibernateTemplate mgthe 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); mgneeds to change to mgpublic User getUser(String userName) { mgreturn (User)getHibernateTemplate().find(from User as u where u.name = ?, mguserName,Hibernate.STRING); mgalso it is vital to maintain case-consistency for variable names as mgusername!=userName!=USERNAME!=Username mgpost 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
Re: Hibernate3+Spring2.5+Struts2
On Thu, Aug 20, 2009 at 11:13 AM, Martin Gaintymgai...@hotmail.com wrote: cannot do a get(0) on a null result Might be true, but it also demonstrates why method chaining can be troublesome, we don't know if the NPE is coming from there or from the call to getHibernateTemplate(), etc. I would suggest breaking this line into multiple lines. It will give you an indication whether you are still having wiring problems or if the NPE is caused from a lack of results on your query (as Martin is indicating). public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); }public interface UserService cannot be referenced directly so best to use your impl class change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); traditionally implementation classes are named ClassNameImpl instead of ClassNameImp Martin, that is just silly, it's a *good* practice to program to interfaces and leave yourself the ability to swap out implementations later... It's pretty much Spring 101. avoid static references such as userService.getUser(username); better to getUserService().getUser(username); //which means the *Action will need accessor method getUserService defined e.g. public UserServiceImp getUserService() { return userService; } Martin Gainty -- 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
RE: Hibernate3+Spring2.5+Struts2
agreed..i would also suggest wrap the code in try catch for the NullPointerException good call wes! 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: Thu, 20 Aug 2009 11:21:31 -0400 Subject: Re: Hibernate3+Spring2.5+Struts2 From: w...@wantii.com To: user@struts.apache.org On Thu, Aug 20, 2009 at 11:13 AM, Martin Gaintymgai...@hotmail.com wrote: cannot do a get(0) on a null result Might be true, but it also demonstrates why method chaining can be troublesome, we don't know if the NPE is coming from there or from the call to getHibernateTemplate(), etc. I would suggest breaking this line into multiple lines. It will give you an indication whether you are still having wiring problems or if the NPE is caused from a lack of results on your query (as Martin is indicating). public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); }public interface UserService cannot be referenced directly so best to use your impl class change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); traditionally implementation classes are named ClassNameImpl instead of ClassNameImp Martin, that is just silly, it's a *good* practice to program to interfaces and leave yourself the ability to swap out implementations later... It's pretty much Spring 101. avoid static references such as userService.getUser(username); better to getUserService().getUser(username); //which means the *Action will need accessor method getUserService defined e.g. public UserServiceImp getUserService() { return userService; } Martin Gainty -- 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 _ 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:WM_HYGN_faster:082009
RE: Hibernate3+Spring2.5+Struts2
cannot do a get(0) on a null result public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); }public interface UserService cannot be referenced directly so best to use your impl class change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); traditionally implementation classes are named ClassNameImpl instead of ClassNameImp avoid static references such as userService.getUser(username); better to getUserService().getUser(username); //which means the *Action will need accessor method getUserService defined e.g. public UserServiceImp getUserService() { return userService; } 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 15:03:11 +0100 Hi martin, Thanks again the template are message source problems are solved, however now I am getting a NullPointerException in the Login Action class in this line: User usr= userService.getUser(username); Here is the setter of userService: Public void SetUserService (UserServiceImp userService) { this.userService=userService; } I cant find out what is the reaosn of the NPE. Cheers, -- From: Martin Gainty mgai...@hotmail.com Sent: Thursday, August 20, 2009 2:48 PM To: Struts Users Mailing List user@struts.apache.org Subject: RE: Hibernate3+Spring2.5+Struts2 snip action.LoginAction contents: public void setMessageSource(ResourceBundleMessageSource messageSource) { this.messageSource = messageSource; }since messageSource is private LoginAction will require getMessageSource e.g. public ResourceBundleMessageSource getMessageSource() { return this.messageSource; } 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 14:41:18 +0100 Hi Martin, Thanks for your help, i have de fined the hibernate template like this like this: bean id=hibernateTemplate class=org.springframework.orm.hibernate3.HibernateTemplate property name=sessionFactoryref bean=sessionFactory //property /bean And then use it in the DAO: I couldn’t change this line by adding the parameter cause it shows an error so kept it like this: public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); } Now when running I get this error: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'messageSource' of bean class [action.LoginAction]: Bean property 'messageSource' is not writable or has an invalid setter method. Does
Re: Hibernate3+Spring2.5+Struts2
On Thu, Aug 20, 2009 at 5:27 PM, Martin Gaintymgai...@hotmail.com wrote: agreed..i would also suggest wrap the code in try catch for the NullPointerException good call wes! Martin Gainty Why? Nils-H - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Hibernate3+Spring2.5+Struts2
Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. avoid static references such as userService.getUser(username); better to getUserService().getUser(username); done. Here is my code now private UserServiceImp userServiceImp; User usr= getUserServiceImp().getUser(username); Still the same exception. Do I need to add setter and getters for both userService and UserServiceImp? Sorry guys but I am lost in this code so I have declared both of userService and userServiceImp with getters and setters and tried all the possibilities but still same exception: LoginAction: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ 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 UserService userService; private UserServiceImp userServiceImp; private String message; private String username; private String password; private ResourceBundleMessageSource messageSource; public LoginAction() { } @Override public String execute() throws Exception { User usr= getUserServiceImp().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 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; } public ResourceBundleMessageSource getMessageSource() { return messageSource; } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } public UserServiceImp getUserServiceImp() { return userServiceImp; } public void setUserServiceImp(UserServiceImp userServiceImp) { this.userServiceImp = userServiceImp; } } UserDaoImpl: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package dao; import po.*; import dao.UserDao; import java.util.List; 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); } } -Original Message- From: Martin Gainty [mailto:mgai...@hotmail.com] Sent: 20 August 2009 16:14 To: Struts Users Mailing List Subject: RE: Hibernate3+Spring2.5+Struts2 cannot do a get(0) on a null result public User getUser(String userName) { return (User)getHibernateTemplate().find(from User as u where u.name = ?, userName).get(0); }public interface UserService cannot be referenced directly so best to use your impl class change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); traditionally implementation classes are named ClassNameImpl instead of ClassNameImp avoid static references such as userService.getUser(username); better to getUserService().getUser(username); //which means the *Action will need accessor method getUserService defined e.g. public UserServiceImp getUserService() { return userService; } Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese
Re: Hibernate3+Spring2.5+Struts2
On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for the help guys. change User usr= userService.getUser(username); to User usr=userServiceImp.getUser(username); userService is a UserServiceImp instance-- UserServiceimp userService. You were on the right track before, you just want the following in your class - -snippet private UserService userService; public void setUserService(UserService userService) { this.userService = userService; } - end snippet I am curious if it's 'userService' that is null... This would mean that your action isn't being wired with the service from Spring. I snipped all the previous messages from this email, so i can't look through it for you, but I will say that this sort of thing is generally a simple property misspelling or some other detail (decimal point? I always mess up some mundane detail). If it's username that is null, you might want to check that your form is properly setup in your JSP. -Wes -- 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
Re: Hibernate3+Spring2.5+Struts2
From your stack trace: SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User I'm guessing that might have something to do with it. Nils-H On Wed, Aug 19, 2009 at 12:40 PM, ZiedBejaouibejaouiz...@hotmail.com wrote: Hi, I am trying to run an example to integrate struts2 with hibernate and Spring. When running the example tomcat display en error: 404 resource is not available. This is my stack trace: 19-Aug-2009 11:29:06 org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart 19-Aug-2009 11:29:06 org.apache.catalina.core.StandardContext start SEVERE: Context [/WebApplication4] startup failed due to previous errors 19-Aug-2009 11:30:00 org.apache.catalina.core.StandardContext stop INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/WebApplication4] has not been started 19-Aug-2009 11:30:00 org.apache.catalina.core.StandardContext addApplicationListener INFO: The listener org.springframework.web.context.ContextLoaderListener is already configured for this context. The duplicate definition has been ignored. 19-Aug-2009 11:30:00 org.springframework.web.context.ContextLoader initWebApplicationContext INFO: Root WebApplicationContext: initialization started 19-Aug-2009 11:30:00 org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.xmlwebapplicationcont...@1cfad77: display name [Root WebApplicationContext]; startup date [Wed Aug 19 11:30:00 BST 2009]; root of context hierarchy 19-Aug-2009 11:30:01 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] 19-Aug-2009 11:30:01 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.xmlwebapplicationcont...@1cfad77]: org.springframework.beans.factory.support.defaultlistablebeanfact...@1ed2061 19-Aug-2009 11:30:01 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfact...@1ed2061: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy 19-Aug-2009 11:30:01 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName INFO: Loaded JDBC driver: com.mysql.jdbc.Driver 19-Aug-2009 11:30:01 org.hibernate.cfg.Environment clinit INFO: Hibernate 3.2.5 19-Aug-2009 11:30:01 org.hibernate.cfg.Environment clinit INFO: hibernate.properties not found 19-Aug-2009 11:30:01 org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : cglib 19-Aug-2009 11:30:01 org.hibernate.cfg.Environment clinit INFO: using JDK 1.4 java.sql.Timestamp handling 19-Aug-2009 11:30:01 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: po.User - user 19-Aug-2009 11:30:01 org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory INFO: Building new Hibernate SessionFactory 19-Aug-2009 11:30:01 org.hibernate.connection.ConnectionProviderFactory newConnectionProvider INFO: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings INFO: RDBMS: MySQL, version: 5.4.1-beta-community 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.8 ( Revision: ${svn.Revision} ) 19-Aug-2009 11:30:02 org.hibernate.dialect.Dialect init INFO: Using dialect: org.hibernate.dialect.MySQLDialect 19-Aug-2009 11:30:02 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory INFO: Using default transaction strategy (direct JDBC transactions) 19-Aug-2009 11:30:02 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic flush during beforeCompletion(): disabled 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic session close at end of transaction: disabled 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory
RE: Hibernate3+Spring2.5+Struts2
Thanks for you reply, In my table I have three coloumns ID, UserName and password. This is my po.User: package service; import po.User; /** * * @author ABIS1 */ public class UserServiceImp implements UserService { private dao.UserDao userDao; public void addUser(String userName, String password, int admin) 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); } } And this is my applicationcontext.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 valuepo/user.hbm.xml/value /list /property property name=hibernateProperties valuehibernate.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 -Original Message- From: Nils-Helge Garli Hegvik [mailto:nil...@gmail.com] Sent: 19 August 2009 11:48 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 From your stack trace: SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User I'm guessing that might have something to do with it. Nils-H On Wed, Aug 19, 2009 at 12:40 PM, ZiedBejaouibejaouiz...@hotmail.com wrote: Hi, I am trying to run an example to integrate struts2 with hibernate and Spring. When running the example tomcat display en error: 404 resource is not available. This is my stack trace: 19-Aug-2009 11:29:06 org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart 19-Aug-2009 11:29:06 org.apache.catalina.core.StandardContext start SEVERE: Context [/WebApplication4] startup failed due to previous errors 19-Aug-2009 11:30:00 org.apache.catalina.core.StandardContext stop INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/WebApplicati on4] has not been started 19-Aug-2009 11:30:00 org.apache.catalina.core.StandardContext addApplicationListener INFO: The listener org.springframework.web.context.ContextLoaderListener is already configured for this context. The duplicate definition has been ignored. 19-Aug-2009 11:30:00 org.springframework.web.context.ContextLoader initWebApplicationContext INFO: Root WebApplicationContext: initialization started 19-Aug-2009 11:30:00 org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.xmlwebapplicationcont...@1cfad77: display name [Root WebApplicationContext]; startup date [Wed Aug 19 11:30:00 BST 2009]; root of context hierarchy 19-Aug-2009 11:30:01 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] 19-Aug-2009 11:30:01 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.xmlwebapplicationcont
Re: Hibernate3+Spring2.5+Struts2
Hi, That the source of your problems: Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User Check mapping files, you are trying to map admin property which doesn't exist in User class. Regards -- Lukasz http://www.lenart.org.pl/ http://dailylog.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Hibernate3+Spring2.5+Struts2
(DefaultActionInvocation.java:221) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) Here is my login Action: * @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.CHINA); }else{ message = messageSource.getMessage(pswError, null,Locale.CHINA); } }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; } } This is the userServiceImpl: package service; import po.User; /** * * @author ABIS1 */ public class UserServiceImp implements UserService { private dao.UserDao userDao; public void addUser(String userName, String password, int admin) throws Exception{ po.User user = new User(); user.setId(12); // user.setId(admin); 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); } } -Original Message- From: Lukasz Lenart [mailto:lukasz.len...@googlemail.com] Sent: 19 August 2009 12:11 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 Hi, That the source of your problems: Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User Check mapping files, you
Re: Hibernate3+Spring2.5+Struts2
) { return this.userDao.getUser(userName); } } -Original Message- From: Lukasz Lenart [mailto:lukasz.len...@googlemail.com] Sent: 19 August 2009 12:11 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 Hi, That the source of your problems: Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User Check mapping files, you are trying to map admin property which doesn't exist in User class. Regards -- Lukasz http://www.lenart.org.pl/ http://dailylog.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Hibernate3+Spring2.5+Struts2
Well the problem is that this is my first example with spring and hibernate I have downloaded the example which should create a login application, now as I said the table have an id a user name and a password. Here is the line of the exception: User usr = userService.getUser(username); Here is the user service interface and class: package service; import dao.UserDaoImpl; import po.User; /** * * @author ABIS1 */ public interface UserService { void addUser(String userName, String password, int admin) throws Exception; User getUser(long userId); User getUser(String userName); void setUserDao(UserDaoImpl userDao); } - package service; import po.User; /** * * @author ABIS1 */ public class UserServiceImp implements UserService { private dao.UserDao userDao; public void addUser(String userName, String password, int admin) 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); } } --- And the user dao interface and implementation: package dao; import po.User; /** * * @author ABIS1 */ public interface UserDao { void save(User user) throws Exception; User getUser(long userId); User getUser(String userName); } - /* * 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); } } -Original Message- From: Nils-Helge Garli Hegvik [mailto:nil...@gmail.com] Sent: 19 August 2009 13:05 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) Looks like you have a NPE at line 31 in LoginAction. What line is that? Which references could have been null? Nils-H On Wed, Aug 19, 2009 at 1:59 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for your help, I have fixed this problem by removing the admin property from the mapping file, now I am having another error, the login page display then as soon as I enter the login details I receive this exception: java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionIn vocation.java:404) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActi onInvocation.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocati on.java:229) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(D efaultWorkflowInterceptor.java:221) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Method FilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionI nvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionI nvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack .java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocati on.java:221) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(Validati onInterceptor.java:150) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.do Intercept(AnnotationValidationInterceptor.java:48) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Method
Re: Hibernate3+Spring2.5+Struts2
Is there a user service injected into your action? If so, does the service return a user? (Are you typing your program in via SMS? It seems like everything is named reasonable except for usr :( It's really difficult for us to help when we don't know the line that's causing the error: *you* know that, and should either tell us, or provide a means for us to figure it out. The more relevant information you can provide the easier it is for us to help :) Dave Zied Bejaoui wrote: Well the problem is that this is my first example with spring and hibernate I have downloaded the example which should create a login application, now as I said the table have an id a user name and a password. Here is the line of the exception: User usr = userService.getUser(username); Here is the user service interface and class: package service; import dao.UserDaoImpl; import po.User; /** * * @author ABIS1 */ public interface UserService { void addUser(String userName, String password, int admin) throws Exception; User getUser(long userId); User getUser(String userName); void setUserDao(UserDaoImpl userDao); } - package service; import po.User; /** * * @author ABIS1 */ public class UserServiceImp implements UserService { private dao.UserDao userDao; public void addUser(String userName, String password, int admin) 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); } } --- And the user dao interface and implementation: package dao; import po.User; /** * * @author ABIS1 */ public interface UserDao { void save(User user) throws Exception; User getUser(long userId); User getUser(String userName); } - /* * 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); } } -Original Message- From: Nils-Helge Garli Hegvik [mailto:nil...@gmail.com] Sent: 19 August 2009 13:05 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) Looks like you have a NPE at line 31 in LoginAction. What line is that? Which references could have been null? Nils-H On Wed, Aug 19, 2009 at 1:59 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for your help, I have fixed this problem by removing the admin property from the mapping file, now I am having another error, the login page display then as soon as I enter the login details I receive this exception: java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionIn vocation.java:404) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActi onInvocation.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocati on.java:229) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(D efaultWorkflowInterceptor.java:221) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Method FilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionI nvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionI nvocation.java:223) at com.opensymphony.xwork2
RE: Hibernate3+Spring2.5+Struts2
Thanks for your reply, well this is the link to the code I am trying to run it is in two parts in the same blog that will be easier for you to locate the problem. http://blogs.sun.com/LiYuanxin/entry/integrating_struts2_0_spring2_5 The problem is in this line in my LoginAction : User usr = userService.getUser(username); I am sorry if I am not clear but it's because I didn't get the code. -Original Message- From: Dave Newton [mailto:newton.d...@yahoo.com] Sent: 19 August 2009 15:18 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 Is there a user service injected into your action? If so, does the service return a user? (Are you typing your program in via SMS? It seems like everything is named reasonable except for usr :( It's really difficult for us to help when we don't know the line that's causing the error: *you* know that, and should either tell us, or provide a means for us to figure it out. The more relevant information you can provide the easier it is for us to help :) Dave Zied Bejaoui wrote: Well the problem is that this is my first example with spring and hibernate I have downloaded the example which should create a login application, now as I said the table have an id a user name and a password. Here is the line of the exception: User usr = userService.getUser(username); Here is the user service interface and class: package service; import dao.UserDaoImpl; import po.User; /** * * @author ABIS1 */ public interface UserService { void addUser(String userName, String password, int admin) throws Exception; User getUser(long userId); User getUser(String userName); void setUserDao(UserDaoImpl userDao); } - package service; import po.User; /** * * @author ABIS1 */ public class UserServiceImp implements UserService { private dao.UserDao userDao; public void addUser(String userName, String password, int admin) 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); } } --- And the user dao interface and implementation: package dao; import po.User; /** * * @author ABIS1 */ public interface UserDao { void save(User user) throws Exception; User getUser(long userId); User getUser(String userName); } - /* * 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); } } -Original Message- From: Nils-Helge Garli Hegvik [mailto:nil...@gmail.com] Sent: 19 August 2009 13:05 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) Looks like you have a NPE at line 31 in LoginAction. What line is that? Which references could have been null? Nils-H On Wed, Aug 19, 2009 at 1:59 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for your help, I have fixed this problem by removing the admin property from the mapping file, now I am having another error, the login page display then as soon as I enter the login details I receive this exception: java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionIn
Re: Hibernate3+Spring2.5+Struts2
Zied Bejaoui wrote: The problem is in this line in my LoginAction : User usr = userService.getUser(username); Then I'd assume the userService is null. I am sorry if I am not clear but it's because I didn't get the code. This doesn't really seem to be a Struts issue, but Spring. It's difficult to jump right in to using three brand new technologies--you might be better served by not trying to do so much at once and develop an understanding of each technology at a time, or by building up an application by hand so you understand how the different pieces fit together. Just a thought. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
thanks dave for you help, I know hoe to use struts and since I need a database app i need hibernate can i just use theses technologies without spring? -- From: Dave Newton newton.d...@yahoo.com Sent: Wednesday, August 19, 2009 4:18 PM To: Struts Users Mailing List user@struts.apache.org Subject: Re: Hibernate3+Spring2.5+Struts2 Zied Bejaoui wrote: The problem is in this line in my LoginAction : User usr = userService.getUser(username); Then I'd assume the userService is null. I am sorry if I am not clear but it's because I didn't get the code. This doesn't really seem to be a Struts issue, but Spring. It's difficult to jump right in to using three brand new technologies--you might be better served by not trying to do so much at once and develop an understanding of each technology at a time, or by building up an application by hand so you understand how the different pieces fit together. Just a thought. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Hibernate3+Spring2.5+Struts2
Yes is the part of my context file: /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 I have tried to figure out the problem for hours no luck... -Original Message- From: Dave Newton [mailto:newton.d...@yahoo.com] Sent: 19 August 2009 15:18 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 Is there a user service injected into your action? If so, does the service return a user? (Are you typing your program in via SMS? It seems like everything is named reasonable except for usr :( It's really difficult for us to help when we don't know the line that's causing the error: *you* know that, and should either tell us, or provide a means for us to figure it out. The more relevant information you can provide the easier it is for us to help :) Dave Zied Bejaoui wrote: Well the problem is that this is my first example with spring and hibernate I have downloaded the example which should create a login application, now as I said the table have an id a user name and a password. Here is the line of the exception: User usr = userService.getUser(username); Here is the user service interface and class: package service; import dao.UserDaoImpl; import po.User; /** * * @author ABIS1 */ public interface UserService { void addUser(String userName, String password, int admin) throws Exception; User getUser(long userId); User getUser(String userName); void setUserDao(UserDaoImpl userDao); } - package service; import po.User; /** * * @author ABIS1 */ public class UserServiceImp implements UserService { private dao.UserDao userDao; public void addUser(String userName, String password, int admin) 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); } } --- And the user dao interface and implementation: package dao; import po.User; /** * * @author ABIS1 */ public interface UserDao { void save(User user) throws Exception; User getUser(long userId); User getUser(String userName); } - /* * 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); } } -Original Message- From: Nils-Helge Garli Hegvik [mailto:nil...@gmail.com] Sent: 19 August 2009 13:05 To: Struts Users Mailing List Subject: Re: Hibernate3+Spring2.5+Struts2 java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) Looks like you have a NPE at line 31 in LoginAction. What line is that? Which references could have been null? Nils-H On Wed, Aug 19, 2009 at 1:59 PM, Zied Bejaouibejaouiz...@hotmail.com wrote: Thanks for your help, I have fixed this problem by removing the admin property from the mapping file, now I am having another error, the login page display then as soon as I enter the login details I receive this exception: java.lang.NullPointerException at action.LoginAction.execute(LoginAction.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
Re: Hibernate3+Spring2.5+Struts2
- Original Message From: Dave Newton newton.d...@yahoo.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, August 19, 2009 7:18:09 AM Subject: Re: Hibernate3+Spring2.5+Struts2 snip 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.CHINA); }else{ message = messageSource.getMessage(pswError, null,Locale.CHINA); } }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; } } snip Your UserServiceImp userService was instantiated but never initialized in your LoginAction class. Hence the NPE. When you to execute a method that does not a reference to real object, you'll get NPE. You might want to review your java :) Best regards, Tommy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
Thanks for your reply however I didn't get you point, I have created a userserviceImp instance in my loginaction. could you please tell what you mean? -- From: Tommy Pham tommy...@yahoo.com Sent: Wednesday, August 19, 2009 4:59 PM To: Struts Users Mailing List user@struts.apache.org Subject: Re: Hibernate3+Spring2.5+Struts2 - Original Message From: Dave Newton newton.d...@yahoo.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, August 19, 2009 7:18:09 AM Subject: Re: Hibernate3+Spring2.5+Struts2 snip 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.CHINA); }else{ message = messageSource.getMessage(pswError, null,Locale.CHINA); } }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; } } snip Your UserServiceImp userService was instantiated but never initialized in your LoginAction class. Hence the NPE. When you to execute a method that does not a reference to real object, you'll get NPE. You might want to review your java :) Best regards, Tommy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
- Original Message From: ZiedBejaoui bejaouiz...@hotmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, August 19, 2009 9:23:35 AM Subject: Re: Hibernate3+Spring2.5+Struts2 Thanks for your reply however I didn't get you point, I have created a userserviceImp instance in my loginaction. could you please tell what you mean? 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.CHINA); }else{ message = messageSource.getMessage(pswError, null,Locale.CHINA); } }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; } } Your UserServiceImp userService was instantiated but never initialized in your LoginAction class. Hence the NPE. When you to execute a method that does not a reference to real object, you'll get NPE. You might want to review your java :) Best regards, Tommy In many programming languages, all variables (fields) have to be initialized before use with exception of primitive types (byte, short, etc - NOTE: String is null by default- they will have a default value). Your custom class UserServiceImp was instantiated with userService but never initialized. So when you try to do userService.getUser() in the execute() method of your LoginAction, you'll get the NPE as seen. I suggest you spend some time and go through this http://java.sun.com/docs/books/tutorial/ . Your current problem is covered here: http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html Best regards, Tommy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
ZiedBejaoui wrote: thanks dave for you help, I know hoe to use struts and since I need a database app i need hibernate can i just use theses technologies without spring? You *can*, but I'm not sure you *should*... it's just so much easier with Spring. I also always tell people that there *are* other options than Hibernate, even though it's obviously a very popular choice. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Hibernate3+Spring2.5+Struts2
review your java speaking of which did the op display the source for ResourceBundleMessageSource.java? Martin Date: Wed, 19 Aug 2009 09:34:48 -0700 From: tommy...@yahoo.com Subject: Re: Hibernate3+Spring2.5+Struts2 To: user@struts.apache.org - Original Message From: ZiedBejaoui bejaouiz...@hotmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, August 19, 2009 9:23:35 AM Subject: Re: Hibernate3+Spring2.5+Struts2 Thanks for your reply however I didn't get you point, I have created a userserviceImp instance in my loginaction. could you please tell what you mean? 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.CHINA); }else{ message = messageSource.getMessage(pswError, null,Locale.CHINA); } }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; } } Your UserServiceImp userService was instantiated but never initialized in your LoginAction class. Hence the NPE. When you to execute a method that does not a reference to real object, you'll get NPE. You might want to review your java :) Best regards, Tommy In many programming languages, all variables (fields) have to be initialized before use with exception of primitive types (byte, short, etc - NOTE: String is null by default- they will have a default value). Your custom class UserServiceImp was instantiated with userService but never initialized. So when you try to do userService.getUser() in the execute() method of your LoginAction, you'll get the NPE as seen. I suggest you spend some time and go through this http://java.sun.com/docs/books/tutorial/ . Your current problem is covered here: http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html Best regards, Tommy - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows Live: Keep your friends up to date with what you do online. http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009
Re: Hibernate3+Spring2.5+Struts2
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? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Hibernate3+Spring2.5+Struts2
On Wed, Aug 19, 2009 at 1:07 PM, Dave Newtonnewton.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 Gaintymgai...@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
RE: Hibernate3+Spring2.5+Struts2
I do have spring installed and it's configured I wil post the code tomorrow. Thanks. ZIED BEJAOUI Tel: 0044(0)7506628905 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 Newtonnewton.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 Gaintymgai...@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 _ Partagez vos souvenirs sur le Web avec les personnes de votre choix. http://www.microsoft.com/northafrica/windows/windowslive/products/photos-share.aspx?tab=1
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 Newtonnewton.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 Gaintymgai...@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=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1