You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ZiedBejaoui <be...@hotmail.com> on 2009/08/19 12:40:50 UTC

Hibernate3+Spring2.5+Struts2

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.XmlWebApplicationContext@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.XmlWebApplicationContext@1cfad77]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1ed2061

19-Aug-2009 11:30:01 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@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 buildSettings

INFO: JDBC batch size: 15

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JDBC batch updates for versioned data: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Scrollable result sets: enabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JDBC3 getGeneratedKeys(): enabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Connection release mode: on_close

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Maximum outer join fetch depth: 2

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Default batch fetch size: 1

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Generate SQL with comments: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Order SQL updates by primary key: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Order SQL inserts for batching: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory

INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory

19-Aug-2009 11:30:02 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>

INFO: Using ASTQueryTranslatorFactory

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Query language substitutions: {}

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JPA-QL strict compliance: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Second-level cache: enabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Query cache: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory createCacheProvider

INFO: Cache provider: org.hibernate.cache.NoCacheProvider

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Optimize cache for minimal puts: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Structured second-level cache entries: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Statistics: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Deleted entity synthetic identifier rollback: disabled

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Default entity-mode: pojo

19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Named query checking : enabled

19-Aug-2009 11:30:03 org.hibernate.impl.SessionFactoryImpl <init>

INFO: building session factory

19-Aug-2009 11:30:03 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons

INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1ed2061: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy

19-Aug-2009 11:30:03 org.springframework.web.context.ContextLoader initWebApplicationContext

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

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)

        at java.security.AccessController.doPrivileged(Native Method)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)

        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)

        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)

        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)

        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)

        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)

        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)

        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)

        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)

        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)

        at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1244)

        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:374)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)

        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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)

        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)

Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User

        at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)

        at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)

        at org.hibernate.mapping.Property.getGetter(Property.java:272)

        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)

        at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)

        at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)

        at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)

        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)

        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)

        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)

        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)

        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)

        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)

        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)

        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)

        ... 36 more

19-Aug-2009 11:30:03 org.apache.catalina.core.StandardContext start

SEVERE: Error listenerStart

19-Aug-2009 11:30:03 org.apache.catalina.core.StandardContext start

SEVERE: Context [/WebApplication4] startup failed due to previous errors

19-Aug-2009 11:30:17 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:17 org.apache.catalina.startup.HostConfig checkResources

INFO: Undeploying context [/WebApplication4]

19-Aug-2009 11:30:17 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:18 org.springframework.web.context.ContextLoader initWebApplicationContext

INFO: Root WebApplicationContext: initialization started

19-Aug-2009 11:30:18 org.springframework.context.support.AbstractApplicationContext prepareRefresh

INFO: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@7db754: display name [Root WebApplicationContext]; startup date [Wed Aug 19 11:30:18 BST 2009]; root of context hierarchy

19-Aug-2009 11:30:18 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]

19-Aug-2009 11:30:18 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory

INFO: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@7db754]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e

19-Aug-2009 11:30:18 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy

19-Aug-2009 11:30:18 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName

INFO: Loaded JDBC driver: com.mysql.jdbc.Driver

19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>

INFO: Hibernate 3.2.5

19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>

INFO: hibernate.properties not found

19-Aug-2009 11:30:18 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: Bytecode provider name : cglib

19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>

INFO: using JDK 1.4 java.sql.Timestamp handling

19-Aug-2009 11:30:19 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues

INFO: Mapping class: po.User -> user

19-Aug-2009 11:30:19 org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory

INFO: Building new Hibernate SessionFactory

19-Aug-2009 11:30:19 org.hibernate.connection.ConnectionProviderFactory newConnectionProvider

INFO: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider

19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings

INFO: RDBMS: MySQL, version: 5.4.1-beta-community

19-Aug-2009 11:30:19 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:19 org.hibernate.dialect.Dialect <init>

INFO: Using dialect: org.hibernate.dialect.MySQLDialect

19-Aug-2009 11:30:19 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory

INFO: Using default transaction strategy (direct JDBC transactions)

19-Aug-2009 11:30:19 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:19 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Automatic flush during beforeCompletion(): disabled

19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Automatic session close at end of transaction: disabled

19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JDBC batch size: 15

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JDBC batch updates for versioned data: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Scrollable result sets: enabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JDBC3 getGeneratedKeys(): enabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Connection release mode: on_close

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Maximum outer join fetch depth: 2

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Default batch fetch size: 1

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Generate SQL with comments: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Order SQL updates by primary key: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Order SQL inserts for batching: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory

INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory

19-Aug-2009 11:30:20 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>

INFO: Using ASTQueryTranslatorFactory

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Query language substitutions: {}

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JPA-QL strict compliance: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Second-level cache: enabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Query cache: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory createCacheProvider

INFO: Cache provider: org.hibernate.cache.NoCacheProvider

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Optimize cache for minimal puts: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Structured second-level cache entries: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Statistics: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Deleted entity synthetic identifier rollback: disabled

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Default entity-mode: pojo

19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Named query checking : enabled

19-Aug-2009 11:30:20 org.hibernate.impl.SessionFactoryImpl <init>

INFO: building session factory

19-Aug-2009 11:30:20 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons

INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy

19-Aug-2009 11:30:20 org.springframework.web.context.ContextLoader initWebApplicationContext

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

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)

        at java.security.AccessController.doPrivileged(Native Method)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)

        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)

        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)

        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)

        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)

        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)

        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)

        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)

        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)

        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)

        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)

        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)

        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)

        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:511)

        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1229)

        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 org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)

        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)

        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)

        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1465)

        at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:821)

        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:349)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)

        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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)

        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)

Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User

        at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)

        at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)

        at org.hibernate.mapping.Property.getGetter(Property.java:272)

        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)

        at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)

        at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)

        at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)

        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)

        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)

        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)

        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)

        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)

        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)

        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)

        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)

        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)

        ... 50 more

19-Aug-2009 11:30:20 org.apache.catalina.core.StandardContext start

SEVERE: Error listenerStart

19-Aug-2009 11:30:20 org.apache.catalina.core.StandardContext start

SEVERE: Context [/WebApplication4] startup failed due to previous errors




RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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>
                <value>po/user.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
 
<value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
        </property>
    </bean>
    <bean id="userDao" class="dao.UserDaoImpl">
        <property name="sessionFactory">
            <ref bean="sessionFactory"></ref>
        </property>
    </bean> 
    <bean id="userService" class="service.UserServiceImp">
        <property name="userDao">
            <ref bean="userDao"></ref>
        </property>
    </bean>
    <bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource"> 
        <property name="basename" value="messages" /> 
    </bean>

    <bean id="loginAction" class="action.LoginAction">
        <property name="userService">
            <ref bean="userService"></ref>
        </property>
        <property name="messageSource" ref="messageSource"/>
    </bean>
</beans>

