java - Exception handling in Struts 2 and Hibernate -



java - Exception handling in Struts 2 and Hibernate -

suppose have developed website in struts2, hibernate, mysql , have added few try/catch blocks here there encloses database calls via hibernate. question is

inside grab block sending appropriate message logger. here can't utilize system.out.println webpage, else can done alert user exception?

as part of testing changed hibernate.cfg.xml , input wrong database password simulate database crash scenario.

as expected threw error

javax.servlet.servletexception: filter execution threw exception java.lang.noclassdeffounderror: com_cenqua_clover/coveragerecorder my.com.employee.<init>(employee.java:29) com.action.employeeaction.<init>(employeeaction.java:23) sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) java.lang.reflect.constructor.newinstance(constructor.java:513) java.lang.class.newinstance0(class.java:355) java.lang.class.newinstance(class.java:308) com.opensymphony.xwork2.objectfactory.buildbean(objectfactory.java:119) com.opensymphony.xwork2.objectfactory.buildbean(objectfactory.java:150) com.opensymphony.xwork2.objectfactory.buildbean(objectfactory.java:139) com.opensymphony.xwork2.objectfactory.buildaction(objectfactory.java:109) com.opensymphony.xwork2.defaultactioninvocation.createaction(defaultactioninvocation.java:288) com.opensymphony.xwork2.defaultactioninvocation.init(defaultactioninvocation.java:388) com.opensymphony.xwork2.defaultactionproxy.prepare(defaultactionproxy.java:187) org.apache.struts2.impl.strutsactionproxy.prepare(strutsactionproxy.java:61) org.apache.struts2.impl.strutsactionproxyfactory.createactionproxy(strutsactionproxyfactory.java:39) com.opensymphony.xwork2.defaultactionproxyfactory.createactionproxy(defaultactionproxyfactory.java:47) org.apache.struts2.dispatcher.dispatcher.serviceaction(dispatcher.java:478) org.apache.struts2.dispatcher.filterdispatcher.dofilter(filterdispatcher.java:395) note total stack trace of root cause available in apache tomcat/7.0.20 logs.

and users perspective not desirable right, how tackle such problems. using eclipse juno, windows xp, mysql 5.5.

the user doesn't need know there database exception, developer does.

the specific exception should logged. user should see operation failed. you'd either study through normal s2 means, e.g., error message.

you may throw application-specific exception , utilize s2's declarative exception handling.

you may utilize declarative exception handling handle or low-level exceptions, imo that's either general, or tedious.

java hibernate exception exception-handling struts2

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -