3 Replies Latest reply on May 22, 2013 9:56 AM by kcbabo

    Issues with Switchyard Service as EJB

    dragos.enachescu

      Hi,

       

      We have tried to implement the Switchyard services as EJBs (Switchyard 0.7 Final), instead of leaving them as basic CDI beans, because we thought of benefiting from the EJB bean pooling. These services are also promoted with SOAP binding.

       

      But configuring the services as EJBs caused some other issues:

      1. when trying to invoke a Switchyard service from another service using the WSDL reference provided by Switchyard: the requests from one service to the other are throttled down by the EJB thread pool and we observed poor performance. If we replaced the WSDL reference with CXF WSDL clients the performance improved the services were invoked through the web service endpoint instead of EJB invocation. Is it possible to still use the Switchyard’s native WSDL reference, but avoid hitting the EJB thread pool?
      2. As a result of the tests performed at the previous point, we tried to increase the EJB thread pool from 10 (the default value) to 15-30 threads, but doing this, we had another issue when invoking switchyard services from soapUI (so, the clients used during the tests were pure SOAP based) – we got a nullpointer as seen in the server log below (the 2 errors do not always appear, only from time to time and mostly when the number of concurrent clients is high - e.g. 30 soap clients):

       

      [Server:server-core-0] 16:42:35,045 WARN  [org.switchyard.internal.ExchangeImpl] (http-server04.localhost/192.168.0.4:9003-1) Fault generated during exchange without a handler: org.switchyard.HandlerException: java.lang.NullPointerException

      [Server:server-core-0]  --- Caused by java.lang.NullPointerException: null

      [Server:server-core-0] 16:42:35,857 ERROR [org.jboss.ws.common.invocation.InvocationHandlerJAXWS] (http-server04.localhost/192.168.0.4:9003-4) Method invocation failed with exception: null: java.lang.reflect.InvocationTargetException

      [Server:server-core-0]    at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source) [:1.7.0_09-icedtea]

      [Server:server-core-0]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:182)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:127)

      [Server:server-core-0]    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) [cxf-api-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207) [cxf-rt-transports-http-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:169)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)

      [Server:server-core-0]    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185) [cxf-rt-transports-http-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108) [cxf-rt-transports-http-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.1.Final-redhat-2.jar:1.0.1.Final-redhat-2]

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)

      [Server:server-core-0]    at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) [jbossws-spi-2.0.4.GA-redhat-1.jar:2.0.4.GA-redhat-1]

      [Server:server-core-0]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.1.Final-redhat-2.jar:1.0.1.Final-redhat-2]

      [Server:server-core-0]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      [Server:server-core-0]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      [Server:server-core-0]    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      [Server:server-core-0]    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      [Server:server-core-0]    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      [Server:server-core-0]    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      [Server:server-core-0]    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      [Server:server-core-0]    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)

      [Server:server-core-0]    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

      [Server:server-core-0]    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)

      [Server:server-core-0]    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)

      [Server:server-core-0]    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0] Caused by: java.lang.NullPointerException

      [Server:server-core-0]    at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source) [xercesImpl-2.9.1-redhat-3.jar:]

      [Server:server-core-0]    at org.apache.xerces.dom.ParentNode.item(Unknown Source) [xercesImpl-2.9.1-redhat-3.jar:]

      [Server:server-core-0]    at org.switchyard.config.DOMConfiguration.getFirstChild(DOMConfiguration.java:490) [switchyard-config-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.config.model.BaseModel.getFirstChildModel(BaseModel.java:270) [switchyard-config-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.config.model.composite.v1.V1BindingModel.getMessageComposer(V1BindingModel.java:144) [switchyard-config-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.config.model.SOAPBindingModel.getSOAPMessageComposer(SOAPBindingModel.java:100) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.InboundHandler.invoke(InboundHandler.java:201) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:113) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:43) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    ... 36 more

      [Server:server-core-0]

      [Server:server-core-0] 16:42:35,890 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-server04.localhost/192.168.0.4:9003-4) Application {http://www.openuri.org/}BS_FRONTEND#{http://www.openuri.org/}FRONTEND has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.JBossWSInvoker.createFault(JBossWSInvoker.java:247)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:202)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:127)

      [Server:server-core-0]    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) [cxf-api-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-rt-core-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207) [cxf-rt-transports-http-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:169)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)

      [Server:server-core-0]    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185) [cxf-rt-transports-http-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108) [cxf-rt-transports-http-2.4.9-redhat-2.jar:2.4.9-redhat-2]

      [Server:server-core-0]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.1.Final-redhat-2.jar:1.0.1.Final-redhat-2]

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)

      [Server:server-core-0]    at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) [jbossws-spi-2.0.4.GA-redhat-1.jar:2.0.4.GA-redhat-1]

      [Server:server-core-0]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.1.Final-redhat-2.jar:1.0.1.Final-redhat-2]

      [Server:server-core-0]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

      [Server:server-core-0]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

      [Server:server-core-0]    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

      [Server:server-core-0]    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

      [Server:server-core-0]    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

      [Server:server-core-0]    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      [Server:server-core-0]    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      [Server:server-core-0]    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)

      [Server:server-core-0]    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

      [Server:server-core-0]    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)

      [Server:server-core-0]    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)

      [Server:server-core-0]    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0] Caused by: java.lang.NullPointerException

      [Server:server-core-0]    at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source) [xercesImpl-2.9.1-redhat-3.jar:]

      [Server:server-core-0]    at org.apache.xerces.dom.ParentNode.item(Unknown Source) [xercesImpl-2.9.1-redhat-3.jar:]

      [Server:server-core-0]    at org.switchyard.config.DOMConfiguration.getFirstChild(DOMConfiguration.java:490) [switchyard-config-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.config.model.BaseModel.getFirstChildModel(BaseModel.java:270) [switchyard-config-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.config.model.composite.v1.V1BindingModel.getMessageComposer(V1BindingModel.java:144) [switchyard-config-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.config.model.SOAPBindingModel.getSOAPMessageComposer(SOAPBindingModel.java:100) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.InboundHandler.invoke(InboundHandler.java:201) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:113) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:43) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

      [Server:server-core-0]    at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source) [:1.7.0_09-icedtea]

      [Server:server-core-0]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_09-icedtea]

      [Server:server-core-0]    at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)

      [Server:server-core-0]    at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:182)

      [Server:server-core-0]    ... 31 more

      [Server:server-core-0]

       

      Can you please give some suggestions on the above?

       

      Thank you in advance

       

      Best regards,

      Dragos

        • 1. Re: Issues with Switchyard Service as EJB
          kcbabo

          EJBs as bean service providers is not a use case we have specifically targeted in SY up to this point.  You may hit a few issues as you blaze this trail, but I think it's an interesting path.

           

          I need to see the app to answer question #1.  There's nothing special about interface.wsdl w/r/t routing and wiring, so I suspect that CDI is wiring the bean references directly. 

           

          For question #2, you have discovered a bug in the InboundHandler of SOAP gateway:

          https://issues.jboss.org/browse/SWITCHYARD-1499


          The window for this error is pretty small, which explains why you only see occasionally under load.

          • 2. Re: Issues with Switchyard Service as EJB
            dragos.enachescu

            Hi Keith,

             

            Thank you for the feedback.

             

            The main reasons for which we elected to use the EJBs was because we want a way to "throttle" down the requests per application and using EJB we can make use of the Bean pool provided by the container (which is more or less what we needed). But we would come back to CDI beans if we could find a way to achieve the same "throttling"/pooling of beans without managing them ourselves. Do you know other way in Switchyard to achive this?

             

            For the question #1, we will prepare a simple service to illustrate our use case and come back to you.

             

            Regards

            • 3. Re: Issues with Switchyard Service as EJB
              kcbabo

              To answer the pooling question directly : no, there is not a pooling mechanism native to CDI (AFAIK) and we don't provide one in SY.  Bean services are application scoped at this point, so there will be one instance of the service for the application.  Invocation of bean service methods is *not* synchronized, so I wouldn't expect pooling to make a significant difference there unless the execution-time is quite long and you exhaust gateway threads to process more incoming messages.


              We will be adding throttling as a gateway configuration item in 1.0, so that will help with throttling down.