When I use such a business method in a simple ejb3 stateless session
bean, it works fine :-)
@Remote
public interface EchoRemote {
void echo();
void echo2();
Object getMessage();
}
------------------
@Stateless
public class EchoBean implements com.foo.ejb.EchoRemote {
...
public String getMessage() { //String, instead of Object, is returned
return "A message from EchoBean";
}
}
When I apply a @TransactionAttribute(TransactionAttributeType.MANDATORY)
on this business method, the annotation is ignored.
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public String getMessage() { //String, instead of Object, is returned
return "A message from EchoBean";
}
I expect a TransactionRequiredException or the like, since my web client
doesn't start transaction, but no exception occurred. The generated
ejb-jar.xml after deployment contains no transaction attribute for any
methods. So the default REQUIRED is always used.
If I change the return type to Object, I got the expected exception.
I suspect all method-level annotation on such methods are ignored,
though I haven't tested other annotations.
This looks like a bug, unless ejb spec has special restrictions on
covariant return type.
--
Cheng