-----Original Message-----
From: Nils-Helge Garli Hegvik [mailto:nilsga@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, ZiedBejaoui<be...@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.XmlWebApplicationContext@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.XmlWebApplicationContext@1cfad77]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@1ed2061
>
> 19-Aug-2009 11:30:01
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
>
> INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@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 buildSettings
>
> INFO: JDBC batch size: 15
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC batch updates for versioned data: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Scrollable result sets: enabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC3 getGeneratedKeys(): enabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Connection release mode: on_close
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Maximum outer join fetch depth: 2
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default batch fetch size: 1
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Generate SQL with comments: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL updates by primary key: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL inserts for batching: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory
createQueryTranslatorFactory
>
> INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:02 org.hibernate.hql.ast.ASTQueryTranslatorFactory
<init>
>
> INFO: Using ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query language substitutions: {}
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JPA-QL strict compliance: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Second-level cache: enabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query cache: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory createCacheProvider
>
> INFO: Cache provider: org.hibernate.cache.NoCacheProvider
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Optimize cache for minimal puts: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Structured second-level cache entries: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Statistics: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Deleted entity synthetic identifier rollback: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default entity-mode: pojo
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Named query checking : enabled
>
> 19-Aug-2009 11:30:03 org.hibernate.impl.SessionFactoryImpl <init>
>
> INFO: building session factory
>
> 19-Aug-2009 11:30:03
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
destroySingletons
>
> INFO: Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1ed2061
: defining beans
[dataSource,sessionFactory,userDao,userService,messageSource,loginAction];
root of factory hierarchy
>
> 19-Aug-2009 11:30:03 org.springframework.web.context.ContextLoader
initWebApplicationContext
>
> 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
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
$1.run(AbstractAutowireCapableBeanFactory.java:485)
>
>        at java.security.AccessController.doPrivileged(Native Method)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.createBean(AbstractAutowireCapableBeanFactory.java:455)
>
>        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Ab
stractBeanFactory.java:251)
>
>        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi
ngleton(DefaultSingletonBeanRegistry.java:169)
>
>        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:248)
>
>        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:170)
>
>        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst
antiateSingletons(DefaultListableBeanFactory.java:407)
>
>        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFac
toryInitialization(AbstractApplicationContext.java:735)
>
>        at
org.springframework.context.support.AbstractApplicationContext.refresh(Abstr
actApplicationContext.java:369)
>
>        at
org.springframework.web.context.ContextLoader.createWebApplicationContext(Co
ntextLoader.java:251)
>
>        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(Cont
extLoader.java:190)
>
>        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(Con
textLoaderListener.java:45)
>
>        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3843)
>
>        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
>
>        at
org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1244)
>
>        at
org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:374)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)
>
>        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
>
>        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
.java:196)
>
>        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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:525)
>
>        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)
>
> Caused by: org.hibernate.PropertyNotFoundException: Could not find a
getter for admin in class po.User
>
>        at
org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAcces
sor.java:282)
>
>        at
org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor
.java:275)
>
>        at org.hibernate.mapping.Property.getGetter(Property.java:272)
>
>        at
org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntity
Tuplizer.java:247)
>
>        at
org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTupli
zer.java:125)
>
>        at
org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java
:55)
>
>        at
org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEn
tityModeToTuplizerMapping.java:56)
>
>        at
org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
>
>        at
org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntity
Persister.java:434)
>
>        at
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTable
EntityPersister.java:109)
>
>        at
org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFacto
ry.java:55)
>
>        at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
>
>        at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
>
>        at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory
(LocalSessionFactoryBean.java:753)
>
>        at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFacto
ry(LocalSessionFactoryBean.java:691)
>
>        at
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertie
sSet(AbstractSessionFactoryBean.java:211)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
>
>        ... 36 more
>
> 19-Aug-2009 11:30:03 org.apache.catalina.core.StandardContext start
>
> SEVERE: Error listenerStart
>
> 19-Aug-2009 11:30:03 org.apache.catalina.core.StandardContext start
>
> SEVERE: Context [/WebApplication4] startup failed due to previous errors
>
> 19-Aug-2009 11:30:17 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:17 org.apache.catalina.startup.HostConfig checkResources
>
> INFO: Undeploying context [/WebApplication4]
>
> 19-Aug-2009 11:30:17 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:18 org.springframework.web.context.ContextLoader
initWebApplicationContext
>
> INFO: Root WebApplicationContext: initialization started
>
> 19-Aug-2009 11:30:18
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
>
> INFO: Refreshing
org.springframework.web.context.support.XmlWebApplicationContext@7db754:
display name [Root WebApplicationContext]; startup date [Wed Aug 19 11:30:18
BST 2009]; root of context hierarchy
>
> 19-Aug-2009 11:30:18
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
>
> INFO: Loading XML bean definitions from ServletContext resource
[/WEB-INF/applicationContext.xml]
>
> 19-Aug-2009 11:30:18
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
>
> INFO: Bean factory for application context
[org.springframework.web.context.support.XmlWebApplicationContext@7db754]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e
>
> 19-Aug-2009 11:30:18
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
>
> INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e
: defining beans
[dataSource,sessionFactory,userDao,userService,messageSource,loginAction];
root of factory hierarchy
>
> 19-Aug-2009 11:30:18
org.springframework.jdbc.datasource.DriverManagerDataSource
setDriverClassName
>
> INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>
>
> INFO: Hibernate 3.2.5
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>
>
> INFO: hibernate.properties not found
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment buildBytecodeProvider
>
> INFO: Bytecode provider name : cglib
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>
>
> INFO: using JDK 1.4 java.sql.Timestamp handling
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.HbmBinder
bindRootPersistentClassCommonValues
>
> INFO: Mapping class: po.User -> user
>
> 19-Aug-2009 11:30:19
org.springframework.orm.hibernate3.LocalSessionFactoryBean
buildSessionFactory
>
> INFO: Building new Hibernate SessionFactory
>
> 19-Aug-2009 11:30:19 org.hibernate.connection.ConnectionProviderFactory
newConnectionProvider
>
> INFO: Initializing connection provider:
org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: RDBMS: MySQL, version: 5.4.1-beta-community
>
> 19-Aug-2009 11:30:19 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:19 org.hibernate.dialect.Dialect <init>
>
> INFO: Using dialect: org.hibernate.dialect.MySQLDialect
>
> 19-Aug-2009 11:30:19 org.hibernate.transaction.TransactionFactoryFactory
buildTransactionFactory
>
> INFO: Using default transaction strategy (direct JDBC transactions)
>
> 19-Aug-2009 11:30:19
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:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Automatic flush during beforeCompletion(): disabled
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Automatic session close at end of transaction: disabled
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC batch size: 15
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC batch updates for versioned data: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Scrollable result sets: enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC3 getGeneratedKeys(): enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Connection release mode: on_close
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Maximum outer join fetch depth: 2
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default batch fetch size: 1
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Generate SQL with comments: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL updates by primary key: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL inserts for batching: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory
createQueryTranslatorFactory
>
> INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:20 org.hibernate.hql.ast.ASTQueryTranslatorFactory
<init>
>
> INFO: Using ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query language substitutions: {}
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JPA-QL strict compliance: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Second-level cache: enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query cache: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory createCacheProvider
>
> INFO: Cache provider: org.hibernate.cache.NoCacheProvider
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Optimize cache for minimal puts: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Structured second-level cache entries: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Statistics: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Deleted entity synthetic identifier rollback: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default entity-mode: pojo
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Named query checking : enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.impl.SessionFactoryImpl <init>
>
> INFO: building session factory
>
> 19-Aug-2009 11:30:20
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
destroySingletons
>
> INFO: Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e
: defining beans
[dataSource,sessionFactory,userDao,userService,messageSource,loginAction];
root of factory hierarchy
>
> 19-Aug-2009 11:30:20 org.springframework.web.context.ContextLoader
initWebApplicationContext
>
> 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
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
$1.run(AbstractAutowireCapableBeanFactory.java:485)
>
>        at java.security.AccessController.doPrivileged(Native Method)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.createBean(AbstractAutowireCapableBeanFactory.java:455)
>
>        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Ab
stractBeanFactory.java:251)
>
>        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi
ngleton(DefaultSingletonBeanRegistry.java:169)
>
>        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:248)
>
>        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:170)
>
>        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst
antiateSingletons(DefaultListableBeanFactory.java:407)
>
>        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFac
toryInitialization(AbstractApplicationContext.java:735)
>
>        at
org.springframework.context.support.AbstractApplicationContext.refresh(Abstr
actApplicationContext.java:369)
>
>        at
org.springframework.web.context.ContextLoader.createWebApplicationContext(Co
ntextLoader.java:251)
>
>        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(Cont
extLoader.java:190)
>
>        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(Con
textLoaderListener.java:45)
>
>        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3843)
>
>        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
>
>        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:7
91)
>
>        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
>
>        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
>
>        at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
>
>        at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:511)
>
>        at
org.apache.catalina.startup.HostConfig.check(HostConfig.java:1229)
>
>        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
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297
)
>
>        at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanSer
verInterceptor.java:836)
>
>        at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
>
>        at
org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1465)
>
>        at
org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:821)
>
>        at
org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:349)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)
>
>        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
>
>        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
.java:196)
>
>        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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:525)
>
>        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)
>
> Caused by: org.hibernate.PropertyNotFoundException: Could not find a
getter for admin in class po.User
>
>        at
org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAcces
sor.java:282)
>
>        at
org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor
.java:275)
>
>        at org.hibernate.mapping.Property.getGetter(Property.java:272)
>
>        at
org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntity
Tuplizer.java:247)
>
>        at
org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTupli
zer.java:125)
>
>        at
org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java
:55)
>
>        at
org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEn
tityModeToTuplizerMapping.java:56)
>
>        at
org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
>
>        at
org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntity
Persister.java:434)
>
>        at
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTable
EntityPersister.java:109)
>
>        at
org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFacto
ry.java:55)
>
>        at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
>
>        at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
>
>        at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory
(LocalSessionFactoryBean.java:753)
>
>        at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFacto
ry(LocalSessionFactoryBean.java:691)
>
>        at
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertie
sSet(AbstractSessionFactoryBean.java:211)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
>
>        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
>
>        ... 50 more
>
> 19-Aug-2009 11:30:20 org.apache.catalina.core.StandardContext start
>
> SEVERE: Error listenerStart
>
> 19-Aug-2009 11:30:20 org.apache.catalina.core.StandardContext start
>
> SEVERE: Context [/WebApplication4] startup failed due to previous errors
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
>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, ZiedBejaoui<be...@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.XmlWebApplicationContext@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.XmlWebApplicationContext@1cfad77]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1ed2061
>
> 19-Aug-2009 11:30:01 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
>
> INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@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 buildSettings
>
> INFO: JDBC batch size: 15
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC batch updates for versioned data: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Scrollable result sets: enabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC3 getGeneratedKeys(): enabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Connection release mode: on_close
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Maximum outer join fetch depth: 2
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default batch fetch size: 1
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Generate SQL with comments: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL updates by primary key: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL inserts for batching: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
>
> INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:02 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
>
> INFO: Using ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query language substitutions: {}
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JPA-QL strict compliance: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Second-level cache: enabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query cache: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory createCacheProvider
>
> INFO: Cache provider: org.hibernate.cache.NoCacheProvider
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Optimize cache for minimal puts: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Structured second-level cache entries: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Statistics: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Deleted entity synthetic identifier rollback: disabled
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default entity-mode: pojo
>
> 19-Aug-2009 11:30:02 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Named query checking : enabled
>
> 19-Aug-2009 11:30:03 org.hibernate.impl.SessionFactoryImpl <init>
>
> INFO: building session factory
>
> 19-Aug-2009 11:30:03 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
>
> INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1ed2061: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy
>
> 19-Aug-2009 11:30:03 org.springframework.web.context.ContextLoader initWebApplicationContext
>
> 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
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
>
>        at java.security.AccessController.doPrivileged(Native Method)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
>
>        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
>
>        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
>
>        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
>
>        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
>
>        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
>
>        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
>
>        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
>
>        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)
>
>        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
>
>        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
>
>        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
>
>        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
>
>        at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1244)
>
>        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:374)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>
>        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
>        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)
>
>        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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
>
>        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)
>
> Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User
>
>        at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
>
>        at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
>
>        at org.hibernate.mapping.Property.getGetter(Property.java:272)
>
>        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
>
>        at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
>
>        at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
>
>        at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
>
>        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
>
>        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
>
>        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
>
>        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
>
>        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
>
>        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
>
>        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
>
>        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
>
>        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
>
>        ... 36 more
>
> 19-Aug-2009 11:30:03 org.apache.catalina.core.StandardContext start
>
> SEVERE: Error listenerStart
>
> 19-Aug-2009 11:30:03 org.apache.catalina.core.StandardContext start
>
> SEVERE: Context [/WebApplication4] startup failed due to previous errors
>
> 19-Aug-2009 11:30:17 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:17 org.apache.catalina.startup.HostConfig checkResources
>
> INFO: Undeploying context [/WebApplication4]
>
> 19-Aug-2009 11:30:17 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:18 org.springframework.web.context.ContextLoader initWebApplicationContext
>
> INFO: Root WebApplicationContext: initialization started
>
> 19-Aug-2009 11:30:18 org.springframework.context.support.AbstractApplicationContext prepareRefresh
>
> INFO: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@7db754: display name [Root WebApplicationContext]; startup date [Wed Aug 19 11:30:18 BST 2009]; root of context hierarchy
>
> 19-Aug-2009 11:30:18 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
>
> INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
>
> 19-Aug-2009 11:30:18 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
>
> INFO: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@7db754]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e
>
> 19-Aug-2009 11:30:18 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
>
> INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy
>
> 19-Aug-2009 11:30:18 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
>
> INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>
>
> INFO: Hibernate 3.2.5
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>
>
> INFO: hibernate.properties not found
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment buildBytecodeProvider
>
> INFO: Bytecode provider name : cglib
>
> 19-Aug-2009 11:30:18 org.hibernate.cfg.Environment <clinit>
>
> INFO: using JDK 1.4 java.sql.Timestamp handling
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
>
> INFO: Mapping class: po.User -> user
>
> 19-Aug-2009 11:30:19 org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory
>
> INFO: Building new Hibernate SessionFactory
>
> 19-Aug-2009 11:30:19 org.hibernate.connection.ConnectionProviderFactory newConnectionProvider
>
> INFO: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: RDBMS: MySQL, version: 5.4.1-beta-community
>
> 19-Aug-2009 11:30:19 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:19 org.hibernate.dialect.Dialect <init>
>
> INFO: Using dialect: org.hibernate.dialect.MySQLDialect
>
> 19-Aug-2009 11:30:19 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
>
> INFO: Using default transaction strategy (direct JDBC transactions)
>
> 19-Aug-2009 11:30:19 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:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Automatic flush during beforeCompletion(): disabled
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Automatic session close at end of transaction: disabled
>
> 19-Aug-2009 11:30:19 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC batch size: 15
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC batch updates for versioned data: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Scrollable result sets: enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JDBC3 getGeneratedKeys(): enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Connection release mode: on_close
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Maximum outer join fetch depth: 2
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default batch fetch size: 1
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Generate SQL with comments: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL updates by primary key: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Order SQL inserts for batching: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
>
> INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:20 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
>
> INFO: Using ASTQueryTranslatorFactory
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query language substitutions: {}
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: JPA-QL strict compliance: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Second-level cache: enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Query cache: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory createCacheProvider
>
> INFO: Cache provider: org.hibernate.cache.NoCacheProvider
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Optimize cache for minimal puts: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Structured second-level cache entries: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Statistics: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Deleted entity synthetic identifier rollback: disabled
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Default entity-mode: pojo
>
> 19-Aug-2009 11:30:20 org.hibernate.cfg.SettingsFactory buildSettings
>
> INFO: Named query checking : enabled
>
> 19-Aug-2009 11:30:20 org.hibernate.impl.SessionFactoryImpl <init>
>
> INFO: building session factory
>
> 19-Aug-2009 11:30:20 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
>
> INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c9fe7e: defining beans [dataSource,sessionFactory,userDao,userService,messageSource,loginAction]; root of factory hierarchy
>
> 19-Aug-2009 11:30:20 org.springframework.web.context.ContextLoader initWebApplicationContext
>
> 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
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
>
>        at java.security.AccessController.doPrivileged(Native Method)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
>
>        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
>
>        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
>
>        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
>
>        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
>
>        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
>
>        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
>
>        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
>
>        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)
>
>        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
>
>        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
>
>        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
>
>        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
>
>        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>
>        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
>
>        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
>
>        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
>
>        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:511)
>
>        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1229)
>
>        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 org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
>
>        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
>
>        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
>
>        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1465)
>
>        at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:821)
>
>        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:349)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>
>        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
>        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)
>
>        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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
>
>        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)
>
> Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for admin in class po.User
>
>        at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
>
>        at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
>
>        at org.hibernate.mapping.Property.getGetter(Property.java:272)
>
>        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:247)
>
>        at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:125)
>
>        at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
>
>        at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
>
>        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
>
>        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
>
>        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
>
>        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
>
>        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
>
>        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
>
>        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
>
>        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
>
>        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
>
>        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
>
>        ... 50 more
>
> 19-Aug-2009 11:30:20 org.apache.catalina.core.StandardContext start
>
> SEVERE: Error listenerStart
>
> 19-Aug-2009 11:30:20 org.apache.catalina.core.StandardContext start
>
> SEVERE: Context [/WebApplication4] startup failed due to previous errors
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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.dave@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:nilsga@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<be...@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.lenart@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Martin Gainty <mg...@hotmail.com>.
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: tommyhp2@yahoo.com
> Subject: Re: Hibernate3+Spring2.5+Struts2
> To: user@struts.apache.org
> 
> 
> 
> 
> 
> 
> ----- Original Message ----
> > From: ZiedBejaoui <be...@hotmail.com>
> > To: Struts Users Mailing List <us...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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

