8 Replies Latest reply: Aug 22, 2011 10:50 PM by Behrang Saeedzadeh RSS

@Interceptor call failure on @WebMethod

James Schreuder Newbie

I have just developed an Interceptor that will log @WebMethod calls on a @WebService annotated @Stateless EJB. I have noticed that if I don't implement a @Remote interface on my @Stateless session bean, the interceptor is not invoked on any of the @WebMethods. But I can still call the webservice correctly. If I do implement the @Remote interface, the interceptor works correctly with the webservice interface.


Here are some short class samples (taken from the O'Reilly EJB3.0 book):

@WebService(name = "TravelAgent", serviceName="TravelAgentService")

// ***
// Comment the following line out and the calls to the
// TravelAgentInterceptor.class in the @Interceptors list
// are never invoked and no failure message is reported
// There is no difference in the behaviour between @Remote
// or "implements TravelAgentRemote" either.
// ***

// @Remote(TravelAgentRemote.class)

public class TravelAgentBean
@PersistenceContext(unitName="titan") private EntityManager manager;

public void createCabin(@WebParam(name="Cabin")Cabin cabin)

public interface TravelAgentRemote
public void createCabin(Cabin cabin);

public class TravelAgentInterceptor
public Object intercept(InvocationContext invocationContext) throws Exception
System.out.println(invocationContext.getMethod().getName() + " called.");
return invocationContext.proceed();

Any help would be much appreciated. I am hoping to avoid having to define Remote interfaces that are exact copies of the methods on my stateless webservice session beans. The @WebService annotation provides an "endpoint interface" so that I don't have to implement the @Remote interface? Is that correct?