Bog*_*dan 5 java java-ee ejb-3.1 glassfish-3
假设我有一个看起来像这样的拦截器:
public class AuthorizationInterceptor {
Logger log = Logger.getLogger(getClass().getName());
@AroundInvoke
private Object authorize(InvocationContext ic) throws Exception{
// ... some other logic for authorization
if (!allowedMethods.contains(ic.getMethod().getName())){
log.info("Authorization failed. Preparing to throw exception");
throw new AuthException("Authorization failed for method " +
ic.getMethod().getName());
}
return ic.proceed();
}
}
Run Code Online (Sandbox Code Playgroud)
这适用于我的EJB的不同方法.
我通常希望将异常throed传递给调用客户端,就像所有正常的EJB异常一样.
显然,如果我从Interceptor中抛出它,就不会发生这种情况......它甚至没有记录在服务器上; 喜欢它永远不会抛出,但它是 - 从不执行return语句.
我究竟做错了什么?
我正在使用GF 3.0.1
这里有一些可以尝试的事情:
1. Check that the authorize(...) method is called.
2. Try making the authorize(...) method public instead of private.
3. Check that the EJB has an annotation like this:
@Interceptors(AuthorizationInterceptor.class)
Run Code Online (Sandbox Code Playgroud)