glassfish
  1. glassfish
  2. GLASSFISH-19249

@OSGi causes ClassCastException when used from EJB deployed as EAR

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2.2
    • Fix Version/s: 4.1
    • Component/s: OSGi-JavaEE
    • Labels:
      None

      Description

      I have a stateless session bean packaged and deployed as OSGi hybrid bundle. I want to access this EJB from another EJB packaged in an EAR file. So I used the following annotations:

      @Inject
      @OSGiService( dynamic = true )
      private QueueRegistryInterface queueRegistry;

      Deployment works fine but on runtime I got the following exception:

      [2012-10-26 11:30:13,695] [ERROR] [org.glassfish.osgicdi.impl] [p: thread-pool-1; w: 7] [#1] Expected annotated element java.lang.ClassCastException to be within an OSGi Bundle.
      [2012-10-26 11:30:13,695] [ERROR] [com.macd.xconnect.messageprocessor.base.MessageProcessor-OmsReceiver] [p: thread-pool-1; w: 7] failed to return failure message back: routeMessage: Error routing message: null
      com.macd.xconnect.messageprocessor.base.MessageRouterBeanException: routeMessage: Error routing message: null
              at com.macd.xconnect.ejbeans.implementation.messagerouter.MessageRouterBean.routeMessage(MessageRouterBean.java:132)
              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.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
              at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
              at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
              at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
              at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
              at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
              at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
              at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
              at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
              at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
              at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
              at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
              at sun.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
              at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
              at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
              at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
              at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
              at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
              at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
              at $Proxy207.routeMessage(Unknown Source)
              at com.macd.xconnect.messageprocessor.base.MessageProcessor.processAndRouteMessage(MessageProcessor.java:201)
              at com.macd.xconnect.messageprocessor.base.MessageProcessor.onMessage(MessageProcessor.java:126)
              at com.macd.xconnect.ejbeans.messageprocessor.MessageProcessorBean.onMessage(MessageProcessorBean.java:155)
              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.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
              at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
              at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:4180)
              at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5368)
              at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
              at com.sun.ejb.containers.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1099)
              at com.sun.ejb.containers.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:81)
              at com.sun.enterprise.connectors.inbound.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:171)
              at $Proxy314.onMessage(Unknown Source)
              at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:260)
              at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:114)
              at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
              at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
      Caused by: java.lang.ClassCastException
              at java.lang.Class.cast(Class.java:2990)
              at org.glassfish.osgicdi.impl.OSGiServiceFactory.getBundleContext(OSGiServiceFactory.java:191)
              at org.glassfish.osgicdi.impl.OSGiServiceFactory.lookupService(OSGiServiceFactory.java:127)
              at org.glassfish.osgicdi.impl.OSGiServiceFactory.access$100(OSGiServiceFactory.java:72)
              at org.glassfish.osgicdi.impl.OSGiServiceFactory$DynamicInvocationHandler.invoke(OSGiServiceFactory.java:232)
              at $Proxy315.find(Unknown Source)
              at com.macd.xconnect.messageprocessor.base.MessageRouter.sendMessage(MessageRouter.java:113)
              at com.macd.xconnect.messageprocessor.base.MessageRouter.sendMessage(MessageRouter.java:178)
              at com.macd.xconnect.messageprocessor.base.MessageRouter.routeMessage(MessageRouter.java:96)
              at com.macd.xconnect.ejbeans.implementation.messagerouter.MessageRouterBean.routeMessage(MessageRouterBean.java:130)
              ... 50 more
      

      Please let me know if any further information or examples are required.

        Activity

        cplaetzinger created issue -
        tlcksnyder made changes -
        Field Original Value New Value
        Fix Version/s 4.0.1 [ 16061 ]
        tlcksnyder made changes -
        Assignee jjsnyder83 [ jjsnyder83 ] mtaube [ mtaube ]
        Sanjeeb Sahoo made changes -
        Issue Type Bug [ 1 ] New Feature [ 2 ]
        Assignee mtaube [ mtaube ] Sanjeeb Sahoo [ ss141213 ]
        Component/s cdi [ 10637 ]
        Romain Grécourt made changes -
        Fix Version/s 4.1 [ 16387 ]
        Fix Version/s 4.0.1 [ 16061 ]

          People

          • Assignee:
            Sanjeeb Sahoo
            Reporter:
            cplaetzinger
          • Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated: