0

On invoking an @Asynchronous method in EJB, I see an error getting logged though the method execution works fine. Any suggestion on what is going wrong? EJB 3.1 on WebSphere V8

The interface is :

@Local
public interface MyService {
    @Asynchronous
    public void doJob(MyObj o);
}

The implementation class :

@Stateless
@Local(MyService.class)
public class MyBean implements MyService {
    @Asynchronous
    public void doJob(MyObj o) {

        // insert to DB

   }
}

Error message

CWWAM1101E: In class {0} the method {1} is annotated with @Asynchronous but must be applied to a business method of a bean class or to a business method of a Local/Remote business interface.

ad-inf
  • 1,520
  • 4
  • 30
  • 53

2 Answers2

1

As you're implementing an interface (MyService) your bean doesn't expose a no-interface view. This means all methods for which the EJB container has to "do something", have to be defined in that interface.

It's very likely that void doJob(...) is not defined MyService. When in doubt, please show the full definition of doJob and MyService.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
  • I guess the error is about having annotated the method declaration in the interface. Can you try removing `@Asynchronous` from `MyService`? You should only have the `@Asynchronous` annotation on `MyBean` then. – Arjan Tijms Nov 12 '12 at 07:47
  • p.s. the `@Local` annotation is double is well. You need it only once. In this case, remove the one on `MyBean`. – Arjan Tijms Nov 12 '12 at 07:49
  • Tried various scenarios. 1 - If annotation is added to the interface and implementation , then the asynchronous functionality works, and the error messages are logged. 2 - If annotation is added to the interface alone, then the error messages are not logged, but the functionality doesn’t work. 3 - If annotation is added to the implementation alone, then the error is logged, but the functionality doesn’t work. – ad-inf Nov 12 '12 at 13:01
  • 1
    That almost sounds like a bug in WebSphere :\ Last thing you could try is not implementing an interface at all. So, remove `implements MyService` completely and `@Local`. This shouldn't be necessary, but just for completeness. – Arjan Tijms Nov 12 '12 at 19:33
1

This is a defect in WebSphere till V8.0.0.5 and a fix is expected in V8.0.0.6

ad-inf
  • 1,520
  • 4
  • 30
  • 53