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 Bejaoui<bejaouiz...@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
> 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.interceptor.ConversionErrorInterceptor.intercept(Con
> versionErrorInterceptor.java:123)
>>        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.interceptor.ParametersInterceptor.doIntercept(Parame
> tersInterceptor.java:167)
>>        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.interceptor.StaticParametersInterceptor.intercept(St
> aticParametersInterceptor.java:105)
>>        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
>
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterce
> ptor.java:83)
>>        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
>
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInt
> erceptor.java:207)
>>        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.interceptor.ModelDrivenInterceptor.intercept(ModelDr
> ivenInterceptor.java:74)
>>        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.interceptor.ScopedModelDrivenInterceptor.intercept(S
> copedModelDrivenInterceptor.java:127)
>>        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
>
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(Prof
> ilingActivationInterceptor.java:107)
>>        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
>
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(Debu
> ggingInterceptor.java:206)
>>        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.interceptor.ChainingInterceptor.intercept(ChainingIn
> terceptor.java:115)
>>        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.interceptor.I18nInterceptor.intercept(I18nIntercepto
> r.java:143)
>>        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.interceptor.PrepareInterceptor.doIntercept(PrepareIn
> terceptor.java:121)
>>        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
>
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletCon
> figInterceptor.java:170)
>>        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.interceptor.AliasInterceptor.intercept(AliasIntercep
> tor.java:123)
>>        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.interceptor.ExceptionMappingInterceptor.intercept(Ex
> ceptionMappingInterceptor.java:176)
>>        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
>
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.jav
> a:419)
>>        at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:235)
>>        at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:206)
>>        at
>
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
> .java:390)
>>        at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:235)
>>        at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:206)
>>        at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:233)
>>        at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va: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(Http
> 11Protocol.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 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
> 
> 
> 
> ---------------------------------------------------------------------
> 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

Reply via email to