小编xxx*_*xxx的帖子

EJB在PreProcessInterceptor中为null

我在JBoss AS 7.1.1环境中使用RestEasy.

我出于安全原因实现了一个PreProcessInterceptor类.该类使用@Provider和@ServerInterceptor进行注释.每次都会调用拦截器,这很好.

现在,困扰我的是以下几点.

我将带有@EJB注释的EJB注入到类中.调用PreProcessInterceptor时,表示EJB始终为null.

@Provider
@ServerInterceptor
public class SecurityInterceptor implements PreProcessInterceptor
{
    @EJB
    private SomeEjb someEjbServiceFacade;

    ... some funny stuff
}
Run Code Online (Sandbox Code Playgroud)

EJB看起来像是:

@Stateless
public class SomeEjb extends AbstractServiceFacade
{
    ... some important stuff
}
Run Code Online (Sandbox Code Playgroud)

有趣的部分,它通过查找工作:

Context ctx = new InitialContext();
SomeEjb asf = ( SomeEjb )ctx.lookup("java:global/mySuperApplication/SomeEjb" );
Run Code Online (Sandbox Code Playgroud)

有人对此行为有解释吗?

提前致谢.

java jboss ejb java-ee interceptor

5
推荐指数
1
解决办法
457
查看次数

标签 统计

ejb ×1

interceptor ×1

java ×1

java-ee ×1

jboss ×1