I have migrated my app from Glassfish 2.2.1 to JBoss AS 6.
Previously i have a generic class for lookup the ejbs, Below is the code:
public class BeanUtil {
private static InitialContext ctx;
public static <T> T create(Class<T> type){
try {
ctx = new InitialContext();
return (T)ctx.lookup(type.getName());
} catch (NamingException e) {
e.printStackTrace();
}
return null;
}
}
The above class works fine for lookup in glassfish. But after migrating the code to JBoss AS 6. I always get javax.naming.NameNotFoundException
Below is one of my ejb class.
@Remote
public interface OperationPerformed {
public void addRandomNo(String randomNos);
}
@Stateless
@Remote(OperationPerformed.class)
public class OperationPerformedImpl implements OperationPerformed {
public void addRandomNo(String randomNos) {
}
}
If i give the complete jndi name which jboss made during deployment of my app, then i can easily lookup the same. But i want generic code for lookup.
Below is the code which i invoke for lookup a bean:
OperationPerformed operationPerformed = BeanUtil.create(OperationPerformed.class);
Please suggest if i am doing something wrong.