Posted by Zied Bejaoui <be...@hotmail.com>.
Hi,

I have changed the code and used the imp class methods but still having the
same exception, here is my code and hop you can help me:

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 usrService;
    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 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 UserServiceImp getUserService() {
        return userService;
    }

    public void setUserService(UserServiceImp userService) {
        this.userService = userService;
    }
    
    public void setMessageSource(ResourceBundleMessageSource messageSource)
    {
        this.messageSource=messageSource; 
    }
    
    public ResourceBundleMessageSource getMessageSource()
    { return messageSource;
    }
    
    public void setUserService(UserService usrService) {
  this.usrService = usrService;
}

}

UserDaoImpl:

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);
        
    }
    
    
}

UserServcieImpl:

package service;
import po.User;

/**
 *
 * @author ABIS1
 */
public class UserServiceImp implements UserService {
    
     private dao.UserDao userDao;

    public void addUser( String userName, String password) throws Exception{
        po.User user = new User();
        
        
        user.setName(userName);
        user.setPassword(password);
        try
        {
            userDao.save(user);
        }
        catch(Exception err)
        {
            throw err;
        }
    }
    public User getUser(long userId)
    {
        return userDao.getUser(userId);
    }

    public void setUserDao(dao.UserDaoImpl userDao) {
        this.userDao = userDao;
    }

    public User getUser(String userName) {
        return this.userDao.getUser(userName);
    }

}

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>
                <value>po/user.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
 
<value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
        </property>
    </bean>
    <bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory"><ref 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">
            <result>example/message.jsp</result>
        </action>
    
    </package>
</struts>



Thannks.
    

