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.
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.");
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?
Hi @ all!
The problem still exists in JBoss 4.2.1 GA. The only workarround is to add a @Local or @Remote to the interface (like xslava wrote already). We generate our interface with wsimport, so we have to change the generated source code every time we do a new generation. If I understood the JSR-220 right, it should be possible to add interceptors to web-service methds as well (without a @Local or @Remote). If I use GlassFish instead of JBoss to deploy the same .jar-file, all interceptors get called.
Sorry for the "me too" post, but this is really unfortunate. @Interceptors just plain don't work on beans marked with only @Stateless and @WebService. Add @Service, @Local or @Remote, it works fine.
This is on AS 4.2.2.
Has this at least been added to the bug list? Are there any other workarounds?
Please do a search on JIRA (under EJBTHREE Project), and if you cannot find an issue, go ahead and file one. If you attach an isolated test case exhibiting this problem, that's very helpful.
For extra credit, you can even poke around and see what the differences between working @Interceptors and you case is. See http://wiki.jboss.org/wiki/Wiki.jsp?page=DevEJB3NewPlugin.