I'm trying to run ejb Helloworld program and my JNDI[1] but I’m getting bellow error[2] I’m running Jboss AS 7 final and AS output list[3]. anyone guide on this to me what my mistake?
[1]
Properties prop = new Properties();
prop.setProperty("java.naming.factory.url.pkgs","org.jboss.ejb.client.naming");
return new InitialContext(prop);
[2]
javax.naming.NameNotFoundException: Name [org.wso2.carbon.custom.ejb-1.0-SNAPSHOT/HelloBean] is not bound in this Context. Unable to find [ejb:].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.lookup(CarbonContextDataHolder.java:705)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.wso2.carbon.connector.EJBConnector.callEJB(EJBConnector.java:69)
at org.wso2.carbon.connector.EJBConnector.connect(EJBConnector.java:40)
at org.wso2.carbon.connector.core.AbstractConnector.mediate(AbstractConnector.java:32)
at org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:78)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
at org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:97)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:149)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[3]
java:global/org.wso2.carbon.custom.ejb-1.0-SNAPSHOT/HelloBean!org.wso2.carbon.custom.ejb.HelloIF
java:app/org.wso2.carbon.custom.ejb-1.0-SNAPSHOT/HelloBean!org.wso2.carbon.custom.ejb.HelloIF
java:module/HelloBean!org.wso2.carbon.custom.ejb.HelloIF
java:jboss/exported/org.wso2.carbon.custom.ejb-1.0-SNAPSHOT/HelloBean!org.wso2.carbon.custom.ejb.HelloIF
java:global/org.wso2.carbon.custom.ejb-1.0-SNAPSHOT/HelloBean
java:app/org.wso2.carbon.custom.ejb-1.0-SNAPSHOT/HelloBean
java:module/HelloBean
i solved this issue after long search. this because of classloder issue in glassfish. so added a method to solve the classloding issue then its work fine.
Thread currentThread = Thread.currentThread();
ClassLoader oldClassLoader = currentThread.getContextClassLoader();
try {
//switching the classloader to prevent class loading glassfish classloading issues
currentThread.setContextClassLoader(getClass().getClassLoader());
//method to run
callEJBStateful(messageContext);
} catch (Exception e) {
handleException("Error calling EJB Service from EJBConnector", e, messageContext);
} finally {
if (oldClassLoader != null) {
//resetting the classloader
currentThread.setContextClassLoader(oldClassLoader);
}
}