28 January 2009

EJB3 default interceptors

To apply an interceptor class (auctionsystem.infra.EJBMonitor in this example) to all beans, add to the deployment descriptor (ejb-jar.xml):

<ejb-jar>
  <interceptors>
    <interceptor>
      <interceptor-class>auctionsystem.helper.EJBMonitor</interceptor-class>
    </interceptor>
  </interceptors>
  <assembly-descriptor>
    <interceptor-binding>
      <ejb-name>*</ejb-name>
      <interceptor-class>auctionsystem.helper.EJBMonitor</interceptor-class>
    </interceptor-binding>
  </assembly-descriptor>
</ejb-jar>

The order in which interceptors are called is:
  1. default interceptors
  2. class level interceptors (interceptors on superclasses are called first)
  3. method level interceptors
To overrule calling of interceptors with larger scope use these annotations:
  1. @ExcludeDefaultInterceptors
  2. @ExcludeClassInterceptors
There are similar defaults for JPA, but these don't work currently in glassfish (issue 2821)

20 January 2009

Glassfish error loading EJB client application container application

Whenever you load an EJB standalone client to be run within a client container into Glassfish 2 you get this error (with a whole stack trace following it):

Error attempting to process extensions from the manifest of JAR file C:\projectlocal\netbeans\SL351_D2\project\Auction\dist\gfdeploy\Auction-ejb.jar; ignoring it and continuing
java.io.FileNotFoundException: C:\projectlocal\netbeans\SL351_D2\project\Auction\dist\gfdeploy\Auction-ejb.jar (The system cannot find the file specified)

The error can be safely ignored, as Tim Quinn explains.

Still it clutters other server output, so I tend to set the deployment logging level (javax.enterprise.system.tools.deployment) to severe in the glassfish console to get rid of it. I just switch it back when in doubt.