代码之家  ›  专栏  ›  技术社区  ›  Yan Khonski

Mule ESB不适用于cookie

  •  0
  • Yan Khonski  · 技术社区  · 6 年前

    我使用Mule ESB3.7.0。

    我有一个应用程序A,它向mule esb发送一个http请求,然后将其转发给应用程序B。应用程序B将响应发送回mule esb,mule esb将其发送回应用程序A。一切正常。

    然后有一天,应用程序B用一个cookie(JSESSIONID,但这无关紧要)发送http响应,应用程序a抛出超时异常我调试了mule esb并找到了这个。

    org.mule.transport.http.transformers.MuleMessageToHttpResponse->
        protected HttpResponse createResponse(Object src, String encoding, MuleMessage msg) throws IOException, TransformerException
    

    这个方法失败了。243号线

        for (String headerName : headerNames) {
            if (HttpConstants.HEADER_COOKIE_SET.equals(headerName))
            {
                // TODO This have to be improved. We shouldn't have to look in all
                // scopes
                Object cookiesObject = msg.getInvocationProperty(headerName);
                if (cookiesObject == null)
                {
                    cookiesObject = msg.getOutboundProperty(headerName);
                }
                if (cookiesObject == null)
                {
                    cookiesObject = msg.getInboundProperty(headerName);
                }
                if (cookiesObject == null)
                {
                    continue;
                }
    
                if (!(cookiesObject instanceof Cookie[]))
                {
                    response.addHeader(new Header(headerName, cookiesObject.toString()));
                }
                else
                {
                    Cookie[] arrayOfCookies = CookieHelper.asArrayOfCookies(cookiesObject);
                    for (Cookie cookie : arrayOfCookies)
                    {
                        /////////// THIS ONE FAILS
                        response.addHeader(new Header(headerName,
                            CookieHelper.formatCookieForASetCookieHeader(cookie)));
                    }
                }
            }
            else
            {
                Object value = msg.getOutboundProperty(headerName);
                if (value == null)
                {
                    value = msg.getInvocationProperty(headerName);
                }
                if (value != null)
                {
                    response.setHeader(new Header(headerName, value.toString()));
                }
            }
       }
    

    org.mule.transport.http.CookieHelper 有编译错误。 enter image description here

    org.apache.tomcat.util.http.ServerCookie.appendCookieValue(Ljava/lang/StringBuffer;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZZ)V
    java.lang.NoSuchMethodError: org.apache.tomcat.util.http.ServerCookie.appendCookieValue(Ljava/lang/StringBuffer;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZZ)V
        at org.mule.transport.http.CookieHelper.formatCookieForASetCookieHeader(CookieHelper.java:319)
        at org.mule.transport.http.transformers.MuleMessageToHttpResponse.createResponse(MuleMessageToHttpResponse.java:272)
        at org.mule.transport.http.transformers.MuleMessageToHttpResponse.transformMessage(MuleMessageToHttpResponse.java:109)
        at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:141)
        at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:89)
        at org.mule.DefaultMuleMessage.transformMessage(DefaultMuleMessage.java:1602)
        at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:1509)
        at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1487)
        at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1470)
        at org.mule.transport.AbstractMessageReceiver.applyResponseTransformers(AbstractMessageReceiver.java:260)
        at org.mule.transport.AbstractMessageReceiver.routeEvent(AbstractMessageReceiver.java:532)
        at org.mule.transport.AbstractTransportMessageProcessTemplate.routeEvent(AbstractTransportMessageProcessTemplate.java:72)
        at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:76)
        at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:63)
        at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
        at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:35)
        at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:22)
        at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
        at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
        at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67)
        at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
        at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
        at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
        at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
        at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
        at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
        at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
        at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:110)
        at org.mule.execution.FlowProcessingPhase$1.run(FlowProcessingPhase.java:62)
        at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
        at org.mule.work.WorkerContext.run(WorkerContext.java:286)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    

    类似的问题(不是重复的,因为我有不同版本的mule) NoSuchMethodError in Tomcat embedded MULE when executing http:set-cookie

    我也读过这个 https://www.mulesoft.org/jira/browse/MULE-6705

    1 回复  |  直到 6 年前
        1
  •  0
  •   Yan Khonski    6 年前

    原来,问题出在图书馆。我们使用SpringBoot,它有依赖项,其中一个覆盖了Coyote的版本。

    provided group: 'org.apache.tomcat', name: 'coyote', version: '6.0.44'

    enter image description here

    在springboot中,它使用了嵌入式tomcat内核。

    compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.0.28'

    enter image description here