glassfish
  1. glassfish
  2. GLASSFISH-11576

Cannot inject session bean annotated as @WebService

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: V3
    • Fix Version/s: 3.1
    • Component/s: ejb_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Linux

    • Issuezilla Id:
      11,576

      Description

      I have a simple Session bean, annotated also with @WebService :

      @Stateless
      @WebService
      public class TestBean {
      }

      Then, I want to inject the session bean into a web servlet (s.S):

      @EJB
      private TestBean testBean;

      When calling the servlet I get the exception:

      WARNING: StandardWrapperValve[S]: PWC1382: Allocate exception for servlet S
      com.sun.enterprise.container.common.spi.util.InjectionException: Error creating
      managed object for class s.S
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:312)
      at
      com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:691)
      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.allocate(StandardWrapper.java:1059)
      at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
      at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      at
      org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      at
      com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      at
      org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
      at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
      at
      com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      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: java.lang.IllegalStateException: Exception attempting to inject
      Remote ejb-ref name=s.S/testBean,Remote 3.x interface
      =session.TestBean,ejb-link=null,lookup=null,mappedName=,jndi-name=session.TestBean,refType=Session
      into class s.S
      at
      org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:133)
      at
      org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:47)
      at
      org.jboss.weld.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:109)
      at
      org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:180)
      at
      org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:154)
      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)
      ... 27 more
      Caused by: com.sun.enterprise.container.common.spi.util.InjectionException:
      Exception attempting to inject Remote ejb-ref name=s.S/testBean,Remote 3.x
      interface
      =session.TestBean,ejb-link=null,lookup=null,mappedName=,jndi-name=session.TestBean,refType=Session
      into class s.S
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:614)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:384)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:168)
      at
      org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:126)
      ... 34 more
      Caused by: javax.naming.NamingException: Lookup failed for
      'java:comp/env/s.S/testBean' in SerialContext [Root exception is
      javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref
      name=s.S/testBean,Remote 3.x interface
      =session.TestBean,ejb-link=null,lookup=null,mappedName=,jndi-name=session.TestBean,refType=Session'
      . Actual (possibly internal) Remote JNDI name used for lookup is
      'session.TestBean#session.TestBean' [Root exception is
      javax.naming.NamingException: Lookup failed for
      'session.TestBean#session.TestBean' in SerialContext [Root exception is
      javax.naming.NameNotFoundException: session.TestBean#session.TestBean not found]]]
      at
      com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:513)
      ... 37 more
      Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote
      ejb-ref name=s.S/testBean,Remote 3.x interface
      =session.TestBean,ejb-link=null,lookup=null,mappedName=,jndi-name=session.TestBean,refType=Session'
      . Actual (possibly internal) Remote JNDI name used for lookup is
      'session.TestBean#session.TestBean' [Root exception is
      javax.naming.NamingException: Lookup failed for
      'session.TestBean#session.TestBean' in SerialContext [Root exception is
      javax.naming.NameNotFoundException: session.TestBean#session.TestBean not found]]
      at
      com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:174)
      at
      com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1040)
      at
      com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:688)
      at
      com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:657)
      at
      com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148)
      at
      com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428)
      ... 39 more
      Caused by: javax.naming.NamingException: Lookup failed for
      'session.TestBean#session.TestBean' in SerialContext [Root exception is
      javax.naming.NameNotFoundException: session.TestBean#session.TestBean not found]
      at
      com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at
      com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:169)
      ... 44 more
      Caused by: javax.naming.NameNotFoundException: session.TestBean#session.TestBean
      not found
      at
      com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:197)
      at
      com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:168)
      at
      com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:58)
      at
      com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:101)
      at
      com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
      ... 46 more

      I think this is quite legal scenario, or not?

        Activity

        Hide
        ksak added a comment -

        The problem is that as defined the TestBean does not expose a no-interface view, so the client reference
        can not be resolved. A no-interface view is only automatically exposed from a bean class when that class
        does not expose any other client views. In the given code the bean exposes a web service client view. If
        you need the bean to also expose a no-interface view, you'll need to explicitly request that by adding the
        @LocalBean annotation to the bean class.

        Show
        ksak added a comment - The problem is that as defined the TestBean does not expose a no-interface view, so the client reference can not be resolved. A no-interface view is only automatically exposed from a bean class when that class does not expose any other client views. In the given code the bean exposes a web service client view. If you need the bean to also expose a no-interface view, you'll need to explicitly request that by adding the @LocalBean annotation to the bean class.
        Hide
        David Konecny added a comment -

        Should not coding mistakes like this one be caught in compile time? @Stateless
        annotation is basically invalid there because TestBean does not have
        No-Iterface, nor Local, nor Remote interface, and therefore there is no
        stateless session bean.

        Or does @Stateless indicates in below case that the web service is stateless?
        (I'm not very knowledgeable when it comes to WSs)

        Show
        David Konecny added a comment - Should not coding mistakes like this one be caught in compile time? @Stateless annotation is basically invalid there because TestBean does not have No-Iterface, nor Local, nor Remote interface, and therefore there is no stateless session bean. Or does @Stateless indicates in below case that the web service is stateless? (I'm not very knowledgeable when it comes to WSs)
        Hide
        ksak added a comment -

        @Stateless is still required for it be to an enterprise bean component. @WebService says that the stateless
        session bean exposes a web service client view.

        Show
        ksak added a comment - @Stateless is still required for it be to an enterprise bean component. @WebService says that the stateless session bean exposes a web service client view.

          People

          • Assignee:
            ksak
            Reporter:
            mkuchtiak
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: