Satish Mishra [
https://community.jboss.org/people/mishra.sat30] created the discussion
"Developed EJB3 based application that I have placed in JBOSS 7 modules is not being
looked up."
To view the discussion, visit:
https://community.jboss.org/message/810361#810361
--------------------------------------------------------------
I have created an ejb application (MyEJB.jar) and placed in JBOSS 7 modules
"com.xxx.myejb". Everything is fine module is being loaded. Now there is a war
in deployments has a servlet is accessing the jar. The jar is visible (I have made entry
of the module in deployment structure file). The servlet calls a method of a class
SystemStart.java. Within that method I am invoking ejb already in the jar. initial context
is fine but when trying to lookup ejb, it gets failed and throwing NameNotFound
exception.
EJB is stateless name CSTimerBean
Local interface name CSTimerLocal
Here is the code-
public static Context getInitialContext() throws NamingException {
if (initialContext == null) {
System.out.println("initialContext");
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,org.jboss.naming.remote.client.InitialContextFactory.class.getName());
properties.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
properties.put("jboss.naming.client.ejb.context", new
Boolean(false));
properties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
properties.put(Context.PROVIDER_URL,"remote://localhost:4447");
properties.put(Context.SECURITY_PRINCIPAL, "jmd");
properties.put(Context.SECURITY_CREDENTIALS, "jmd123");
System.out.println("initialContext 2"+properties);
initialContext = new InitialContext(properties);
System.out.println("initialContext 1");
}
return initialContext;
}
private static String getCSLookupName() {
String appName = "";
String moduleName = "UFSwitch";
String distinctName = "";
// The EJB bean implementation class name
String beanName = CSTimerBean.class.getSimpleName();
// Fully qualified remote interface name
final String interfaceName = CSTimer.class.getName();
// Create a look up string name
String name = "ejb:" + appName + "/" + moduleName +
"/" +
distinctName + "/" + beanName + "!" +
interfaceName;
System.out.println(name);
return name;
}
public static CSTimer doCSLookup() {
Context context = null;
CSTimer bean = null;
try {
// 1. Obtaining Context
context = GlobalFunctions.getInitialContext();
System.out.println("String LookupName"+getCSLookupName());
String lookupName = getCSLookupName();
// 3. Lookup and cast
bean = (CSTimer) context.lookup(lookupName);
} catch (Exception e) {
e.printStackTrace();
}
return bean;
}
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/810361#810361]
Start a new discussion in EJB3 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]