glassfish
  1. glassfish
  2. GLASSFISH-18370

OSGi Services injected with CDI have their exceptions wrapped..

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1.2_b21
    • Fix Version/s: 4.0
    • Component/s: cdi, OSGi, OSGi-JavaEE
    • Labels:
      None

      Description

      When injecting an OSGi Service with methods that declare they throw exceptions.

      The CDI wrapper does not unwrap them before throwing them back up.

      In org.glassfish.osgicdi.impl.OSGiServiceFactory$DynamicInvocationHandler.invoke()

      line 185: return method.invoke(instanceToUse, args);

      should really be something like..

      try { 
         return method.invoke(instanceToUse, args);
      } catch ( final InvocationTargetException e ) {
         throw e.getCause();
      }
      

      Might want to check for getCause() == null too, but you get the idea..

      [#|2012-02-14T18:57:23.082-0500|SEVERE|glassfish3.1.2|com.sun.jersey.spi.container.ContainerResponse|_ThreadID=174;_ThreadName=Thread-2;|Mapped exception to response: 500 (Internal Server Error)
      javax.ws.rs.WebApplicationException: java.lang.reflect.UndeclaredThrowableException
      	at com.mm.ws.optin.OptInResource.initiate(OptInResource.java:90)
      	at com.mm.ws.optin.OptInResource$Proxy$_$$_WeldClientProxy.initiate(OptInResource$Proxy$_$$_WeldClientProxy.java)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
      	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
      	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
      	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
      	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
      	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
      	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
      	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
      	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
      	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
      	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
      	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
      	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
      	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
      	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
      	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
      	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
      	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
      	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
      	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      	at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.reflect.UndeclaredThrowableException
      	at $Proxy217.initiateOptIn(Unknown Source)
      	at com.mm.ws.optin.OptInResource.initiate(OptInResource.java:55)
      	... 44 more
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.GeneratedMethodAccessor614.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.glassfish.osgicdi.impl.OSGiServiceFactory$DynamicInvocationHandler.invoke(OSGiServiceFactory.java:234)
      	... 46 more
      Caused by: com.mm.service.optin.InvalidCampaignIdentifierException: campaignIdentifier cannot be empty or null
      	at com.mm.service.optin.impl.OptInServiceImpl.initiateOptIn(OptInServiceImpl.java:63)
      	at sun.reflect.GeneratedMethodAccessor614.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      	at $Proxy216.initiateOptIn(Unknown Source)
      	... 50 more
      
      

        Activity

        Hide
        Sivakumar Thyagarajan added a comment -

        This patch looks good to me too. I will commit this changes soon and update this issue.

        Show
        Sivakumar Thyagarajan added a comment - This patch looks good to me too. I will commit this changes soon and update this issue.
        Hide
        Sanjeeb Sahoo added a comment -

        Tang,

        When you have time, please submit add a test case for this in FighterFish test suite [1]?

        Thanks,
        Sahoo

        [1] https://wikis.oracle.com/pages/viewpage.action?pageId=36438159

        Show
        Sanjeeb Sahoo added a comment - Tang, When you have time, please submit add a test case for this in FighterFish test suite [1] ? Thanks, Sahoo [1] https://wikis.oracle.com/pages/viewpage.action?pageId=36438159
        Hide
        TangYong added a comment -

        Hi sahoo, siva,

        Please see attachment and I have added a test case for the issue and ran successuflly.

        Show
        TangYong added a comment - Hi sahoo, siva, Please see attachment and I have added a test case for the issue and ran successuflly.
        Hide
        Sanjeeb Sahoo added a comment -

        I am applying the patch.

        Show
        Sanjeeb Sahoo added a comment - I am applying the patch.
        Hide
        Sanjeeb Sahoo added a comment -

        Applying patch supplied by Tang Yong.
        Sending module/osgi-cdi/src/main/java/org/glassfish/osgicdi/impl/OSGiServiceFactory.java
        Sending test/it/ExpectedTestResult.txt
        Sending test/it/src/test/java/org/glassfish/fighterfish/test/it/T2_Test.java
        Sending test/testapp/pom.xml
        Adding test/testapp/test.app20
        Adding test/testapp/test.app20/README.xml
        Adding test/testapp/test.app20/osgi.properties
        Adding test/testapp/test.app20/pom.xml
        Adding test/testapp/test.app20/src
        Adding test/testapp/test.app20/src/main
        Adding test/testapp/test.app20/src/main/java
        Adding test/testapp/test.app20/src/main/java/org
        Adding test/testapp/test.app20/src/main/java/org/glassfish
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/SimpleServiceActivator.java
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/SimpleStockQuoteServiceImpl.java
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/StockQuoteService.java
        Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/StockQuoteServlet.java
        Adding test/testapp/test.app20/src/main/webapp
        Adding test/testapp/test.app20/src/main/webapp/WEB-INF
        Adding test/testapp/test.app20/src/main/webapp/WEB-INF/beans.xml
        Adding test/testapp/test.app20/src/test
        Adding test/testapp/test.app20/src/test/java
        Adding test/testapp/test.app20/src/test/java/org
        Adding test/testapp/test.app20/src/test/java/org/glassfish
        Adding test/testapp/test.app20/src/test/java/org/glassfish/fighterfish
        Adding test/testapp/test.app20/src/test/java/org/glassfish/fighterfish/test
        Adding test/testapp/test.app20/src/test/java/org/glassfish/fighterfish/test/app20
        Transmitting file data ............
        Committed revision 56653.

        Show
        Sanjeeb Sahoo added a comment - Applying patch supplied by Tang Yong. Sending module/osgi-cdi/src/main/java/org/glassfish/osgicdi/impl/OSGiServiceFactory.java Sending test/it/ExpectedTestResult.txt Sending test/it/src/test/java/org/glassfish/fighterfish/test/it/T2_Test.java Sending test/testapp/pom.xml Adding test/testapp/test.app20 Adding test/testapp/test.app20/README.xml Adding test/testapp/test.app20/osgi.properties Adding test/testapp/test.app20/pom.xml Adding test/testapp/test.app20/src Adding test/testapp/test.app20/src/main Adding test/testapp/test.app20/src/main/java Adding test/testapp/test.app20/src/main/java/org Adding test/testapp/test.app20/src/main/java/org/glassfish Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20 Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/SimpleServiceActivator.java Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/SimpleStockQuoteServiceImpl.java Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/StockQuoteService.java Adding test/testapp/test.app20/src/main/java/org/glassfish/fighterfish/test/app20/StockQuoteServlet.java Adding test/testapp/test.app20/src/main/webapp Adding test/testapp/test.app20/src/main/webapp/WEB-INF Adding test/testapp/test.app20/src/main/webapp/WEB-INF/beans.xml Adding test/testapp/test.app20/src/test Adding test/testapp/test.app20/src/test/java Adding test/testapp/test.app20/src/test/java/org Adding test/testapp/test.app20/src/test/java/org/glassfish Adding test/testapp/test.app20/src/test/java/org/glassfish/fighterfish Adding test/testapp/test.app20/src/test/java/org/glassfish/fighterfish/test Adding test/testapp/test.app20/src/test/java/org/glassfish/fighterfish/test/app20 Transmitting file data ............ Committed revision 56653.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: