eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
378 stars 144 forks source link

Failure to lookup EJB in ear/war #21114

Closed glassfishrobot closed 4 years ago

glassfishrobot commented 10 years ago

I have an ear which includes an EJB and a jax-rs WAR module, both listed in the application.xml file of the EAR.

The war contains jax-rs Application and resource bean classes, and the resource class injects stateless bean from the EJB module using @EJB annotation.

When I access the REST resource after deploy GlassFish is unable to locate the jax-rs resource bean, which lives inside the WAR. It looks like GlassFish assumes it is to be found in the EJB module (see Stacktrace below).

I have a small example application exhibiting this problem, that I will gladly upload if possible.

The problem does not appear to be in GlassFish versions 4.0 up to and including 4.0.1 b04.

We have done testing on both Java 7 and 8.

[2014-07-01T12:06:22.179+0200] [glassfish 4.0] [WARNING] [] [org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider] [tid: _ThreadID=123 _ThreadName=http-listener-1(1)] [timeMillis: 1404209182179] [levelValue: 900] [[ An instance of EJB class, dk.dbc.gf.ejb.HelloWorldBean, could not be looked up using simple form name. Attempting to look up using the fully-qualified form name. javax.naming.NamingException: Lookup failed for 'java:app/gf-4.0.1-fail-ejb-1.0-SNAPSHOT/HelloWorldBean' in SerialContext[myEnv=

{java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

[Root exception is javax.naming.NameNotFoundException: No object bound to name java:app/gf-4.0.1-fail-ejb-1.0-SNAPSHOT/HelloWorldBean] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) at javax.naming.InitialContext.lookup(InitialContext.java:417) at javax.naming.InitialContext.lookup(InitialContext.java:417) at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.lookupSimpleForm(EjbComponentProvider.java:378) at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.lookup(EjbComponentProvider.java:360) at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.access$000(EjbComponentProvider.java:100) at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider$EjbFactory.provide(EjbComponentProvider.java:123) at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2151) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:641) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:626) at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:172) at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185) at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74) at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112) at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94) at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63) at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:252) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1025) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:745) Caused by: javax.naming.NameNotFoundException: No object bound to name java:app/gf-4.0.1-fail-ejb-1.0-SNAPSHOT/HelloWorldBean at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:741) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471) ... 64 more ]]

Affected Versions

[4.1_dev]

glassfishrobot commented 6 years ago
glassfishrobot commented 10 years ago

@glassfishrobot Commented @barchetta said: There have been some recent Jersey integrations. Assigning to Jakub for initial evaluation.

glassfishrobot commented 10 years ago

@glassfishrobot Commented dbcjbn said: Would you happen to have an estimate on when this issue will be addressed, please?

glassfishrobot commented 10 years ago

@glassfishrobot Commented dbcjbn said: This bug has also been observed on GlassFish v4.1

glassfishrobot commented 10 years ago

@glassfishrobot Commented sgerr said: Bug is reproduced at Glassfish 4.1. It seems it is related to https://java.net/jira/browse/JERSEY-2122, but Jersey bug is at fixed state (fix version is 2.6), whereas Glassfish 4.1 is packaged with jersey of version 2.10.4-0. Unfortunately, this bug still appears. Is it scheduled for resolution?

glassfishrobot commented 10 years ago

@glassfishrobot Commented giates2000 said: Due to this issue all my working jee7 rest web services are now stopped on glassfish v. 4.1, is there any workaround ?

glassfishrobot commented 9 years ago

@glassfishrobot Commented gray said: I've found what is causing this bug and added comment to https://java.net/jira/browse/JERSEY-2122.

glassfishrobot commented 9 years ago

@glassfishrobot Commented gray said: https://java.net/jira/browse/JERSEY-2690

glassfishrobot commented 9 years ago

@glassfishrobot Commented marvinemilbrach said: posssible workaround: replace @Stateless with: @javax.enterprise.context.RequestScoped @javax.enterprise.context.ApplicationScoped @javax.enterprise.context.ConversationScoped // NOT tested @javax.enterprise.context.SessionScoped // NOT tested

perhaps related to https://java.net/jira/browse/GLASSFISH-21199

glassfishrobot commented 9 years ago

