java - How to hide RuntimeException details from EJB client? -


I have a JEE5 application that exposes the services using (local) session beans.

happens during service execution, a RuntimeException is thrown in a javax.ejb.EJBTransactionRolledbackException and explained by JBoss (5.0.1).

The problem is that customers can access detailed information about the order due to the applications received by this EJBTransactionRolledbackException, highlighting the internal structure of your application and I do not want to do so.

Instead, I would have always jeopardized runtime exposure displayed in the same (and simple) technical exception (without any reason).

> What is the best way to achieve this? (Based on the previous answer and my personal research, I use the JBoss configuration (using the interceptor)?)

Public class FaultBarrierInterceptor {@AroundInvoke throws exception exception, Public Invocation (Last Invitation InvocationContext) Exception:

{Try {return invocationContext.proceed ( ); } Hold (Last Runtime Exception e) {Last Logger Logger = Logger. Gate Logger (invocationContext.getMethod (). GetDeclaringClass ()); Logger.error ("A mistake occurred during service charge:" + \ \ n-METHOD: "+ invocationContext.getMethod () +" \ n-PARAMS: + Arrays.toString (invocationContext.getParameters ()), e) ; Throw new technical feedback (); Throwing technical exception provides EJBException and does not disclose RuntimeException due to the reason:

  Public class TechnicalException extends EJBException {}  

I use this interceptor in all public services:

  @Stateless @Interceptors ({FaultBarrierInterceptor.class}) public class ShoppingCardServicesBean ShoppingCardServices {...   

This is an implementation.

Any runtime exception is captured, logged and using a technical exception, the client (without internal details) is mistaken. The checked exceptions are ignored.

RuntimeException handling is centralized and different from any business methods.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -