Hello,
I've spent hours to perform one of the most simple operation that, with any other application server, is really obvious and I'm very surprized to see the confusion and the lack of information and examples when it comes to use WebSphere.
I'm running WebSphere 8.5.5 on windows, I have a seesion bean deployed and its JNDI binding displayed by the log file is java:global/TestEAR/TestEJB/Test123!com.ing.tests.Test123.
So, I'm trying to call it from a Java standalone client like this:
Map props =
new HashMap();
props.put(EJBContainer.
MODULES, new File ("C:/RADWorkspace/Workspace_WAS_8.5_New/TestEJB\build"));
props.put(EJBContainer.
PROVIDER, "com.ibm.websphere.ejbcontainer.EmbeddableContainerProvider");
EJBContainer ec = EJBContainer.
createEJBContainer(props);
Object
o = ec.getContext().lookup(
"java:global/TestEAR/TestEJB/Test123!com.ing.tests.Test123");
This raises the following exception:
Exception in thread "P=929450:O=0:CT"
javax.ejb.EJBException: nested exception is: com.ibm.ws.exception.ConfigurationError: java.lang.Exception: Cannot find BundleContext for service com.ibm.ws.runtime.component.MetaDataMgrImplat com.ibm.websphere.ejbcontainer.EmbeddableContainer.initialize(EmbeddableContainer.java:499)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.open(EmbeddableContainer.java:442)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.newContainer(EmbeddableContainer.java:396)
at com.ibm.websphere.ejbcontainer.EmbeddableContainerProvider.createEJBContainer(EmbeddableContainerProvider.java:75)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(
EJBContainer.java:56)
at com.ing.tests.Test123.main(Test123.java:21)
Caused by: com.ibm.ws.exception.ConfigurationError:
java.lang.Exception: Cannot find BundleContext for service com.ibm.ws.runtime.component.MetaDataMgrImpl
at com.ibm.ws.runtime.component.MetaDataMgrImpl.initialize(
MetaDataMgrImpl.java:511)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.initialize(
EmbeddableContainer.java:497)
I tried also using the following code :
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
props.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2809");
Context ctx = new InitialContext(props);
Object o = ctx.lookup("java:global/TestEAR/TestEJB/Test123!com.ing.tests.Test123");
This raises the following exception:
NMSV0307E: A java: URL name was used, but Naming was not configured to handle java: URL names. The likely cause is a user in error attempting to specify a java: URL name in a non-J2EE client or server environment. Throwing ConfigurationException.
Exception in thread "main"
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:109)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:85)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:612)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:561)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
at javax.naming.InitialContext.lookup(InitialContext.java:422)
at com.ing.tests.Test123.main(Test123.java:20)
Does anybody have a simple example ? Many thanks in advance.
Nicolas