@glassfishrobot Commented dobromyslov said: @RequestScoped breaks transactions in Jersey and it requires to mark methods as @Transactional.

Also Weld does not work well with @RequestScoped and raises an exception sometimes: https://issues.jboss.org/browse/WELD-1774

glassfishrobot commented 9 years ago

@glassfishrobot Commented dobromyslov said: java.lang.IllegalStateException: WELD-000335: Context is already active Raises when I redeploy with JRebel. It's been fixed in WELD 2.2.8.Final.

glassfishrobot commented 9 years ago

@glassfishrobot Commented sparksis said: I've submitted a pull request which fixes the issue in Jersey: https://github.com/jersey/jersey/pull/162

Unfortunately the the pull request is still pending.

glassfishrobot commented 8 years ago

@glassfishrobot Commented nabizamani said: Is this here still an open issue? I'm just wondering because there is no reaction from Oracle!

glassfishrobot commented 8 years ago

@glassfishrobot Commented @japod said: I am no longer on Jersey team. IIUC, this has already been fixed in Jersey (as per https://github.com/jersey/jersey/commit/8636f65b992322008bb987409af0dd97dec3b95f ). So this bug should get fixed in GlassFish once the corresponding Jersey version gets integrated.

glassfishrobot commented 7 years ago

@glassfishrobot Commented nabizamani said: So today GlassFish 4.1.2 was released - although way too late that's better than nothing! However, this kinda old bug was not fixed. By the way - this bug is definitely fixed in Payara 4.1.1.171.1!!!!

Now I wonder why this bug did not get fixed? The public announcement at https://blogs.oracle.com/theaquarium/entry/glassfish_4_1_2_released states clearly:

"GlassFish 4.1.2 has undergone extensive testing that include the component unit tests, developer tests, full CTS 7 as well as standalone TCKs"

That statement sounds like a joke if such major bugs like this one are not fixed! How can GlassFish be called Java EE 7 compliant??? So what's the state here?

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-21114

glassfishrobot commented 10 years ago

@glassfishrobot Commented Reported by dbcjbn

glassfishrobot commented 7 years ago

@waynegemmell Commented Hi I have the same problem. The work around mentioned worked for me. Error

javax.naming.NamingException: Lookup failed for 'java:app/ConnetOBS-ejb/BillingServiceFacadeREST' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:app/ConnetOBS-ejb/BillingServiceFacadeREST]

Fix

I replaced @stateless with @javax.enterprise.context.RequestScoped

glassfishrobot commented 7 years ago

@waynegemmell Commented Subsequently, I had do follow the instructions in the following comment to get a working system. I hope this helps someone. https://java.net/jira/browse/GLASSFISH-21440?focusedCommentId=393833&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-393833

glassfishrobot commented 7 years ago

@dinagpal Commented I got your point. As you mentioned before that you are having a sample app exhibiting this issue. If you upload it then it will be convenient for me to reproduce this bug.

glassfishrobot commented 7 years ago

@yaminikb Commented @nabizamani This bug is not fixed in 4.1.2. Can you please try with GlassFish 5.0? http://download.oracle.com/glassfish/5.0/nightly/index.html

glassfishrobot commented 7 years ago

@dinagpal Commented This issue is caused by Jersey. Glassfish 5.0 is integrated with Jersey version 2.26-b02 and the Jersey bug is at fixed state in this version. I have verified it also by creating a sample application.

glassfishrobot commented 7 years ago

@yaminikb Commented @waynegemmell Can you please verify if your problem is resolved using latest GlassFish 5.0?

glassfishrobot commented 7 years ago

@waynegemmell Commented It looks to be working on Glassfish 5, not that that helps my production implementation. On glassfish 5 however, the Jersey stuff isn't emitting JSON anymore so it's difficult to test.

glassfishrobot commented 7 years ago

@nzamani Commented This issue has been around for about 3 years, and it still exists in 4.1.2 - what a shame. We are desperately waiting to get this fixed, have a look at stackoverflow! Especially since there seems to be an easy fix by patching Jersey.

However, the last 3 years nothing happened. How about offering Glassfish 4.1.3??? I think this is important because with this bug Glassfish 4 IS NOT Java EE 7 compliant!

And please add the labels right labels as this reflects the reality much better:

github-actions[bot] commented 4 years ago

This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment