I am migrating Ejb 2.1 to Ejb 3.1. I changed Java Version from 1.6 to 1.8, and Ejb Version from 2.1 to 3.1. Once I made the changes, I am getting problems in the ibm-ejb-jar-bnd.xml and ibm-ejb-jar-ext.xml files. I am getting these messages:
1: Session EJB with name 'abcEJB' not found
2: Resource reference with name 'ResourceRef_xyz' not found for this EJB or interceptorAm I missing anything?
I have migrated from EJB 2.1 to EJB 3.1 couple of years back and I recall facing the same issues and error you are facing.
Although I don't remember the exact action that fixed the issue nor other issues I faced along the way, but I will tell you what I did to fix ALL issues, including this one.
Note: It's not an easy task to migrate, but following these next steps as described will save you lots of hassle later on.
Now the code should look like this:
Session Bean interface:
@Local
public interface MySessionInterface {
// TODO :: declare business methods
}
Session bean implementation:
@stateless
public interface MySessionBeanImpl implements MySessionInterface {
// TODO :: implement business methods
}
Service Locator to lookup EJBs using JNDI:
public class ServiceLocator {
public final <T> T getLocalSession(Class<T> _class) throws NamingException {
return (T) new InitialContext().lookup("ejblocal:" + _class.getName());
}
}
Client:
public class SessionClient {
public void performOperation() {
try {
MySessionInterface session = ServiceLocator.getLocalSession(MySessionInterface.class);
// TODO :: perform business logic here
} catch (NamingException e) {
// TODO :: handle exception
}
}
}
Of course service locator can have the following improvements but I removed them for brevity:
Hope you find it useful.