users@glassfish.java.net

Manual lookup of remote EJB in Glassfish

From: <glassfish_at_javadesktop.org>
Date: Mon, 25 Oct 2010 23:19:28 PDT

Hi
We have remote ejb's deployed on a Glassfish 3.0.1 instance, and a frontend webapp deployed in another GF3.0.1 instance.

Injecting a remote EJB in the frontend webapp like this works:

        @EJB(name = "StatusService")
        private StatusService statusService;

The ejb is defined in the frontend sun-web.xml:

        <ejb-ref>
                <ejb-ref-name>StatusService</ejb-ref-name>
                <jndi-name>corbaname:iiop:localhost:3700#no.evote.service.StatusService</jndi-name>
        </ejb-ref>

But I want to do a manual lookup of the EJB (basically replicating the @EJB functionality). So I try this:

InitialContext context = new InitialContext();
StatusService statusService = (StatusService)context.lookup("corbaname:iiop:localhost:3700#no.evote.service.StatusService");

But this always gives this error (which basically says the ejb whas not found):

[#|2010-10-26T07:39:25.977+0200|SEVERE|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=23;_ThreadName=Thread-1;|javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
        at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:485)
        at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:524)
        at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at no.evote.presentation.EJBProducer.getStatusService(EJBProducer.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
        at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:200)
        at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:164)
        at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:143)
        at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:360)
        at org.jboss.weld.context.DependentContext.get(DependentContext.java:62)
        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:709)
        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:771)
        at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:794)
        at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:108)
        at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:790)
        at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:802)
        at org.jboss.weld.manager.SimpleInjectionTarget$1.proceed(SimpleInjectionTarget.java:122)
        at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:130)
        at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:47)
        at org.jboss.weld.manager.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:116)
        at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:204)
        at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:178)
        at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:456)
        at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:423)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:295)
        at com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:709)
        at com.sun.enterprise.web.WebModule.createServletInstance(WebModule.java:1937)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1252)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1229)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5007)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5280)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
        at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
        at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
        at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
        at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:251)
        at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:471)
        ... 77 more

I have read the EJB faq here a few times now:
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

I can't find a matching scenario there, but from what I can understand, shouldn't this code work?

All help appreciated!

Regards,
Anders
[Message sent by forum member 'andersaab']

http://forums.java.net/jive/thread.jspa?messageID=486221