I have written a sample EJB class as shown below :
@Stateless(mappedName = "BusinessSLSB")
@Local(BusinessLocal.class)
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public class BusinessSLSB implements BusinessLocal{
//body of the class
}
I have a non-EJB class in the same project and I try to lookup the file in the following way :
public class GetTransactionData {
private BusinessLocal business;
public GetTransactionDataForMercury(){
notifier.info("Creating an object of GetTransactionData");
try{
InitialContext ctx = new InitialContext();
business = (BusinessLocal) ctx.lookup("BusinessSLSB");
}catch(Exception ne){
notifier.error("Error occurred --> " + ne.getMessage());
}
}
When I am executing the code, I am getting the following exception :
Error occurred --> Unable to resolve BusinessSLSB. Resolved '
Am I going wrong in providing the lookup name? How can I resolve this issue?
I have found the solution for such a problem. The solution is add the following lines in the web.xml file :
and the following lines in GetTransactionData :