jpa - How to stop handled Exceptions from being logged? -


i have implemented exception handling unique-constraint of jpa entity. working want to, when triggered dumps handled exceptions container logfile.

  • a jpa entity managed slsb (service façade). service façade called slsb, provides remoting capabilities based on jax-rs.
  • in service façade, entitymanager operations wrapped in try-catch-block, detecting cause of unique-constraint-violation. throws custom checked applicationexception.
  • the rest-bean catches applicationexception , throws custom unchecked badrequestexception.
  • an exceptionmapper outputs badrequestexception remote client.

this working well. part don't understand is: (handled) exceptions logged in container's logfile (complete long stacktrace):

[#|2010-09-29t18:49:39.185+0200|warning|glassfish3.0.1|org.eclipse.persistence.session.file:/users/hank/netbeansprojects/coreserver/build/classes/_coreserverpersistenceunit|_threadid=30;_threadname=thread-1;| local exception stack:  exception [eclipselink-4002] (eclipse persistence services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.databaseexception internal exception: com.mysql.jdbc.exceptions.jdbc4.mysqlintegrityconstraintviolationexception: duplicate entry.... .... caused by: com.mysql.jdbc.exceptions.jdbc4.mysqlintegrityconstraintviolationexception: duplicate entry.... 

and throwing badrequestexception:

[#|2010-09-29t18:49:39.336+0200|warning|glassfish3.0.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_threadid=30;_threadname=thread-1;|a system exception occurred during invocation on ejb shopperresource method public javax.ws.rs.core.response mvs.gateway.shopperresource.create(javax.xml.bind.jaxbelement) javax.ejb.ejbexception @ com.sun.ejb.containers.basecontainer.processsystemexception(basecontainer.java:5119) .... caused by: mvs.api.exception.badrequestexception: mvs.api.exception.mvscause: field 'msisdn' must unique! 

is how should be? thought since handle exceptions, wouldn't dumped log?

the exceptions logged because have exception logging enabled.

exceptions logged default when log level warning or greater. if set log level severe or off not logged.

i.e. "eclipselink.logging.level"="severe"

you can set "eclipselink.logging.exceptions"="false" property disable exception logging.

see, http://wiki.eclipse.org/eclipselink/examples/jpa/logging


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -