1. Compilation error, incorrect declaration on line 3.
2. Compilation error, incorrect declaration on line 4.
3. The code compiles fine.
4. Compilation error, the GatewayBean class must be declared abstract.
5. Compilation error, the GatewayBean class must be declared final.
Answer 2 is correct. The message-driven bean class must define one onMessage method whose signature must follow these rules:
The method must be declared as public. The method must not be declared as final or static. The return type must be void. The method must have a single argument of type javax.jms.Message. The throws clause must not define any application exceptions.
I don't understand why this mthod is declared wrong. I believe it follows all the above rules....what am I missing?
Whenever a class implements an interface it has to provide the implementation of the methods declared in the interface or the class will be abstract. If you provide the implementatiom for onMessage(javax.jms.TextMessage) then you will get a compile time error that the MDB needs to implement the inherited abstract method onMessage(javax.jms.Message).