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.

22 December 2008

Hacking the Amazone rainforest

Brazilian loggers are hiring hackers to break in to government systems and exceed their quota.
The Brazilian government will respond by raising the quota with 150%.

21 December 2008

JMS producer code example

Alternate example for Code 8-1 in SL351-EE5.
This example features:
- ejb client container resource injection
- Queue/topic agnostic API (JMS 1.1)

EJB life cycle callback handlers

SL-351-EE5 Extra excercise 10.1

1 Create a JMS connection when the AuctionManagerBean is created.
   Make the connection an attribute of the bean
2 Close the JMS Connection when the bean is destroyed.



Solution

15 December 2008

EJB2 => EJB3

These slides show an example of the changes in a session bean going from EJB 2 to EJB 3