Skip to Content

Payload Logging with Groovy Script: java.lang.NoSuchMethodException: No signature of method

Hello,

I am trying to log payloads in an integration flow using the following code in a groovy script step:import com.sap.gateway.ip.core.customdev.util.Message;

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){
        messageLog.addAttachmentAsString("Payload", body, "text/plain");
     }
    return message;
}

When executing the integration flow the following error appears in monitoring:

Message processing failed.

java.lang.NoSuchMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.Log message payload() is applicable for argument types: (com.sap.gateway.ip.core.customdev.processor.MessageImpl) values: [com.sap.gateway.ip.core.customdev.processor.MessageImpl@5b15080c]

Does anyone have an idea what is causing this or if there is a problem in the code itself?

Thank you for your help!

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2017 at 01:03 AM

    Hi Florian,

    Can you please post a screenshot which shows the details of your Groovy script artifact?

    This piece of code works for me:

    import com.sap.gateway.ip.core.customdev.util.Message;
    def Message processData(Message message) {
        def body = message.getBody(java.lang.String) as String;
        def messageLog = messageLogFactory.getMessageLog(message);
        if(messageLog != null){
            messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment")
            messageLog.addAttachmentAsString("ResponsePayload1:", body, "text/plain");
         }
        return message;
    }

    Regards,

    Prasanna


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 12, 2017 at 06:56 AM

    Is there really a Need for logging the payload with Groovy script? I'm quite new to SCPI, so be lenient with me, if you happen to be able to reproduce the wanted message at any time, traceing might be easier, especially since it will persist payload at any message step. Backdraw would be, that it is only on for 10 minutes, so no Long term logging there.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.