1 Reply Latest reply on Apr 2, 2008 2:31 AM by jwenting

    Why interceptors can't be deployed using ejb-jar.xml?

    littlepinkie

      Hi, I'm trying to get familiar with the interceptors in ejb3. I succeeded in using it with annotations, and it worked well. But when I remove the @Interceptors and put <interceptor-binding> in the ejb-jar.xml, the interceptor doesn't work.
      Here is the ejb-jar.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar
       xmlns="http://java.sun.com/xm./ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
       http://java.sun.com/xml/ns/javaee/ejb-jar_3.0.xsd"
       version="3.0">
      
       <assembly-description>
       <interceptor-binding>
       <ejb-name>HelloWorldBean</ejb-name>
       <interceptor-class>com.abc.interceptors.Profiler</interceptor-class>
       </interceptor-binding>
       </assembly-description>
      </ejb-jar>
      


      Thanks in advance for any help!

        • 1. Re: Why interceptors can't be deployed using ejb-jar.xml?

          you're probably missing the section of the ejb-jar.

          Something like

          <interceptors>
           <interceptor>
           <interceptor-class>your_interceptor_class_name</interceptor-class>
           <post-construct>
           <lifecycle-callback-method>methodName</lifecycle-callback-method>
           </post-construct>
           <!-- ditto for other callback methods -->
           </interceptor>
          </interceptors>