"Errors while creating SerializableLazyValue by reflection" when trying to set secure property as attribute before APIKit

332 views Asked by At

As explained in this question, I must set some attributes before APIKit. However, one of them is a secure property:

%dw 2.0
output application/java
---
(
    (attributes 
        - "headers"
        - "maskedRequestPath")
    ++
    ({ 
        headers: attributes.headers 
        ++ 
        { 
            xpto: p("secure::SOME-VALUE")
        }
    }) 
)
as Object {
    class: "org.mule.extension.http.api.HttpRequestAttributes"
}

Now I am getting below error:

""Exception happen while calling 'class org.mule.extension.http.api.HttpRequestAttributesBuilder.build()' method. Reason: Errors while creating org.mule.runtime.api.util.SerializableLazyValue by reflection, even when class in on classpath.'

5| (attributes | ... 19| }

Trace: at main (line: 5, column: 5)" evaluating expression: "%dw 2.0 output application/java --- ( (attributes - "headers" - "maskedRequestPath") ++ ({ headers: attributes.headers ++ { xpto: p("secure::SOME-VALUE") } }) ) as Object { class: "org.mule.extension.http.api.HttpRequestAttributes" }"."

Is there a way to solve this issue?

1

There are 1 answers

0
Harshank Bansal On BEST ANSWER

Seems like the field clientCertificate is creating problem. You can try removing them like you did with maskedRequestPath. Also want to mention that if you are using Mule 4.3 or later you can reduce your DataWeave using update operator

%dw 2.0
output application/java
---
((attributes - "maskedRequestPath" - "clientCertificate") update {
    case .headers.xpto! -> p("secure::SOME-VALUE")
}) as Object {
    class: "org.mule.extension.http.api.HttpRequestAttributes"
}