Hi All,
Today when i was taking mock test from Enthuware I found 2 mistakes, please tell me if I am wrong.
1)
@Stateless
@Remote(Easy.class)
public class EasyBean {
public void doIt() throws MyException{
if(true) throw new MyException();
}
}
The code for MyException is as follows -
public class MyException extends Exception{ }
If a client calls doIt() method on EasyBean (assuming that it is declared in the remote interface), what will happen?
The client will get RemoteException.
The client will get EJBException.
The client will get MyException.
The client will get NullPointerException.
The client will get EJBException that wraps MyException.In the above question the bean is not implimenting the interface, so i marked as EJBException. So please clarify my doubt.
2)
Consider the following code for a session bean class:
//... valid cdoe
//Line 1: insert code here
public class TellerBean implements
com.enthu.ejbplus.TellerRemote, com.enthu.ejbplus.TellerLocal {
// ... valid code
}
This bean sends messages to a Queue in its business methods. Which of the following line of code should be inserted at // Line 1 to declare a TYPE-level dependency on the JMS Queue?
(Assume appropriate import and other necessary statements.)
@Resource
Queue myQueue;
@Resource
private static Queue myQueue;
@Resource(name="jms/myQueue", type=javax.jms.Queue.class)
@Resource(name="jms/Queue")
Queue myQueue;
The answer given by Enthuware is in bold but there is one more question below that is contredicting the above question.
Consider the following code for a session bean class:
//... valid code
public class TellerBean implements
com.enthu.ejbplus.TellerRemote, com.enthu.ejbplus.TellerLocal {
//Line 1: insert code here
}
}
This bean sends messages to a Queue in its methods. Which of the following line of code should be inserted at // Line 1 to inject a Queue object?
(Assume appropriate import and other necessary statements.)
@Resource private Queue myQueue; c
@Resource private static Queue myQueue;
@Resource(name="jms/myQueue", type=javax.jms.Queue.class)
A variable is required. It would have been valid if it were put before the class definition.
@Resource(name="jms/Queue")
Queue myQueue;
If the name is not specified, a default name is assumed which is generated using the complete class name prependend to the field name i.e. com.enthu.ejbplus.TellerBean/myQueue
@Resource public final Queue myQueue;
Please tell me if i am wrong.
Regards
Vasanthi