elias
elias

Reputation: 15480

Script mediator giving 'ContentID is null' error

I'm trying to edit the payload with a script mediator, but it's giving this error:

TID: [0] [ESB] [2014-02-26 11:55:31,709] ERROR {org.apache.axis2.transport.base.threads.NativeWorkerPool} -  Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool}
java.lang.RuntimeException: ContentID is null
    at org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:360)
    at org.apache.synapse.mediators.bsf.ScriptMediator.prepareExternalScript(ScriptMediator.java:366)
    at org.apache.synapse.mediators.bsf.ScriptMediator.mediateWithExternalScript(ScriptMediator.java:244)
    at org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:212)
    at org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:187)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
    at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:154)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:434)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:219)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

The code:

<script language="js" key="conf:SecHeaderGenerator.js" function="getBodyWithSecHeader" />

The javascript file:

function getBodyWithSecHeader(mc)
{
  var body = mc.getPayloadXML();

  var time = new Date().format("yyyy-MM-dd'T'HH:mm:ss+0300");
  var user = 'user';
  var domain = 'testdomain';
  var password = 'pass';
  var encoded = hex_md5(time + hex_md5(password)).toLowerCase();

  mc.setPayloadXML(
    <set_message_status>
      <user>
        <now>{time}</now>
        <login>{user}</login>
        <company>{domain}</company>
        <auth_string>{encoded}</auth_string>
      </user>
      {body}
    </set_message_status>);

    return mc.getPayloadXML();
}
[...] 

Why this error occurs? I'm using WSO2 ESB 4.6.0.

UPDATE

Trying exactly the same scenario with another copy of the ESB with the same version, it works normally.

Upvotes: 0

Views: 1218

Answers (1)

elias
elias

Reputation: 15480

I found the solution. The problem was that the media-type of the javascript file was text/plain instead application/javascript.

Upvotes: 1

Related Questions