-----Original Message-----
From: Wes Wannemacher [mailto:wesw@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 Bejaoui<be...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Wes Wannemacher <we...@wantii.com>.
sure, zip it up and email it to me

-Wes

On Fri, Aug 21, 2009 at 10:00 AM, ZiedBejaoui<be...@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" <we...@wantii.com>
> Sent: Thursday, August 20, 2009 7:44 PM
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Re: Hibernate3+Spring2.5+Struts2
>
>> On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaoui<be...@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by ZiedBejaoui <be...@hotmail.com>.
I will split it into 3 war files.

Cheers

--------------------------------------------------
From: "Martin Gainty" <mg...@hotmail.com>
Sent: Friday, August 21, 2009 3:35 PM
To: "Struts Users Mailing List" <us...@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: bejaouizied@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" <we...@wantii.com>
>> Sent: Thursday, August 20, 2009 7:44 PM
>> To: "Struts Users Mailing List" <us...@struts.apache.org>
>> Subject: Re: Hibernate3+Spring2.5+Struts2
>>
>> > On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaoui<be...@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-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Martin Gainty <mg...@hotmail.com>.
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: bejaouizied@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" <we...@wantii.com>
> Sent: Thursday, August 20, 2009 7:44 PM
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Re: Hibernate3+Spring2.5+Struts2
> 
> > On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaoui<be...@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-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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

Posted by ZiedBejaoui <be...@hotmail.com>.
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" <we...@wantii.com>
Sent: Thursday, August 20, 2009 7:44 PM
To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Re: Hibernate3+Spring2.5+Struts2

> On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaoui<be...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Wes Wannemacher <we...@wantii.com>.
On Thu, Aug 20, 2009 at 12:38 PM, Zied Bejaoui<be...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
On Thu, Aug 20, 2009 at 5:27 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Martin Gainty <mg...@hotmail.com>.
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: wesw@wantii.com
> To: user@struts.apache.org
> 
> On Thu, Aug 20, 2009 at 11:13 AM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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

Posted by Wes Wannemacher <we...@wantii.com>.
On Thu, Aug 20, 2009 at 11:13 AM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re:RE: Hibernate3+Spring2.5+Struts2

Posted by xnpeng <xn...@163.com>.
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?
how to remove my email from this fucking list?


 


在2009-08-20,"Zied Bejaoui" <be...@hotmail.com> 写道:
>I still have the same exception, I am posting all my code amd my project
>structure hope you can fix me to fix the problem:
>
>Package action:
>
>package action;
>
>import com.opensymphony.xwork2.ActionSupport;
>import java.util.Locale;
>import org.springframework.context.support.ResourceBundleMessageSource;
>import po.User;
>
>import service.UserService;
>import service.UserServiceImp;
>/**
> *
> * @author ABIS1
> */
>
>public class LoginAction extends ActionSupport {
>    
>    private UserServiceImp userService;
>    private String message;
>    private String username;
>    private String password;
>    private ResourceBundleMessageSource messageSource;
>
>    public LoginAction() {
>    }
>
>    @Override
>    public String execute() throws Exception {
>       
>        
>        
>        User usr = userService.getUser(username);
>       
>        if(usr != null){
>            if(usr.getPassword().equals(password)){
>                message = messageSource.getMessage("loginSuccess",
>null,Locale.UK);
>            }else{
>                message = messageSource.getMessage("pswError",
>null,Locale.UK);
>            }
>        }else{
>            message = messageSource.getMessage("usrError",
>null,Locale.CHINA);          
>        }
>        return SUCCESS;
>    }
>
>    public void setUserService(UserServiceImp userService) {
>        this.userService = userService;
>    }
>
>    public String getMessage() {
>        return message;
>    }
>
>    public void setMessage(String message) {
>        this.message = message;
>    }
>
>    public String getUsername() {
>        return username;
>    }
>
>    public void setUsername(String username) {
>        this.username = username;
>    }
>
>    public String getPassword() {
>        return password;
>    }
>
>    public void setPassword(String password) {
>        this.password = password;
>    }
>
>    public void setMessageSource(ResourceBundleMessageSource messageSource)
>{
>        this.messageSource = messageSource;
>    }
>
>}
>----------------------------------------------------------------------------
>----------------------------------------------------------------------
>Package Dao:
>
>package dao;
>import po.User;
>
>
>/**
> *
> * @author ABIS1
> */
>public interface UserDao {
>    
>    void save(User user) throws Exception;
>    User getUser(long userId);
>    User getUser(String userName);
>    User getuser (String password);
>
>}___________________________________________________________
>
>/*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
>
>package dao;
>
>import po.*;
>import dao.UserDao;
>import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
>
>/**
> *
> * @author ABIS1
> */
>public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
>    
>    public void save(User user) throws Exception
>    {
>        try
>        {
>            getHibernateTemplate().save(user);
>        }
>        catch(Exception err)
>        {
>            throw err;
>        }
>
>    }   
>
>    public User getUser(long userId)
>    {
>        return (User)getHibernateTemplate().get(User.class, userId);
>    } 
>
>    public User getUser(String userName) {
>        return (User)getHibernateTemplate().find("from User as u where
>u.name = ?", userName).get(0);
>    }
>    
>    public User getuser(String password) {
>        return (User)getHibernateTemplate().find("from User as u where
>u.password = ?", password).get(0);
>    }
>
>}
>----------------------------------------------------------------------------
>--------------------------------------------------------------------
>Package service:
>
>package service;
>import dao.UserDaoImpl;
>import po.User;
>/**
> *
> * @author ABIS1
> */
>public interface UserService {
>    
>    void addUser(String userName, String password) throws Exception;
>
>    User getUser(long userId);
>   
>    User getUser(String userName);
>
>    void setUserDao(UserDaoImpl userDao);
>
>}
>_____________________________________________________________________
>
>/*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
>
>package service;
>import po.User;
>
>/**
> *
> * @author ABIS1
> */
>public class UserServiceImp implements UserService {
>    
>     private dao.UserDao userDao;
>
>    public void addUser(String userName, String password) throws Exception{
>        po.User user = new User();
>        
>         
>        user.setName(userName);
>        user.setPassword(password);
>        try
>        {
>            userDao.save(user);
>        }
>        catch(Exception err)
>        {
>            throw err;
>        }
>    }
>    public User getUser(long userId)
>    {
>        return userDao.getUser(userId);
>    }
>
>    public void setUserDao(dao.UserDaoImpl userDao) {
>        this.userDao = userDao;
>    }
>
>    public User getUser(String userName) {
>        return this.userDao.getUser(userName);
>    }
>
>}
>
>----------------------------------------------------------------
>
>Package PO:
>
>/*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
>
>package po;
>
>/**
> *
> * @author ABIS1
> */
>public class User {
>    
>    private String Name; 
>    private long id;
>    private String password;
>//   private int admin;
>
>    public String getName() {
>        return Name;
>    }
>
>    public void setName(String Name) {
>        this.Name = Name;
>    }
>
>    public long getId() {
>        return id;
>    }
>
>    public void setId(long id) {
>        this.id = id;
>    }
>
>    public String getPassword() {
>        return password;
>    }
>
>    public void setPassword(String password) {
>        this.password = password;
>    }
>    
>  /*  public void setAdmin (int admin)
>    {this.admin=admin;}
>    
>    public int getAdmin ()
>    {return admin;}*/
>    
>  
>    
>    
>
>}
>
>____________________________________________________________________________
>
>User.hbm.xml under po:
>
><?xml version="1.0" encoding="UTF-8"?>
><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
>3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
><hibernate-mapping>
>  <class dynamic-insert="false" dynamic-update="false" mutable="true"
>name="po.User" optimistic-lock="version" polymorphism="implicit"
>select-before-update="false" table="user">
><id column="userId" name="id">
>            <generator class="identity"/>
>        </id>
>        
>        <property column="userName" name="name" type="string"/>
>       
>        <property column="password" name="password" type="string"/>
>        </class>
></hibernate-mapping>
>
>----------------------------------------------------------------------------
>-------------------------
>
>My application context.xml: 
>
><?xml version="1.0" encoding="UTF-8"?>
><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
>"http://www.springframework.org/dtd/spring-beans.dtd">
>
><beans default-autowire="autodetect">
>    <!-- add your spring beans here -->
>    <bean id="dataSource"
>class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>        <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
>        <property name="username" value="root"/>
>        <property name="password" value=""/>
>    </bean>
>    <bean id="sessionFactory"
>class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>        <property name="dataSource" ref="dataSource"/>
>        <property name="mappingResources">
>            <list>
>                <value>po/user.hbm.xml</value>
>            </list>
>        </property>
>        <property name="hibernateProperties">
> 
><value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
>        </property>
>    </bean>
>    <bean id="userDao" class="dao.UserDaoImpl">
>        <property name="sessionFactory">
>            <ref bean="sessionFactory"></ref>
>        </property>
>    </bean> 
>    <bean id="userService" class="service.UserServiceImp">
>        <property name="userDao">
>            <ref bean="userDao"></ref>
>        </property>
>    </bean>
>    <bean id="messageSource"
>class="org.springframework.context.support.ResourceBundleMessageSource"> 
>        <property name="basename" value="messages" /> 
>    </bean>
>
>    <bean id="loginAction" class="action.LoginAction">
>        <property name="userService">
>            <ref bean="userService"></ref>
>        </property>
>        <property name="messageSource" ref="messageSource"/>
>    </bean>
></beans>
>
>
>Hope this can help.
> 
>
>
>
>-----Original Message-----
>From: Martin Gainty [mailto:mgainty@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: wesw@wantii.com
>> To: user@struts.apache.org
>> 
>> On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
>> >
>> > Are you using the Spring plugin?
>> >
>> > [snip]
>> 
>> 
>> Dave's right, make sure you have the spring plugin installed and that
>> you have spring's listener configured in your web.xml file
>> 
>> 
>> On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>
>_________________________________________________________________
>Get back to school stuff for them and cashback for you.
>http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
>oSchool_Cashback_BTSCashback_1x1
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

RE: Hibernate3+Spring2.5+Struts2

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

Posted by Zied Bejaoui <be...@hotmail.com>.
This is the definition of my session factory, hibernate properties and data
source :
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
        <property name="username" value="root"/>
        <property name="password" value=""/>
    </bean>
    <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
            <list>
                <value>po/user.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
 
<value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
        </property>
    </bean>
MY dao is not using hibernate template but sessuin factory I have changed it
to this:

bean id="userDao" class="dao.UserDaoImpl">
        <property name="HibernateTemplate">
            <ref bean="HibernateTemplate"></ref>
        </property>
    </bean>
Regarding the case consistency I have the table field userName, and the
variable username, did you see any typing mistake.

I have run the example and seems that the problem is that hibernate template
is not define how can i define it please I don’t know the syntax?

Here is the error:
SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'userDao' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
'HibernateTemplate' while setting bean property 'HibernateTemplate'; nested
exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'HibernateTemplate' is defined


Thanks for your help 



-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: 20 August 2009 13:32
To: Struts Users Mailing List
Subject: RE: Hibernate3+Spring2.5+Struts2


mg>take a look inside all of the provided xml files.. did you
mg>define a sessionFactory..alternatively implements
mg><property name="hibernate.properties">
mg>or mappingResources 
mg><property name="mappingResources">
mg>or mappingDirectoryLocations
mg><property name="mappingDirectoryLocations"/>

mg>a sessionFactory needs a dataSource jndiName something like
mg><value>java:comp/env/jdbc/dataSource</value>
mg>the sessionFactory refers to the datasource later on via property e.g.
mg><bean id=sessionFactory" class="...LocalSessionFactoryBean"/>
mg><property name="dataSource">
mg><ref bean="dataSource"/>
mg></property>
mg></bean>

mg>did you define a HibernateTemplate whose property name="sessionFactory"?

mg>do your DAO beans use the hibernateTemplate?
mg><bean id="someDAO" class="...someDaoHibernate">
mg><property name="hibernateTemplate">
mg>  <ref bean="hibernateTemplate">

mg>the hibernateTemplate statement find method is missing the type parameter
>     public User getUser(String userName) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.name = ?", userName).get(0);

mg>needs to change to 
mg>public User getUser(String userName) {

mg>return (User)getHibernateTemplate().find("from User as u where u.name =
?", mg>userName,Hibernate.STRING);


mg>also it is vital to maintain case-consistency for variable names as
mg>username!=userName!=USERNAME!=Username

mg>post back those xml files when you get the chance

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




> From: bejaouizied@hotmail.com
> To: user@struts.apache.org
> Subject: RE: Hibernate3+Spring2.5+Struts2
> Date: Thu, 20 Aug 2009 11:17:16 +0100
> 
> I still have the same exception, I am posting all my code amd my project
> structure hope you can fix me to fix the problem:
> 
> Package action:
> 
> package action;
> 
> import com.opensymphony.xwork2.ActionSupport;
> import java.util.Locale;
> import org.springframework.context.support.ResourceBundleMessageSource;
> import po.User;
> 
> import service.UserService;
> import service.UserServiceImp;
> /**
>  *
>  * @author ABIS1
>  */
> 
> public class LoginAction extends ActionSupport {
>     
>     private UserServiceImp userService;
>     private String message;
>     private String username;
>     private String password;
>     private ResourceBundleMessageSource messageSource;
> 
>     public LoginAction() {
>     }
> 
>     @Override
>     public String execute() throws Exception {
>        
>         
>         
>         User usr = userService.getUser(username);
>        
>         if(usr != null){
>             if(usr.getPassword().equals(password)){
>                 message = messageSource.getMessage("loginSuccess",
> null,Locale.UK);
>             }else{
>                 message = messageSource.getMessage("pswError",
> null,Locale.UK);
>             }
>         }else{
>             message = messageSource.getMessage("usrError",
> null,Locale.CHINA);          
>         }
>         return SUCCESS;
>     }
> 
>     public void setUserService(UserServiceImp userService) {
>         this.userService = userService;
>     }
> 
>     public String getMessage() {
>         return message;
>     }
> 
>     public void setMessage(String message) {
>         this.message = message;
>     }
> 
>     public String getUsername() {
>         return username;
>     }
> 
>     public void setUsername(String username) {
>         this.username = username;
>     }
> 
>     public String getPassword() {
>         return password;
>     }
> 
>     public void setPassword(String password) {
>         this.password = password;
>     }
> 
>     public void setMessageSource(ResourceBundleMessageSource
messageSource)
> {
>         this.messageSource = messageSource;
>     }
> 
> }
>
----------------------------------------------------------------------------
> ----------------------------------------------------------------------
> Package Dao:
> 
> package dao;
> import po.User;
> 
> 
> /**
>  *
>  * @author ABIS1
>  */
> public interface UserDao {
>     
>     void save(User user) throws Exception;
>     User getUser(long userId);
>     User getUser(String userName);
>     User getuser (String password);
> 
> }___________________________________________________________
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package dao;
> 
> import po.*;
> import dao.UserDao;
> import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
>     
>     public void save(User user) throws Exception
>     {
>         try
>         {
>             getHibernateTemplate().save(user);
>         }
>         catch(Exception err)
>         {
>             throw err;
>         }
> 
>     }   
> 
>     public User getUser(long userId)
>     {
>         return (User)getHibernateTemplate().get(User.class, userId);
>     } 
> 
>     public User getUser(String userName) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.name = ?", userName).get(0);
>     }
>     
>     public User getuser(String password) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.password = ?", password).get(0);
>     }
> 
> }
>
----------------------------------------------------------------------------
> --------------------------------------------------------------------
> Package service:
> 
> package service;
> import dao.UserDaoImpl;
> import po.User;
> /**
>  *
>  * @author ABIS1
>  */
> public interface UserService {
>     
>     void addUser(String userName, String password) throws Exception;
> 
>     User getUser(long userId);
>    
>     User getUser(String userName);
> 
>     void setUserDao(UserDaoImpl userDao);
> 
> }
> _____________________________________________________________________
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package service;
> import po.User;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class UserServiceImp implements UserService {
>     
>      private dao.UserDao userDao;
> 
>     public void addUser(String userName, String password) throws
Exception{
>         po.User user = new User();
>         
>          
>         user.setName(userName);
>         user.setPassword(password);
>         try
>         {
>             userDao.save(user);
>         }
>         catch(Exception err)
>         {
>             throw err;
>         }
>     }
>     public User getUser(long userId)
>     {
>         return userDao.getUser(userId);
>     }
> 
>     public void setUserDao(dao.UserDaoImpl userDao) {
>         this.userDao = userDao;
>     }
> 
>     public User getUser(String userName) {
>         return this.userDao.getUser(userName);
>     }
> 
> }
> 
> ----------------------------------------------------------------
> 
> Package PO:
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package po;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class User {
>     
>     private String Name; 
>     private long id;
>     private String password;
> //   private int admin;
> 
>     public String getName() {
>         return Name;
>     }
> 
>     public void setName(String Name) {
>         this.Name = Name;
>     }
> 
>     public long getId() {
>         return id;
>     }
> 
>     public void setId(long id) {
>         this.id = id;
>     }
> 
>     public String getPassword() {
>         return password;
>     }
> 
>     public void setPassword(String password) {
>         this.password = password;
>     }
>     
>   /*  public void setAdmin (int admin)
>     {this.admin=admin;}
>     
>     public int getAdmin ()
>     {return admin;}*/
>     
>   
>     
>     
> 
> }
> 
>
____________________________________________________________________________
> 
> User.hbm.xml under po:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping>
>   <class dynamic-insert="false" dynamic-update="false" mutable="true"
> name="po.User" optimistic-lock="version" polymorphism="implicit"
> select-before-update="false" table="user">
> <id column="userId" name="id">
>             <generator class="identity"/>
>         </id>
>         
>         <property column="userName" name="name" type="string"/>
>        
>         <property column="password" name="password" type="string"/>
>         </class>
> </hibernate-mapping>
> 
>
----------------------------------------------------------------------------
> -------------------------
> 
> My application context.xml: 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> "http://www.springframework.org/dtd/spring-beans.dtd">
> 
> <beans default-autowire="autodetect">
>     <!-- add your spring beans here -->
>     <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>         <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
>         <property name="username" value="root"/>
>         <property name="password" value=""/>
>     </bean>
>     <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>         <property name="dataSource" ref="dataSource"/>
>         <property name="mappingResources">
>             <list>
>                 <value>po/user.hbm.xml</value>
>             </list>
>         </property>
>         <property name="hibernateProperties">
>  
> <value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
>         </property>
>     </bean>
>     <bean id="userDao" class="dao.UserDaoImpl">
>         <property name="sessionFactory">
>             <ref bean="sessionFactory"></ref>
>         </property>
>     </bean> 
>     <bean id="userService" class="service.UserServiceImp">
>         <property name="userDao">
>             <ref bean="userDao"></ref>
>         </property>
>     </bean>
>     <bean id="messageSource"
> class="org.springframework.context.support.ResourceBundleMessageSource"> 
>         <property name="basename" value="messages" /> 
>     </bean>
> 
>     <bean id="loginAction" class="action.LoginAction">
>         <property name="userService">
>             <ref bean="userService"></ref>
>         </property>
>         <property name="messageSource" ref="messageSource"/>
>     </bean>
> </beans>
> 
> 
> Hope this can help.
>  
> 
> 
> 
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@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: wesw@wantii.com
> > To: user@struts.apache.org
> > 
> > On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> > >
> > > Are you using the Spring plugin?
> > >
> > > [snip]
> > 
> > 
> > Dave's right, make sure you have the spring plugin installed and that
> > you have spring's listener configured in your web.xml file
> > 
> > 
> > On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> _________________________________________________________________
> Get back to school stuff for them and cashback for you.
>
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
> oSchool_Cashback_BTSCashback_1x1
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® is up to 70% faster. Now good news travels really fast. 
http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:W
M_HYGN_faster:082009


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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:mgainty@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 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: bejaouizied@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" <mg...@hotmail.com>
> Sent: Thursday, August 20, 2009 2:48 PM
> To: "Struts Users Mailing List" <us...@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: bejaouizied@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="sessionFactory"><ref 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:mgainty@hotmail.com]
> >> Sent: 20 August 2009 13:32
> >> To: Struts Users Mailing List
> >> Subject: RE: Hibernate3+Spring2.5+Struts2
> >>
> >>
> >> mg>take a look inside all of the provided xml files.. did you
> >> mg>define a sessionFactory..alternatively implements
> >> mg><property name="hibernate.properties">
> >> mg>or mappingResources
> >> mg><property name="mappingResources">
> >> mg>or mappingDirectoryLocations
> >> mg><property name="mappingDirectoryLocations"/>
> >>
> >> mg>a sessionFactory needs a dataSource jndiName something like
> >> mg><value>java:comp/env/jdbc/dataSource</value>
> >> mg>the sessionFactory refers to the datasource later on via property
e.g.
> >> mg><bean id=sessionFactory" class="...LocalSessionFactoryBean"/>
> >> mg><property name="dataSource">
> >> mg><ref bean="dataSource"/>
> >> mg></property>
> >> mg></bean>
> >>
> >> mg>did you define a HibernateTemplate whose property 
> >> name="sessionFactory"?
> >>
> >> mg>do your DAO beans use the hibernateTemplate?
> >> mg><bean id="someDAO" class="...someDaoHibernate">
> >> mg><property name="hibernateTemplate">
> >> mg>  <ref bean="hibernateTemplate">
> >>
> >> mg>the hibernateTemplate statement find method is missing the type 
> >> parameter
> >> >     public User getUser(String userName) {
> >> >         return (User)getHibernateTemplate().find("from User as u
where
> >> > u.name = ?", userName).get(0);
> >>
> >> mg>needs to change to
> >> mg>public User getUser(String userName) {
> >>
> >> mg>return (User)getHibernateTemplate().find("from User as u where
u.name 
> >> =
> >> ?", mg>userName,Hibernate.STRING);
> >>
> >>
> >> mg>also it is vital to maintain case-consistency for variable names as
> >> mg>username!=userName!=USERNAME!=Username
> >>
> >> mg>post back those xml files when you get the chance
> >>
> >> thanks,
> >> Martin Gainty
> >> ______________________________________________
> >> Verzicht und Vertraulichkeitanmerkung/Note de déni et de
confidentialité
> >>
> >> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> >> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede 
> >> unbefugte
> >> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese
Nachricht
> >> dient lediglich dem Austausch von Informationen und entfaltet keine
> >> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> >> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> >> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas

> >> le
> >> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> >> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la 
> >> copie
> >> de ceci est interdite. Ce message sert à l'information seulement et 
> >> n'aura
> >> pas n'importe quel effet légalement obligatoire. Étant donné que les 
> >> email
> >> peuvent facilement être sujets à la manipulation, nous ne pouvons 
> >> accepter
> >> aucune responsabilité pour le contenu fourni.
> >>
> >>
> >>
> >>
> >> > From: bejaouizied@hotmail.com
> >> > To: user@struts.apache.org
> >> > Subject: RE: Hibernate3+Spring2.5+Struts2
> >> > Date: Thu, 20 Aug 2009 11:17:16 +0100
> >> >
> >> > I still have the same exception, I am posting all my code amd my 
> >> > project
> >> > structure hope you can fix me to fix the problem:
> >> >
> >> > Package action:
> >> >
> >> > package action;
> >> >
> >> > import com.opensymphony.xwork2.ActionSupport;
> >> > import java.util.Locale;
> >> > import
org.springframework.context.support.ResourceBundleMessageSource;
> >> > import po.User;
> >> >
> >> > import service.UserService;
> >> > import service.UserServiceImp;
> >> > /**
> >> >  *
> >> >  * @author ABIS1
> >> >  */
> >> >
> >> > public class LoginAction extends ActionSupport {
> >> >
> >> >     private UserServiceImp userService;
> >> >     private String message;
> >> >     private String username;
> >> >     private String password;
> >> >     private ResourceBundleMessageSource messageSource;
> >> >
> >> >     public LoginAction() {
> >> >     }
> >> >
> >> >     @Override
> >> >     public String execute() throws Exception {
> >> >
> >> >
> >> >
> >> >         User usr = userService.getUser(username);
> >> >
> >> >         if(usr != null){
> >> >             if(usr.getPassword().equals(password)){
> >> >                 message = messageSource.getMessage("loginSuccess",
> >> > null,Locale.UK);
> >> >             }else{
> >> >                 message = messageSource.getMessage("pswError",
> >> > null,Locale.UK);
> >> >             }
> >> >         }else{
> >> >             message = messageSource.getMessage("usrError",
> >> > null,Locale.CHINA);
> >> >         }
> >> >         return SUCCESS;
> >> >     }
> >> >
> >> >     public void setUserService(UserServiceImp userService) {
> >> >         this.userService = userService;
> >> >     }
> >> >
> >> >     public String getMessage() {
> >> >         return message;
> >> >     }
> >> >
> >> >     public void setMessage(String message) {
> >> >         this.message = message;
> >> >     }
> >> >
> >> >     public String getUsername() {
> >> >         return username;
> >> >     }
> >> >
> >> >     public void setUsername(String username) {
> >> >         this.username = username;
> >> >     }
> >> >
> >> >     public String getPassword() {
> >> >         return password;
> >> >     }
> >> >
> >> >     public void setPassword(String password) {
> >> >         this.password = password;
> >> >     }
> >> >
> >> >     public void setMessageSource(ResourceBundleMessageSource
> >> messageSource)
> >> > {
> >> >         this.messageSource = messageSource;
> >> >     }
> >> >
> >> > }
> >> >
> >>
----------------------------------------------------------------------------
> >> >
----------------------------------------------------------------------
> >> > Package Dao:
> >> >
> >> > package dao;
> >> > import po.User;
> >> >
> >> >
> >> > /**
> >> >  *
> >> >  * @author ABIS1
> >> >  */
> >> > public interface UserDao {
> >> >
> >> >     void save(User user) throws Exception;
> >> >     User getUser(long userId);
> >> >     User getUser(String userName);
> >> >     User getuser (String password);
> >> >
> >> > }___________________________________________________________
> >> >
> >> > /*
> >> >  * To change this template, choose Tools | Templates
> >> >  * and open the template in the editor.
> >> >  */
> >> >
> >> > package dao;
> >> >
> >> > import po.*;
> >> > import dao.UserDao;
> >> > import
org.springframework.orm.hibernate3.support.HibernateDaoSupport;
> >> >
> >> > /**
> >> >  *
> >> >  * @author ABIS1
> >> >  */
> >> > public class UserDaoImpl extends HibernateDaoSupport implements
UserDao 
> >> > {
> >> >
> >> >     public void save(User user) throws Exception
> >> >     {
> >> >         try
> >> >         {
> >> >             getHibernateTemplate().save(user);
> >> >         }
> >> >         catch(Exception err)
> >> >         {
> >> >             throw err;
> >> >         }
> >> >
> >> >     }
> >> >
> >> >     public User getUser(long userId)
> >> >     {
> >> >         return (User)getHibernateTemplate().get(User.class, userId);
> >> >     }
> >> >
> >> >     public User getUser(String userName) {
> >> >         return (User)getHibernateTemplate().find("from User as u
where
> >> > u.name = ?", userName).get(0);
> >> >     }
> >> >
> >> >     public User getuser(String password) {
> >> >         return (User)getHibernateTemplate().find("from User as u
where
> >> > u.password = ?", password).get(0);
> >> >     }
> >> >
> >> > }
> >> >
> >>
----------------------------------------------------------------------------
> >> > --------------------------------------------------------------------
> >> > Package service:
> >> >
> >> > package service;
> >> > import dao.UserDaoImpl;
> >> > import po.User;
> >> > /**
> >> >  *
> >> >  * @author ABIS1
> >> >  */
> >> > public interface UserService {
> >> >
> >> >     void addUser(String userName, String password) throws Exception;
> >> >
> >> >     User getUser(long userId);
> >> >
> >> >     User getUser(String userName);
> >> >
> >> >     void setUserDao(UserDaoImpl userDao);
> >> >
> >> > }
> >> > _____________________________________________________________________
> >> >
> >> > /*
> >> >  * To change this template, choose Tools | Templates
> >> >  * and open the template in the editor.
> >> >  */
> >> >
> >> > package service;
> >> > import po.User;
> >> >
> >> > /**
> >> >  *
> >> >  * @author ABIS1
> >> >  */
> >> > public class UserServiceImp implements UserService {
> >> >
> >> >      private dao.UserDao userDao;
> >> >
> >> >     public void addUser(String userName, String password) throws
> >> Exception{
> >> >         po.User user = new User();
> >> >
> >> >
> >> >         user.setName(userName);
> >> >         user.setPassword(password);
> >> >         try
> >> >         {
> >> >             userDao.save(user);
> >> >         }
> >> >         catch(Exception err)
> >> >         {
> >> >             throw err;
> >> >         }
> >> >     }
> >> >     public User getUser(long userId)
> >> >     {
> >> >         return userDao.getUser(userId);
> >> >     }
> >> >
> >> >     public void setUserDao(dao.UserDaoImpl userDao) {
> >> >         this.userDao = userDao;
> >> >     }
> >> >
> >> >     public User getUser(String userName) {
> >> >         return this.userDao.getUser(userName);
> >> >     }
> >> >
> >> > }
> >> >
> >> > ----------------------------------------------------------------
> >> >
> >> > Package PO:
> >> >
> >> > /*
> >> >  * To change this template, choose Tools | Templates
> >> >  * and open the template in the editor.
> >> >  */
> >> >
> >> > package po;
> >> >
> >> > /**
> >> >  *
> >> >  * @author ABIS1
> >> >  */
> >> > public class User {
> >> >
> >> >     private String Name;
> >> >     private long id;
> >> >     private String password;
> >> > //   private int admin;
> >> >
> >> >     public String getName() {
> >> >         return Name;
> >> >     }
> >> >
> >> >     public void setName(String Name) {
> >> >         this.Name = Name;
> >> >     }
> >> >
> >> >     public long getId() {
> >> >         return id;
> >> >     }
> >> >
> >> >     public void setId(long id) {
> >> >         this.id = id;
> >> >     }
> >> >
> >> >     public String getPassword() {
> >> >         return password;
> >> >     }
> >> >
> >> >     public void setPassword(String password) {
> >> >         this.password = password;
> >> >     }
> >> >
> >> >   /*  public void setAdmin (int admin)
> >> >     {this.admin=admin;}
> >> >
> >> >     public int getAdmin ()
> >> >     {return admin;}*/
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > }
> >> >
> >> >
> >>
____________________________________________________________________________
> >> >
> >> > User.hbm.xml under po:
> >> >
> >> > <?xml version="1.0" encoding="UTF-8"?>
> >> > <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
DTD
> >> > 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> >> > <hibernate-mapping>
> >> >   <class dynamic-insert="false" dynamic-update="false" mutable="true"
> >> > name="po.User" optimistic-lock="version" polymorphism="implicit"
> >> > select-before-update="false" table="user">
> >> > <id column="userId" name="id">
> >> >             <generator class="identity"/>
> >> >         </id>
> >> >
> >> >         <property column="userName" name="name" type="string"/>
> >> >
> >> >         <property column="password" name="password" type="string"/>
> >> >         </class>
> >> > </hibernate-mapping>
> >> >
> >> >
> >>
----------------------------------------------------------------------------
> >> > -------------------------
> >> >
> >> > My application context.xml:
> >> >
> >> > <?xml version="1.0" encoding="UTF-8"?>
> >> > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> >> > "http://www.springframework.org/dtd/spring-beans.dtd">
> >> >
> >> > <beans default-autowire="autodetect">
> >> >     <!-- add your spring beans here -->
> >> >     <bean id="dataSource"
> >> > class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> >> >         <property name="driverClassName" 
> >> > value="com.mysql.jdbc.Driver"/>
> >> >         <property name="url" 
> >> > value="jdbc:mysql://localhost:3306/sshdemo"/>
> >> >         <property name="username" value="root"/>
> >> >         <property name="password" value=""/>
> >> >     </bean>
> >> >     <bean id="sessionFactory"
> >> > class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> >> >         <property name="dataSource" ref="dataSource"/>
> >> >         <property name="mappingResources">
> >> >             <list>
> >> >                 <value>po/user.hbm.xml</value>
> >> >             </list>
> >> >         </property>
> >> >         <property name="hibernateProperties">
> >> >
> >> > <value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
> >> >         </property>
> >> >     </bean>
> >> >     <bean id="userDao" class="dao.UserDaoImpl">
> >> >         <property name="sessionFactory">
> >> >             <ref bean="sessionFactory"></ref>
> >> >         </property>
> >> >     </bean>
> >> >     <bean id="userService" class="service.UserServiceImp">
> >> >         <property name="userDao">
> >> >             <ref bean="userDao"></ref>
> >> >         </property>
> >> >     </bean>
> >> >     <bean id="messageSource"
> >> >
class="org.springframework.context.support.ResourceBundleMessageSource">
> >> >         <property name="basename" value="messages" />
> >> >     </bean>
> >> >
> >> >     <bean id="loginAction" class="action.LoginAction">
> >> >         <property name="userService">
> >> >             <ref bean="userService"></ref>
> >> >         </property>
> >> >         <property name="messageSource" ref="messageSource"/>
> >> >     </bean>
> >> > </beans>
> >> >
> >> >
> >> > Hope this can help.
> >> >
> >> >
> >> >
> >> >
> >> > -----Original Message-----
> >> > From: Martin Gainty [mailto:mgainty@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: wesw@wantii.com
> >> > > To: user@struts.apache.org
> >> > >
> >> > > On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> >> > > >
> >> > > > Are you using the Spring plugin?
> >> > > >
> >> > > > [snip]
> >> > >
> >> > >
> >> > > Dave's right, make sure you have the spring plugin installed and
that
> >> > > you have spring's listener configured in your web.xml file
> >> > >
> >> > >
> >> > > On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> >> > > For additional commands, e-mail: user-help@struts.apache.org
> >> > >
> >> >
> >> > _________________________________________________________________
> >> > Get back to school stuff for them and cashback for you.
> >> >
> >>
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
> >> > oSchool_Cashback_BTSCashback_1x1
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >>
> >> _________________________________________________________________
> >> Hotmail® is up to 70% faster. Now good news travels really fast.
> >>
http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:W
> >> M_HYGN_faster:082009
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >
> > _________________________________________________________________
> > Get back to school stuff for them and cashback for you.
> >
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
oSchool_Cashback_BTSCashback_1x1 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

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

_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1

RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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="sessionFactory"><ref 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:mgainty@hotmail.com] 
Sent: 20 August 2009 13:32
To: Struts Users Mailing List
Subject: RE: Hibernate3+Spring2.5+Struts2


mg>take a look inside all of the provided xml files.. did you
mg>define a sessionFactory..alternatively implements
mg><property name="hibernate.properties">
mg>or mappingResources 
mg><property name="mappingResources">
mg>or mappingDirectoryLocations
mg><property name="mappingDirectoryLocations"/>

mg>a sessionFactory needs a dataSource jndiName something like
mg><value>java:comp/env/jdbc/dataSource</value>
mg>the sessionFactory refers to the datasource later on via property e.g.
mg><bean id=sessionFactory" class="...LocalSessionFactoryBean"/>
mg><property name="dataSource">
mg><ref bean="dataSource"/>
mg></property>
mg></bean>

mg>did you define a HibernateTemplate whose property name="sessionFactory"?

mg>do your DAO beans use the hibernateTemplate?
mg><bean id="someDAO" class="...someDaoHibernate">
mg><property name="hibernateTemplate">
mg>  <ref bean="hibernateTemplate">

mg>the hibernateTemplate statement find method is missing the type parameter
>     public User getUser(String userName) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.name = ?", userName).get(0);

mg>needs to change to 
mg>public User getUser(String userName) {

mg>return (User)getHibernateTemplate().find("from User as u where u.name =
?", mg>userName,Hibernate.STRING);


mg>also it is vital to maintain case-consistency for variable names as
mg>username!=userName!=USERNAME!=Username

mg>post back those xml files when you get the chance

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




> From: bejaouizied@hotmail.com
> To: user@struts.apache.org
> Subject: RE: Hibernate3+Spring2.5+Struts2
> Date: Thu, 20 Aug 2009 11:17:16 +0100
> 
> I still have the same exception, I am posting all my code amd my project
> structure hope you can fix me to fix the problem:
> 
> Package action:
> 
> package action;
> 
> import com.opensymphony.xwork2.ActionSupport;
> import java.util.Locale;
> import org.springframework.context.support.ResourceBundleMessageSource;
> import po.User;
> 
> import service.UserService;
> import service.UserServiceImp;
> /**
>  *
>  * @author ABIS1
>  */
> 
> public class LoginAction extends ActionSupport {
>     
>     private UserServiceImp userService;
>     private String message;
>     private String username;
>     private String password;
>     private ResourceBundleMessageSource messageSource;
> 
>     public LoginAction() {
>     }
> 
>     @Override
>     public String execute() throws Exception {
>        
>         
>         
>         User usr = userService.getUser(username);
>        
>         if(usr != null){
>             if(usr.getPassword().equals(password)){
>                 message = messageSource.getMessage("loginSuccess",
> null,Locale.UK);
>             }else{
>                 message = messageSource.getMessage("pswError",
> null,Locale.UK);
>             }
>         }else{
>             message = messageSource.getMessage("usrError",
> null,Locale.CHINA);          
>         }
>         return SUCCESS;
>     }
> 
>     public void setUserService(UserServiceImp userService) {
>         this.userService = userService;
>     }
> 
>     public String getMessage() {
>         return message;
>     }
> 
>     public void setMessage(String message) {
>         this.message = message;
>     }
> 
>     public String getUsername() {
>         return username;
>     }
> 
>     public void setUsername(String username) {
>         this.username = username;
>     }
> 
>     public String getPassword() {
>         return password;
>     }
> 
>     public void setPassword(String password) {
>         this.password = password;
>     }
> 
>     public void setMessageSource(ResourceBundleMessageSource
messageSource)
> {
>         this.messageSource = messageSource;
>     }
> 
> }
>
----------------------------------------------------------------------------
> ----------------------------------------------------------------------
> Package Dao:
> 
> package dao;
> import po.User;
> 
> 
> /**
>  *
>  * @author ABIS1
>  */
> public interface UserDao {
>     
>     void save(User user) throws Exception;
>     User getUser(long userId);
>     User getUser(String userName);
>     User getuser (String password);
> 
> }___________________________________________________________
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package dao;
> 
> import po.*;
> import dao.UserDao;
> import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
>     
>     public void save(User user) throws Exception
>     {
>         try
>         {
>             getHibernateTemplate().save(user);
>         }
>         catch(Exception err)
>         {
>             throw err;
>         }
> 
>     }   
> 
>     public User getUser(long userId)
>     {
>         return (User)getHibernateTemplate().get(User.class, userId);
>     } 
> 
>     public User getUser(String userName) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.name = ?", userName).get(0);
>     }
>     
>     public User getuser(String password) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.password = ?", password).get(0);
>     }
> 
> }
>
----------------------------------------------------------------------------
> --------------------------------------------------------------------
> Package service:
> 
> package service;
> import dao.UserDaoImpl;
> import po.User;
> /**
>  *
>  * @author ABIS1
>  */
> public interface UserService {
>     
>     void addUser(String userName, String password) throws Exception;
> 
>     User getUser(long userId);
>    
>     User getUser(String userName);
> 
>     void setUserDao(UserDaoImpl userDao);
> 
> }
> _____________________________________________________________________
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package service;
> import po.User;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class UserServiceImp implements UserService {
>     
>      private dao.UserDao userDao;
> 
>     public void addUser(String userName, String password) throws
Exception{
>         po.User user = new User();
>         
>          
>         user.setName(userName);
>         user.setPassword(password);
>         try
>         {
>             userDao.save(user);
>         }
>         catch(Exception err)
>         {
>             throw err;
>         }
>     }
>     public User getUser(long userId)
>     {
>         return userDao.getUser(userId);
>     }
> 
>     public void setUserDao(dao.UserDaoImpl userDao) {
>         this.userDao = userDao;
>     }
> 
>     public User getUser(String userName) {
>         return this.userDao.getUser(userName);
>     }
> 
> }
> 
> ----------------------------------------------------------------
> 
> Package PO:
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package po;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class User {
>     
>     private String Name; 
>     private long id;
>     private String password;
> //   private int admin;
> 
>     public String getName() {
>         return Name;
>     }
> 
>     public void setName(String Name) {
>         this.Name = Name;
>     }
> 
>     public long getId() {
>         return id;
>     }
> 
>     public void setId(long id) {
>         this.id = id;
>     }
> 
>     public String getPassword() {
>         return password;
>     }
> 
>     public void setPassword(String password) {
>         this.password = password;
>     }
>     
>   /*  public void setAdmin (int admin)
>     {this.admin=admin;}
>     
>     public int getAdmin ()
>     {return admin;}*/
>     
>   
>     
>     
> 
> }
> 
>
____________________________________________________________________________
> 
> User.hbm.xml under po:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping>
>   <class dynamic-insert="false" dynamic-update="false" mutable="true"
> name="po.User" optimistic-lock="version" polymorphism="implicit"
> select-before-update="false" table="user">
> <id column="userId" name="id">
>             <generator class="identity"/>
>         </id>
>         
>         <property column="userName" name="name" type="string"/>
>        
>         <property column="password" name="password" type="string"/>
>         </class>
> </hibernate-mapping>
> 
>
----------------------------------------------------------------------------
> -------------------------
> 
> My application context.xml: 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> "http://www.springframework.org/dtd/spring-beans.dtd">
> 
> <beans default-autowire="autodetect">
>     <!-- add your spring beans here -->
>     <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>         <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
>         <property name="username" value="root"/>
>         <property name="password" value=""/>
>     </bean>
>     <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>         <property name="dataSource" ref="dataSource"/>
>         <property name="mappingResources">
>             <list>
>                 <value>po/user.hbm.xml</value>
>             </list>
>         </property>
>         <property name="hibernateProperties">
>  
> <value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
>         </property>
>     </bean>
>     <bean id="userDao" class="dao.UserDaoImpl">
>         <property name="sessionFactory">
>             <ref bean="sessionFactory"></ref>
>         </property>
>     </bean> 
>     <bean id="userService" class="service.UserServiceImp">
>         <property name="userDao">
>             <ref bean="userDao"></ref>
>         </property>
>     </bean>
>     <bean id="messageSource"
> class="org.springframework.context.support.ResourceBundleMessageSource"> 
>         <property name="basename" value="messages" /> 
>     </bean>
> 
>     <bean id="loginAction" class="action.LoginAction">
>         <property name="userService">
>             <ref bean="userService"></ref>
>         </property>
>         <property name="messageSource" ref="messageSource"/>
>     </bean>
> </beans>
> 
> 
> Hope this can help.
>  
> 
> 
> 
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@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: wesw@wantii.com
> > To: user@struts.apache.org
> > 
> > On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> > >
> > > Are you using the Spring plugin?
> > >
> > > [snip]
> > 
> > 
> > Dave's right, make sure you have the spring plugin installed and that
> > you have spring's listener configured in your web.xml file
> > 
> > 
> > On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> _________________________________________________________________
> Get back to school stuff for them and cashback for you.
>
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
> oSchool_Cashback_BTSCashback_1x1
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® is up to 70% faster. Now good news travels really fast. 
http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:W
M_HYGN_faster:082009


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Martin Gainty <mg...@hotmail.com>.
mg>take a look inside all of the provided xml files.. did you
mg>define a sessionFactory..alternatively implements
mg><property name="hibernate.properties">
mg>or mappingResources 
mg><property name="mappingResources">
mg>or mappingDirectoryLocations
mg><property name="mappingDirectoryLocations"/>

mg>a sessionFactory needs a dataSource jndiName something like
mg><value>java:comp/env/jdbc/dataSource</value>
mg>the sessionFactory refers to the datasource later on via property e.g.
mg><bean id=sessionFactory" class="...LocalSessionFactoryBean"/>
mg><property name="dataSource">
mg><ref bean="dataSource"/>
mg></property>
mg></bean>

mg>did you define a HibernateTemplate whose property name="sessionFactory"?

mg>do your DAO beans use the hibernateTemplate?
mg><bean id="someDAO" class="...someDaoHibernate">
mg><property name="hibernateTemplate">
mg>  <ref bean="hibernateTemplate">

mg>the hibernateTemplate statement find method is missing the type parameter
>     public User getUser(String userName) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.name = ?", userName).get(0);

mg>needs to change to 
mg>public User getUser(String userName) {

mg>return (User)getHibernateTemplate().find("from User as u where u.name = ?", mg>userName,Hibernate.STRING);


mg>also it is vital to maintain case-consistency for variable names as
mg>username!=userName!=USERNAME!=Username

mg>post back those xml files when you get the chance

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




> From: bejaouizied@hotmail.com
> To: user@struts.apache.org
> Subject: RE: Hibernate3+Spring2.5+Struts2
> Date: Thu, 20 Aug 2009 11:17:16 +0100
> 
> I still have the same exception, I am posting all my code amd my project
> structure hope you can fix me to fix the problem:
> 
> Package action:
> 
> package action;
> 
> import com.opensymphony.xwork2.ActionSupport;
> import java.util.Locale;
> import org.springframework.context.support.ResourceBundleMessageSource;
> import po.User;
> 
> import service.UserService;
> import service.UserServiceImp;
> /**
>  *
>  * @author ABIS1
>  */
> 
> public class LoginAction extends ActionSupport {
>     
>     private UserServiceImp userService;
>     private String message;
>     private String username;
>     private String password;
>     private ResourceBundleMessageSource messageSource;
> 
>     public LoginAction() {
>     }
> 
>     @Override
>     public String execute() throws Exception {
>        
>         
>         
>         User usr = userService.getUser(username);
>        
>         if(usr != null){
>             if(usr.getPassword().equals(password)){
>                 message = messageSource.getMessage("loginSuccess",
> null,Locale.UK);
>             }else{
>                 message = messageSource.getMessage("pswError",
> null,Locale.UK);
>             }
>         }else{
>             message = messageSource.getMessage("usrError",
> null,Locale.CHINA);          
>         }
>         return SUCCESS;
>     }
> 
>     public void setUserService(UserServiceImp userService) {
>         this.userService = userService;
>     }
> 
>     public String getMessage() {
>         return message;
>     }
> 
>     public void setMessage(String message) {
>         this.message = message;
>     }
> 
>     public String getUsername() {
>         return username;
>     }
> 
>     public void setUsername(String username) {
>         this.username = username;
>     }
> 
>     public String getPassword() {
>         return password;
>     }
> 
>     public void setPassword(String password) {
>         this.password = password;
>     }
> 
>     public void setMessageSource(ResourceBundleMessageSource messageSource)
> {
>         this.messageSource = messageSource;
>     }
> 
> }
> ----------------------------------------------------------------------------
> ----------------------------------------------------------------------
> Package Dao:
> 
> package dao;
> import po.User;
> 
> 
> /**
>  *
>  * @author ABIS1
>  */
> public interface UserDao {
>     
>     void save(User user) throws Exception;
>     User getUser(long userId);
>     User getUser(String userName);
>     User getuser (String password);
> 
> }___________________________________________________________
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package dao;
> 
> import po.*;
> import dao.UserDao;
> import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
>     
>     public void save(User user) throws Exception
>     {
>         try
>         {
>             getHibernateTemplate().save(user);
>         }
>         catch(Exception err)
>         {
>             throw err;
>         }
> 
>     }   
> 
>     public User getUser(long userId)
>     {
>         return (User)getHibernateTemplate().get(User.class, userId);
>     } 
> 
>     public User getUser(String userName) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.name = ?", userName).get(0);
>     }
>     
>     public User getuser(String password) {
>         return (User)getHibernateTemplate().find("from User as u where
> u.password = ?", password).get(0);
>     }
> 
> }
> ----------------------------------------------------------------------------
> --------------------------------------------------------------------
> Package service:
> 
> package service;
> import dao.UserDaoImpl;
> import po.User;
> /**
>  *
>  * @author ABIS1
>  */
> public interface UserService {
>     
>     void addUser(String userName, String password) throws Exception;
> 
>     User getUser(long userId);
>    
>     User getUser(String userName);
> 
>     void setUserDao(UserDaoImpl userDao);
> 
> }
> _____________________________________________________________________
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package service;
> import po.User;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class UserServiceImp implements UserService {
>     
>      private dao.UserDao userDao;
> 
>     public void addUser(String userName, String password) throws Exception{
>         po.User user = new User();
>         
>          
>         user.setName(userName);
>         user.setPassword(password);
>         try
>         {
>             userDao.save(user);
>         }
>         catch(Exception err)
>         {
>             throw err;
>         }
>     }
>     public User getUser(long userId)
>     {
>         return userDao.getUser(userId);
>     }
> 
>     public void setUserDao(dao.UserDaoImpl userDao) {
>         this.userDao = userDao;
>     }
> 
>     public User getUser(String userName) {
>         return this.userDao.getUser(userName);
>     }
> 
> }
> 
> ----------------------------------------------------------------
> 
> Package PO:
> 
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> 
> package po;
> 
> /**
>  *
>  * @author ABIS1
>  */
> public class User {
>     
>     private String Name; 
>     private long id;
>     private String password;
> //   private int admin;
> 
>     public String getName() {
>         return Name;
>     }
> 
>     public void setName(String Name) {
>         this.Name = Name;
>     }
> 
>     public long getId() {
>         return id;
>     }
> 
>     public void setId(long id) {
>         this.id = id;
>     }
> 
>     public String getPassword() {
>         return password;
>     }
> 
>     public void setPassword(String password) {
>         this.password = password;
>     }
>     
>   /*  public void setAdmin (int admin)
>     {this.admin=admin;}
>     
>     public int getAdmin ()
>     {return admin;}*/
>     
>   
>     
>     
> 
> }
> 
> ____________________________________________________________________________
> 
> User.hbm.xml under po:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping>
>   <class dynamic-insert="false" dynamic-update="false" mutable="true"
> name="po.User" optimistic-lock="version" polymorphism="implicit"
> select-before-update="false" table="user">
> <id column="userId" name="id">
>             <generator class="identity"/>
>         </id>
>         
>         <property column="userName" name="name" type="string"/>
>        
>         <property column="password" name="password" type="string"/>
>         </class>
> </hibernate-mapping>
> 
> ----------------------------------------------------------------------------
> -------------------------
> 
> My application context.xml: 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> "http://www.springframework.org/dtd/spring-beans.dtd">
> 
> <beans default-autowire="autodetect">
>     <!-- add your spring beans here -->
>     <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>         <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
>         <property name="username" value="root"/>
>         <property name="password" value=""/>
>     </bean>
>     <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>         <property name="dataSource" ref="dataSource"/>
>         <property name="mappingResources">
>             <list>
>                 <value>po/user.hbm.xml</value>
>             </list>
>         </property>
>         <property name="hibernateProperties">
>  
> <value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
>         </property>
>     </bean>
>     <bean id="userDao" class="dao.UserDaoImpl">
>         <property name="sessionFactory">
>             <ref bean="sessionFactory"></ref>
>         </property>
>     </bean> 
>     <bean id="userService" class="service.UserServiceImp">
>         <property name="userDao">
>             <ref bean="userDao"></ref>
>         </property>
>     </bean>
>     <bean id="messageSource"
> class="org.springframework.context.support.ResourceBundleMessageSource"> 
>         <property name="basename" value="messages" /> 
>     </bean>
> 
>     <bean id="loginAction" class="action.LoginAction">
>         <property name="userService">
>             <ref bean="userService"></ref>
>         </property>
>         <property name="messageSource" ref="messageSource"/>
>     </bean>
> </beans>
> 
> 
> Hope this can help.
>  
> 
> 
> 
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@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: wesw@wantii.com
> > To: user@struts.apache.org
> > 
> > On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> > >
> > > Are you using the Spring plugin?
> > >
> > > [snip]
> > 
> > 
> > Dave's right, make sure you have the spring plugin installed and that
> > you have spring's listener configured in your web.xml file
> > 
> > 
> > On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> _________________________________________________________________
> Get back to school stuff for them and cashback for you.
> http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
> oSchool_Cashback_BTSCashback_1x1
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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

Posted by Zied Bejaoui <be...@hotmail.com>.
I still have the same exception, I am posting all my code amd my project
structure hope you can fix me to fix the problem:

Package action:

package action;

import com.opensymphony.xwork2.ActionSupport;
import java.util.Locale;
import org.springframework.context.support.ResourceBundleMessageSource;
import po.User;

import service.UserService;
import service.UserServiceImp;
/**
 *
 * @author ABIS1
 */

public class LoginAction extends ActionSupport {
    
    private UserServiceImp userService;
    private String message;
    private String username;
    private String password;
    private ResourceBundleMessageSource messageSource;

    public LoginAction() {
    }

    @Override
    public String execute() throws Exception {
       
        
        
        User usr = userService.getUser(username);
       
        if(usr != null){
            if(usr.getPassword().equals(password)){
                message = messageSource.getMessage("loginSuccess",
null,Locale.UK);
            }else{
                message = messageSource.getMessage("pswError",
null,Locale.UK);
            }
        }else{
            message = messageSource.getMessage("usrError",
null,Locale.CHINA);          
        }
        return SUCCESS;
    }

    public void setUserService(UserServiceImp userService) {
        this.userService = userService;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setMessageSource(ResourceBundleMessageSource messageSource)
{
        this.messageSource = messageSource;
    }

}
----------------------------------------------------------------------------
----------------------------------------------------------------------
Package Dao:

package dao;
import po.User;


/**
 *
 * @author ABIS1
 */
public interface UserDao {
    
    void save(User user) throws Exception;
    User getUser(long userId);
    User getUser(String userName);
    User getuser (String password);

}___________________________________________________________

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao;

import po.*;
import dao.UserDao;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 * @author ABIS1
 */
public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
    
    public void save(User user) throws Exception
    {
        try
        {
            getHibernateTemplate().save(user);
        }
        catch(Exception err)
        {
            throw err;
        }

    }   

    public User getUser(long userId)
    {
        return (User)getHibernateTemplate().get(User.class, userId);
    } 

    public User getUser(String userName) {
        return (User)getHibernateTemplate().find("from User as u where
u.name = ?", userName).get(0);
    }
    
    public User getuser(String password) {
        return (User)getHibernateTemplate().find("from User as u where
u.password = ?", password).get(0);
    }

}
----------------------------------------------------------------------------
--------------------------------------------------------------------
Package service:

package service;
import dao.UserDaoImpl;
import po.User;
/**
 *
 * @author ABIS1
 */
public interface UserService {
    
    void addUser(String userName, String password) throws Exception;

    User getUser(long userId);
   
    User getUser(String userName);

    void setUserDao(UserDaoImpl userDao);

}
_____________________________________________________________________

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package service;
import po.User;

/**
 *
 * @author ABIS1
 */
public class UserServiceImp implements UserService {
    
     private dao.UserDao userDao;

    public void addUser(String userName, String password) throws Exception{
        po.User user = new User();
        
         
        user.setName(userName);
        user.setPassword(password);
        try
        {
            userDao.save(user);
        }
        catch(Exception err)
        {
            throw err;
        }
    }
    public User getUser(long userId)
    {
        return userDao.getUser(userId);
    }

    public void setUserDao(dao.UserDaoImpl userDao) {
        this.userDao = userDao;
    }

    public User getUser(String userName) {
        return this.userDao.getUser(userName);
    }

}

----------------------------------------------------------------

Package PO:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package po;

/**
 *
 * @author ABIS1
 */
public class User {
    
    private String Name; 
    private long id;
    private String password;
//   private int admin;

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
  /*  public void setAdmin (int admin)
    {this.admin=admin;}
    
    public int getAdmin ()
    {return admin;}*/
    
  
    
    

}

____________________________________________________________________________

User.hbm.xml under po:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class dynamic-insert="false" dynamic-update="false" mutable="true"
name="po.User" optimistic-lock="version" polymorphism="implicit"
select-before-update="false" table="user">
<id column="userId" name="id">
            <generator class="identity"/>
        </id>
        
        <property column="userName" name="name" type="string"/>
       
        <property column="password" name="password" type="string"/>
        </class>
</hibernate-mapping>

----------------------------------------------------------------------------
-------------------------

My application context.xml: 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="autodetect">
    <!-- add your spring beans here -->
    <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/sshdemo"/>
        <property name="username" value="root"/>
        <property name="password" value=""/>
    </bean>
    <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
            <list>
                <value>po/user.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
 
<value>hibernate.dialect=org.hibernate.dialect.MySQLDialect</value>
        </property>
    </bean>
    <bean id="userDao" class="dao.UserDaoImpl">
        <property name="sessionFactory">
            <ref bean="sessionFactory"></ref>
        </property>
    </bean> 
    <bean id="userService" class="service.UserServiceImp">
        <property name="userDao">
            <ref bean="userDao"></ref>
        </property>
    </bean>
    <bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource"> 
        <property name="basename" value="messages" /> 
    </bean>

    <bean id="loginAction" class="action.LoginAction">
        <property name="userService">
            <ref bean="userService"></ref>
        </property>
        <property name="messageSource" ref="messageSource"/>
    </bean>
</beans>


Hope this can help.
 



-----Original Message-----
From: Martin Gainty [mailto:mgainty@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: wesw@wantii.com
> To: user@struts.apache.org
> 
> On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> >
> > Are you using the Spring plugin?
> >
> > [snip]
> 
> 
> Dave's right, make sure you have the spring plugin installed and that
> you have spring's listener configured in your web.xml file
> 
> 
> On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackT
oSchool_Cashback_BTSCashback_1x1


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Martin Gainty <mg...@hotmail.com>.
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: wesw@wantii.com
> To: user@struts.apache.org
> 
> On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> >
> > Are you using the Spring plugin?
> >
> > [snip]
> 
> 
> Dave's right, make sure you have the spring plugin installed and that
> you have spring's listener configured in your web.xml file
> 
> 
> On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1

RE: Hibernate3+Spring2.5+Struts2

Posted by bejaoui zied <be...@hotmail.com>.
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: wesw@wantii.com
> To: user@struts.apache.org
> 
> On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
> >
> > Are you using the Spring plugin?
> >
> > [snip]
> 
> 
> Dave's right, make sure you have the spring plugin installed and that
> you have spring's listener configured in your web.xml file
> 
> 
> On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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

Posted by Wes Wannemacher <we...@wantii.com>.
On Wed, Aug 19, 2009 at 1:07 PM, Dave Newton<ne...@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 <be...@hotmail.com>
>
> Are you using the Spring plugin?
>
> [snip]


Dave's right, make sure you have the spring plugin installed and that
you have spring's listener configured in your web.xml file


On Wed, Aug 19, 2009 at 1:07 PM, Martin Gainty<mg...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Dave Newton <ne...@yahoo.com>.
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 <be...@hotmail.com>

Are you using the Spring plugin?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Tommy Pham <to...@yahoo.com>.




----- Original Message ----
> From: ZiedBejaoui <be...@hotmail.com>
> To: Struts Users Mailing List <us...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by ZiedBejaoui <be...@hotmail.com>.
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" <to...@yahoo.com>
Sent: Wednesday, August 19, 2009 4:59 PM
To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Re: Hibernate3+Spring2.5+Struts2

>
>
>
>
>
> ----- Original Message ----
>> From: Dave Newton <ne...@yahoo.com>
>> To: Struts Users Mailing List <us...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Tommy Pham <to...@yahoo.com>.




----- Original Message ----
> From: Dave Newton <ne...@yahoo.com>
> To: Struts Users Mailing List <us...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Dave Newton <ne...@yahoo.com>.
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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by ZiedBejaoui <be...@hotmail.com>.
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" <ne...@yahoo.com>
Sent: Wednesday, August 19, 2009 4:18 PM
To: "Struts Users Mailing List" <us...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Dave Newton <ne...@yahoo.com>.
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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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.dave@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:nilsga@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<be...@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.lenart@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Dave Newton <ne...@yahoo.com>.
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:nilsga@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<be...@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.lenart@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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:nilsga@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<be...@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.lenart@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
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<be...@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(DefaultActionInvocation.java:404)
>        at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
>        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
>        at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
>        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
>        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 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
>        at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
>        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
>        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 com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
>        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 com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
>        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
>        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 com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
>        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.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
>        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.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
>        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 com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
>        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 com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
>        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.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
>        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.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
>        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 com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
>        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 com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
>        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 com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
>        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
>        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.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
>        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 com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
>        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 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.lenart@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Hibernate3+Spring2.5+Struts2

Posted by Zied Bejaoui <be...@hotmail.com>.
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(DefaultActionInvocation.java:404)
        at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
        at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
        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 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
        at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
        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 com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
        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 com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
        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 com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
        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.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
        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.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
        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 com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
        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 com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
        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.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
        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.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
        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 com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
        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 com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
        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 com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
        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.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
        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 com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
        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 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.lenart@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate3+Spring2.5+Struts2

Posted by Lukasz Lenart <lu...@googlemail.com>.
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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org