Hello,
I am running Hibernate 2.1.1, Struts, and MySQL 1.4 database for my web application.
Here is a little piece of the Struts-config.xml file:
<action
path="/login"
type="com.tjgrp.guava.timesheet.LoginAction"
scope="request"
name="loginForm"
input="/login.jsp">
<forward name="success" path="/Welcome.jsp" redirect="true" />
<forward name="failure" path="/login.jsp" redirect="true" />
</action>
The problem I am having is that somehow 'success' never happens. (I deployed the application and checked). It also seems that in the Action class (loginAction) , something is not working as it should. Could you tell me what I am doing wrong?
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = null;
LoginForm loginform = (LoginForm) form;
String password = loginform.getPassword();
String identifier = loginform.getIdentifier();
try {
Context ctx = new InitialContext();
SessionFactory sf = (SessionFactory) ctx.lookup(
"guava:/hibernate/SessionFactory");
Session session = sessionFactory.openSession();
String query =
"select guavauser from com.tjgrp.guava.data.GuavaUser guavauser " +
"where guavauser.password = :password and " +
"guavauser.identifier = :identifier";
Query q = session.createQuery(query);
q.setParameter("identifier", identifier, Hibernate.STRING);
q.setParameter("password", password, Hibernate.STRING);
GuavaUser gUser = (GuavaUser) q.uniqueResult();
request.setAttribute("objId", gUser);
forward = mapping.findForward("success");
loginform.clear();
session.close();
} catch (NamingException e) {
System.err.println("Naming Exception" + e.getMessage());
throw new RuntimeException(e);
} catch (HibernateException e) {
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
} finally {
return forward;
}
}
Here is the stack trace:
----------------------------
INFO: Installing web application at context path /build from URL file:C:\Apache Software\Tomcat 5.0\webapps\build
14:30:03,171 INFO Environment:432 - Hibernate 2.1.1
14:30:03,187 INFO Environment:461 - hibernate.properties not found
14:30:03,187 INFO Environment:481 - using CGLIB reflection optimizer
14:30:03,203 INFO Configuration:843 - configuring from resource: /hibernate.cfg.xml
14:30:03,203 INFO Configuration:815 - Configuration resource: /hibernate.cfg.xml
14:30:03,343 DEBUG DTDEntityResolver:20 - trying to locate
http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
14:30:03,468 DEBUG DTDEntityResolver:29 - found
http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath
14:30:03,562 DEBUG Configuration:801 - dialect=net.sf.hibernate.dialect.MySQLDialect
14:30:03,578 DEBUG Configuration:801 - connection.username=root
14:30:03,578 DEBUG Configuration:801 - connection.password=
14:30:03,578 DEBUG Configuration:801 - connection.url=jdbc:mysql:///guava
14:30:03,578 DEBUG Configuration:801 - connection.driver_class=com.mysql.jdbc.Driver
14:30:03,578 DEBUG Configuration:801 - show_sql=true
14:30:03,578 DEBUG Configuration:801 - use_outer_join=true
14:30:03,578 DEBUG Configuration:801 - transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory
14:30:03,593 DEBUG Configuration:801 - dbcp.minIdle=1
14:30:03,593 DEBUG Configuration:801 - cache.use_query_cache=true
14:30:03,593 DEBUG Configuration:952 - guava:/hibernate/SessionFactory<-org.dom4j.tree.DefaultAttribute@873723 [Attribute: name resource value "com/tjgrp/guava/data/GuavaUser.hbm.xml"]
14:30:03,593 INFO Configuration:300 - Mapping resource: com/tjgrp/guava/data/GuavaUser.hbm.xml
14:30:03,640 DEBUG DTDEntityResolver:20 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
14:30:03,640 DEBUG DTDEntityResolver:29 - found
http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
14:30:03,828 INFO Binder:225 - Mapping class: com.tjgrp.guava.data.GuavaUser -> guavauser
14:30:04,015 DEBUG Binder:449 - Mapped property: objId -> objId, type: long
14:30:04,062 DEBUG Binder:449 - Mapped property: identifier -> identifier, type: string
14:30:04,062 DEBUG Binder:449 - Mapped property: password -> password, type: string
14:30:04,062 DEBUG Binder:449 - Mapped property: firstName -> firstName, type: string
14:30:04,062 DEBUG Binder:449 - Mapped property: lastName -> lastName, type: string
14:30:04,062 INFO Configuration:998 - Configured SessionFactory: guava:/hibernate/SessionFactory
14:30:04,078 DEBUG Configuration:999 - properties: {show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=C:\Apache Software\Tomcat 5.0, hibernate.connection.url=jdbc:mysql:///guava, catalina.useNaming=true, os.name=Windows XP, sun.boot.class.path=C:\Apache Software\Tomcat 5.0\common\endorsed\xercesImpl.jar;C:\Apache Software\Tomcat 5.0\common\endorsed\xmlParserAPIs.jar;C:\Program Files\Java\j2re1.4.2_03\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_03\lib\i18n.jar;C:\Program Files\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_03\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_03\classes, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_03-b02, user.name=SYSTEM, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, hibernate.session_factory_name=guava:/hibernate/SessionFactory, connection.driver_class=com.mysql.jdbc.Driver, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=C:\Program Files\Java\j2re1.4.2_03\bin, dialect=net.sf.hibernate.dialect.MySQLDialect, java.version=1.4.2_03, user.timezone=America/New_York, sun.arch.data.model=32, hibernate.use_outer_join=true, java.endorsed.dirs=C:\Apache Software\Tomcat 5.0\common\endorsed, sun.cpu.isalist=pentium i486 i386, file.encoding.pkg=sun.io, cache.use_query_cache=true, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=48.0, hibernate.dbcp.minIdle=1, user.country=US, connection.url=jdbc:mysql:///guava, java.home=C:\Program Files\Java\j2re1.4.2_03, java.vm.info=mixed mode, os.version=5.1, transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, path.separator=;, connection.password=, java.vm.version=1.4.2_03-b02, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, hibernate.connection.password=, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=root, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., java.naming.factory.url.pkgs=org.apache.naming, user.home=C:\WINDOWS\system32\config\systemprofile, java.specification.vendor=Sun Microsystems Inc., java.library.path=C:\Program Files\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\System32;C:\j2sdk1.4.2_03\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, connection.username=root, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, common.loader=${catalina.home}/common/classes,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\Apache Software\Tomcat 5.0\bin\bootstrap.jar, use_outer_join=true, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=C:\Apache Software\Tomcat 5.0, hibernate.cache.use_query_cache=true, sun.cpu.endian=little, sun.os.patch.level=Service Pack 1, java.io.tmpdir=C:\WINDOWS\TEMP\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\ext, user.dir=C:\Apache Software\Tomcat 5.0, dbcp.minIdle=1, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, file.encoding=Cp1252, java.specification.version=1.4, hibernate.show_sql=true}
14:30:04,078 INFO Configuration:584 - processing one-to-many association mappings
14:30:04,093 INFO Configuration:593 - processing one-to-one association property references
14:30:04,093 INFO Configuration:618 - processing foreign key constraints
14:30:04,156 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
14:30:04,156 INFO SettingsFactory:62 - Use outer join fetching: true
14:30:04,171 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
14:30:04,171 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
14:30:04,187 INFO DriverManagerConnectionProvider:71 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///guava
14:30:04,187 INFO DriverManagerConnectionProvider:72 - connection properties: {user=root, password=}
14:30:04,203 INFO TransactionFactoryFactory:31 - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
14:30:04,218 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
14:30:04,218 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
14:30:04,218 DEBUG DriverManagerConnectionProvider:94 - opening new JDBC connection
14:30:04,515 DEBUG DriverManagerConnectionProvider:100 - created connection to: jdbc:mysql:///guava, Isolation Level: 4
14:30:04,515 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
14:30:04,531 INFO SettingsFactory:89 - Use scrollable result sets: true
14:30:04,531 INFO SettingsFactory:90 - JDBC 2 max batch size: 15
14:30:04,531 INFO SettingsFactory:96 - echoing all SQL to stdout
14:30:04,531 INFO SettingsFactory:99 - Query language substitutions: {}
14:30:04,531 INFO SettingsFactory:110 - cache provider: net.sf.ehcache.hibernate.Provider
14:30:04,546 INFO Configuration:1057 - instantiating and configuring caches
14:30:04,890 INFO SessionFactoryImpl:119 - building session factory
14:30:04,890 DEBUG SessionFactoryImpl:125 - instantiating session factory with properties: {show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=C:\Apache Software\Tomcat 5.0, hibernate.connection.url=jdbc:mysql:///guava, catalina.useNaming=true, os.name=Windows XP, sun.boot.class.path=C:\Apache Software\Tomcat 5.0\common\endorsed\xercesImpl.jar;C:\Apache Software\Tomcat 5.0\common\endorsed\xmlParserAPIs.jar;C:\Program Files\Java\j2re1.4.2_03\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_03\lib\i18n.jar;C:\Program Files\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_03\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_03\classes, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_03-b02, user.name=SYSTEM, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, hibernate.session_factory_name=guava:/hibernate/SessionFactory, connection.driver_class=com.mysql.jdbc.Driver, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=C:\Program Files\Java\j2re1.4.2_03\bin, dialect=net.sf.hibernate.dialect.MySQLDialect, java.version=1.4.2_03, user.timezone=America/New_York, sun.arch.data.model=32, hibernate.use_outer_join=true, java.endorsed.dirs=C:\Apache Software\Tomcat 5.0\common\endorsed, sun.cpu.isalist=pentium i486 i386, file.encoding.pkg=sun.io, cache.use_query_cache=true, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=48.0, hibernate.dbcp.minIdle=1, user.country=US, connection.url=jdbc:mysql:///guava, java.home=C:\Program Files\Java\j2re1.4.2_03, java.vm.info=mixed mode, os.version=5.1, transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, path.separator=;, connection.password=, java.vm.version=1.4.2_03-b02, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, hibernate.connection.password=, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=root, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., java.naming.factory.url.pkgs=org.apache.naming, user.home=C:\WINDOWS\system32\config\systemprofile, java.specification.vendor=Sun Microsystems Inc., java.library.path=C:\Program Files\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\System32;C:\j2sdk1.4.2_03\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, connection.username=root, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, common.loader=${catalina.home}/common/classes,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\Apache Software\Tomcat 5.0\bin\bootstrap.jar, use_outer_join=true, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=C:\Apache Software\Tomcat 5.0, hibernate.cache.use_query_cache=true, sun.cpu.endian=little, sun.os.patch.level=Service Pack 1, java.io.tmpdir=C:\WINDOWS\TEMP\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\ext, user.dir=C:\Apache Software\Tomcat 5.0, dbcp.minIdle=1, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, file.encoding=Cp1252, java.specification.version=1.4, hibernate.show_sql=true}
14:30:06,265 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
14:30:06,281 DEBUG SessionFactoryObjectFactory:76 - registered: 981cb4a1fb175a9800fb175a9f2a0000 (guava:/hibernate/SessionFactory)
14:30:06,281 INFO SessionFactoryObjectFactory:86 - Factory name: guava:/hibernate/SessionFactory
14:30:06,281 INFO NamingHelper:26 - JNDI InitialContext properties:{}
14:30:06,281 DEBUG NamingHelper:48 - binding: guava:/hibernate/SessionFactory
14:30:06,296 DEBUG NamingHelper:58 - lookup: guava:
14:30:06,296 INFO NamingHelper:68 - Creating subcontext: guava:
14:30:06,296 DEBUG NamingHelper:58 - lookup: hibernate
14:30:06,296 INFO NamingHelper:68 - Creating subcontext: hibernate
14:30:06,296 DEBUG NamingHelper:73 - binding: SessionFactory
14:30:06,296 DEBUG SessionFactoryImpl:381 - Returning a Reference to the SessionFactory
14:30:06,312 DEBUG NamingHelper:76 - Bound name: guava:/hibernate/SessionFactory
14:30:06,312 INFO SessionFactoryObjectFactory:91 - Bound factory to JNDI name: guava:/hibernate/SessionFactory
14:30:06,312 WARN SessionFactoryObjectFactory:101 - InitialContext did not implement EventContext
14:30:06,312 DEBUG SessionFactoryImpl:196 - instantiated session factory
14:30:06,312 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
14:30:06,406 WARN Configurator:123 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: file:/C:/Apache Software/Tomcat 5.0/work/Catalina/localhost/build/loader/ehcache-failsafe.xml
14:30:06,421 WARN Plugin:95 - Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.
14:30:06,718 INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache
14:30:06,718 WARN Plugin:95 - Could not find configuration for net.sf.hibernate.cache.QueryCache. Configuring using the defaultCache settings.
Could the warning I am getting at the end be the problem?
Some feedback is really appreciated..