ejb@glassfish.java.net

interceptor not invoked when declared in ejb-jar.xml and packaged in EAR/lib

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Wed, 01 Mar 2006 14:04:42 -0500 (EST)

I have this example:

If I package AssemblyInterceptor.class and ejb client view classes and
utility classes in EAR/lib/shared.jar, this interceptor is not invoked.
There is no error anywhere. EAR/lib is the default library-directory for
the app.

If I also duplicate AssemblyInterceptor.class in ejb-jar, interceptor is
invoked as expected.

In any case, the generated full ejb-jar.xml does contain this interceptor
and interceptor binding.

Any idea what's wrong here?

//already declared in ejb-jar.xml. Annotations not needed
@Stateless
public class AssemblyBean extends AssemblyBeanBase
    implements AssemblyRemoteIF, AssemblyLocalIF, AssemblyCommonIF
{
    public AssemblyBean() {
    }
}

ejb-jar.xml: (metadata-complete=false)
=====================================
    <enterprise-beans>
        <session>
            <ejb-name>AssemblyBean</ejb-name>
<business-local>...AssemblyLocalIF</business-local>
<business-remote>...AssemblyRemoteIF</business-remote>
<ejb-class>...AssemblyBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
            <security-identity>
                <use-caller-identity/>
            </security-identity>
        </session>
    </enterprise-beans>
    <interceptors>
        <interceptor>
<interceptor-class>...AssemblyInterceptor</interceptor-class>
        </interceptor>
    </interceptors>

    <assembly-descriptor>
        <interceptor-binding>
            <ejb-name>AssemblyBean</ejb-name>
            <interceptor-order>
<interceptor-class>...AssemblyInterceptor</interceptor-class>
            </interceptor-order>
        </interceptor-binding>
    </assembly-descriptor>


interceptor:
=============
public class AssemblyInterceptor {

    public AssemblyInterceptor() {
        super();
    }

    @PostConstruct
    protected void myCreate(InvocationContext inv) throws RuntimeException
{
    }

    @PreDestroy
    protected void myRemove(InvocationContext inv) throws RuntimeException
{
    }

    @AroundInvoke
    protected Object intercept(InvocationContext inv) throws Exception {
    ...
    }
}

Thanks.
-- Cheng