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.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

        Hide
        TangYong added a comment -

        If exactly speaking, EAR OSGi Deployment has not a uniform standard, although OSGi EE has published a SubSystem Spec.
        For the feature, there are three ways:

        1. let us wait SubSystem Spec Implementation
        The Subsystem Spec Implementation is charged by Apache Aries.

        2. Using Apache Aries Application Feature
        Just as what I said in my blog, however, this way has a backback that we need to arrange right bundles related to the feature.
        Indeedly, we need some function liking Apache Karaf Feature to provision such feature automaticlly. However, this will change
        GlassFish Kernel. You knonw , this will need more effort and also need to discuss with Sahoo carefully.

        3. Implmenting a new Hybrid Application Bundle related to EAR.
        This also needed to be dicuss with Sahoo. Eg. whether needing to implement it currently?

        So, for your scene, I suggest that you can do it based on my blog.

        If having any problem,

        giving me your sample (pl. adding your sample into github or others which I can acess)

        In the future, we will implement OSGi/CDI Spec firstly, however, once we felt your scene is most important, we will change plan and maybe firstly
        implement the feature you mentioned.

        Of Course, also pl. listening Sahoo's suggestion.

        Thanks
        Tang

        Show
        TangYong added a comment - If exactly speaking, EAR OSGi Deployment has not a uniform standard, although OSGi EE has published a SubSystem Spec. For the feature, there are three ways: 1. let us wait SubSystem Spec Implementation The Subsystem Spec Implementation is charged by Apache Aries. 2. Using Apache Aries Application Feature Just as what I said in my blog, however, this way has a backback that we need to arrange right bundles related to the feature. Indeedly, we need some function liking Apache Karaf Feature to provision such feature automaticlly. However, this will change GlassFish Kernel. You knonw , this will need more effort and also need to discuss with Sahoo carefully. 3. Implmenting a new Hybrid Application Bundle related to EAR. This also needed to be dicuss with Sahoo. Eg. whether needing to implement it currently? So, for your scene, I suggest that you can do it based on my blog. If having any problem, giving me your sample (pl. adding your sample into github or others which I can acess) In the future, we will implement OSGi/CDI Spec firstly, however, once we felt your scene is most important, we will change plan and maybe firstly implement the feature you mentioned. Of Course, also pl. listening Sahoo's suggestion. Thanks Tang
        Hide
        jthoennes added a comment -

        Hello,

        this issues is planned for release 4.0.1. Is anybody working on this right now? When is this release due?

        Thanks, Jörg

        Show
        jthoennes added a comment - Hello, this issues is planned for release 4.0.1. Is anybody working on this right now? When is this release due? Thanks, Jörg
        Hide
        TangYong added a comment -

        jthoennes
        CC: Sahoo

        >I will give an detailed steps in my blog about how to play with it including an eba sample.
        You can see concrete steps and test sample in the following:

        http://osgizone.typepad.com/tangyong/2013/04/glassfish-osgi-integration-part1-integrating-apache-aries-application-into-glassfish-v4.html

        Thanks
        --Tang

        Show
        TangYong added a comment - jthoennes CC: Sahoo >I will give an detailed steps in my blog about how to play with it including an eba sample. You can see concrete steps and test sample in the following: http://osgizone.typepad.com/tangyong/2013/04/glassfish-osgi-integration-part1-integrating-apache-aries-application-into-glassfish-v4.html Thanks --Tang
        Hide
        TangYong added a comment - - edited

        jthoennes
        CC: Sahoo

        Initial investigation has been ended. and I have an integration plan. However, can not check in the plan because having some issues.

        OK, I fistly said the integration plan.

        1) creating three new directories in glassfish\modules

        • third-party\aries\application
        • third-party\aries\blueprint
        • third-party\aries\pre-requisites

        2) putting the following aries related bundles into the above three directories

        • third-party\aries\application
          org.apache.aries.application.api-1.0.0.jar
          org.apache.aries.application.default.local.platform-1.0.0.jar
          org.apache.aries.application.deployment.management-1.0.0.jar
          org.apache.aries.application.install-1.0.0.jar
          org.apache.aries.application.management-1.0.0.jar
          org.apache.aries.application.modeller-1.0.0.jar
          org.apache.aries.application.resolver.noop-1.0.0.jar
          org.apache.aries.application.resolver.obr-1.0.0.jar
          org.apache.aries.application.runtime-1.0.0.jar
          org.apache.aries.application.utils-1.0.0.jar
        • third-party\aries\blueprint
          org.apache.aries.blueprint.api-1.0.0.jar
          org.apache.aries.blueprint.core-1.0.0.jar
        • third-party\aries\pre-requisites
          org.apache.aries.proxy-1.0.0.jar
          org.apache.aries.util-1.0.0.jar
          org.apache.felix.bundlerepository.jar
          slf4j-api-1.5.11.jar
          slf4j-simple-1.5.11.jar

        3) add/modify the following into config\osgi.properties
        glassfish.osgi.auto.install=\
        $

        {com.sun.aas.installRootURI}modules/endorsed/ \
        ${com.sun.aas.installRootURI}

        modules/osgi-resource-locator.jar \
        $

        {com.sun.aas.installRootURI}modules/ \
        ${com.sun.aas.installRootURI}

        modules/autostart/ \
        $

        {com.sun.aas.installRootURI}modules/third-party/aries/pre-requisites/ \
        ${com.sun.aas.installRootURI}

        modules/third-party/aries/blueprint/ \
        $

        {com.sun.aas.installRootURI}modules/third-party/aries/application/

        aries.bundles=\
        ${com.sun.aas.installRootURI}

        modules/third-party/aries/pre-requisites/ \
        $

        {com.sun.aas.installRootURI}modules/third-party/aries/blueprint/ \
        ${com.sun.aas.installRootURI}

        modules/third-party/aries/application/

        glassfish.osgi.auto.start=\
        $

        {core.bundles}

        \
        $

        {autostart.bundles} \
        ${aries.bundles}

        glassfish.osgi.auto.start.level.2=${autostart.bundles}

        \
        $

        {aries.bundles}

        4) start-domain

        5) putting your eba into glassfish\domains\domain1\autodeploy\bundles

        6) using asadmin osgi lb to see whether the bundles in your eba have been deployed.

        I will give an detailed steps in my blog about how to play with it including an eba sample.

        [Analise]
        I said that I can not check in the above plan because,

        1) influence gf starting performance

        • Sahoo has removed org.apache.felix.bundlerepository.jar, however, I must put it back because of aries.
        • should not start these third-party bundles while starting gf, more reasonable doing is to start them while deploying eba.

        2) deployment can not recognize eba's deployment
        Currently, only executing "asadmin deploy --type=osgi .../xx.eba" has not any effect and causes failed deployment.So, must investigate
        how to make a bridge between deployment and aries eba deployment. Thus, we can resolve 1)'s issue.
        However, I have more urgent things, so I said this is my initial result.

        Thanks
        --Tang

        Show
        TangYong added a comment - - edited jthoennes CC: Sahoo Initial investigation has been ended. and I have an integration plan. However, can not check in the plan because having some issues. OK, I fistly said the integration plan. 1) creating three new directories in glassfish\modules third-party\aries\application third-party\aries\blueprint third-party\aries\pre-requisites 2) putting the following aries related bundles into the above three directories third-party\aries\application org.apache.aries.application.api-1.0.0.jar org.apache.aries.application.default.local.platform-1.0.0.jar org.apache.aries.application.deployment.management-1.0.0.jar org.apache.aries.application.install-1.0.0.jar org.apache.aries.application.management-1.0.0.jar org.apache.aries.application.modeller-1.0.0.jar org.apache.aries.application.resolver.noop-1.0.0.jar org.apache.aries.application.resolver.obr-1.0.0.jar org.apache.aries.application.runtime-1.0.0.jar org.apache.aries.application.utils-1.0.0.jar third-party\aries\blueprint org.apache.aries.blueprint.api-1.0.0.jar org.apache.aries.blueprint.core-1.0.0.jar third-party\aries\pre-requisites org.apache.aries.proxy-1.0.0.jar org.apache.aries.util-1.0.0.jar org.apache.felix.bundlerepository.jar slf4j-api-1.5.11.jar slf4j-simple-1.5.11.jar 3) add/modify the following into config\osgi.properties glassfish.osgi.auto.install=\ $ {com.sun.aas.installRootURI}modules/endorsed/ \ ${com.sun.aas.installRootURI} modules/osgi-resource-locator.jar \ $ {com.sun.aas.installRootURI}modules/ \ ${com.sun.aas.installRootURI} modules/autostart/ \ $ {com.sun.aas.installRootURI}modules/third-party/aries/pre-requisites/ \ ${com.sun.aas.installRootURI} modules/third-party/aries/blueprint/ \ $ {com.sun.aas.installRootURI}modules/third-party/aries/application/ aries.bundles=\ ${com.sun.aas.installRootURI} modules/third-party/aries/pre-requisites/ \ $ {com.sun.aas.installRootURI}modules/third-party/aries/blueprint/ \ ${com.sun.aas.installRootURI} modules/third-party/aries/application/ glassfish.osgi.auto.start=\ $ {core.bundles} \ $ {autostart.bundles} \ ${aries.bundles} glassfish.osgi.auto.start.level.2=${autostart.bundles} \ $ {aries.bundles} 4) start-domain 5) putting your eba into glassfish\domains\domain1\autodeploy\bundles 6) using asadmin osgi lb to see whether the bundles in your eba have been deployed. I will give an detailed steps in my blog about how to play with it including an eba sample. [Analise] I said that I can not check in the above plan because, 1) influence gf starting performance Sahoo has removed org.apache.felix.bundlerepository.jar, however, I must put it back because of aries. should not start these third-party bundles while starting gf, more reasonable doing is to start them while deploying eba. 2) deployment can not recognize eba's deployment Currently, only executing "asadmin deploy --type=osgi .../xx.eba" has not any effect and causes failed deployment.So, must investigate how to make a bridge between deployment and aries eba deployment. Thus, we can resolve 1)'s issue. However, I have more urgent things, so I said this is my initial result. Thanks --Tang
        Hide
        TangYong added a comment -

        jthoennes,

        For mixing OSGi and non-OSGi modules, Sahoo has done much.

        >Would this be also covered by the Apache Aries integration?
        I am investigating it. Pl. give me some time,

        There are some things needing to notice:

        1) my consideration is that we only integrate apache aries application(eba)(including part of blueprint) rather than all aries functions, because glassfish
        osgi-javaee has offered many features(eg. osgi jpa, osgi jta...), I must select minimized set while integrating eba.

        2) we must not influence current gf starting performance while integrating eba

        3) so far, I felt that we need to make a bridge between deployment and eba.

        Thanks
        --Tang

        Show
        TangYong added a comment - jthoennes, For mixing OSGi and non-OSGi modules, Sahoo has done much. >Would this be also covered by the Apache Aries integration? I am investigating it. Pl. give me some time, There are some things needing to notice: 1) my consideration is that we only integrate apache aries application(eba)(including part of blueprint) rather than all aries functions, because glassfish osgi-javaee has offered many features(eg. osgi jpa, osgi jta...), I must select minimized set while integrating eba. 2) we must not influence current gf starting performance while integrating eba 3) so far, I felt that we need to make a bridge between deployment and eba. Thanks --Tang

          People

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

            Dates

            • Created:
              Updated: