com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL: HTTP Client with JSON CONNECTOR: Destination 1 SCRIPT SOURCE: response SOURCE CODE: 39: } 40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 41: } 42: } 43: function doScript() { 44: msg = JSON.parse(connectorMessage.getResponseTransformedData()); 45: function doTransform() { 46: 47: 48: var mapping; LINE NUMBER: 44 DETAILS: SyntaxError: Unexpected token: o at d89555a6-f1d2-4738-a164-48b213af267f:44 (doScript) at d89555a6-f1d2-4738-a164-48b213af267f:91

Mirth Project | Eric Butterfield | 11 months ago
  1. 0

    Not sure if this is at all related to MIRTH-3824... In version 3.3.0, you could put a JSON object into a Response object, and choose that response in your source connector, and everything would work just fine. When you viewed the response message (whether in the receiving channel's source or the sending channel's destination), you would correctly see the JSON object that was put into the response. So, for example, you could do something like this in the Postprocessor, and respond from the Postprocessor: var jsonObj = { "result": "This is the result.", "data": "This is some other data." } return ResponseFactory.getSentResponse(jsonObj); However, it's no longer working this way in 3.3.1. Now, when you look at the response message in the message view, you see: [object Object] And if you try to use the response in a response transformer, you get an error like this: Response Transformer error ERROR MESSAGE: Error evaluating response transformer com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL: HTTP Client with JSON CONNECTOR: Destination 1 SCRIPT SOURCE: response SOURCE CODE: 39: } 40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 41: } 42: } 43: function doScript() { 44: msg = JSON.parse(connectorMessage.getResponseTransformedData()); 45: function doTransform() { 46: 47: 48: var mapping; LINE NUMBER: 44 DETAILS: SyntaxError: Unexpected token: o at d89555a6-f1d2-4738-a164-48b213af267f:44 (doScript) at d89555a6-f1d2-4738-a164-48b213af267f:91 at com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call(JavaScriptResponseTransformer.java:160) at com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call(JavaScriptResponseTransformer.java:118) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) I've attached a couple of channels (an HTTP Sender that sends to an HTTP Listener with JSON as the data type) that demonstrate this. The channels work perfectly fine under 3.3.0, but cause an error under 3.3.1.

    Mirth Project | 11 months ago | Eric Butterfield
    com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL: HTTP Client with JSON CONNECTOR: Destination 1 SCRIPT SOURCE: response SOURCE CODE: 39: } 40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 41: } 42: } 43: function doScript() { 44: msg = JSON.parse(connectorMessage.getResponseTransformedData()); 45: function doTransform() { 46: 47: 48: var mapping; LINE NUMBER: 44 DETAILS: SyntaxError: Unexpected token: o at d89555a6-f1d2-4738-a164-48b213af267f:44 (doScript) at d89555a6-f1d2-4738-a164-48b213af267f:91
  2. 0

    Not sure if this is at all related to MIRTH-3824... In version 3.3.0, you could put a JSON object into a Response object, and choose that response in your source connector, and everything would work just fine. When you viewed the response message (whether in the receiving channel's source or the sending channel's destination), you would correctly see the JSON object that was put into the response. So, for example, you could do something like this in the Postprocessor, and respond from the Postprocessor: var jsonObj = { "result": "This is the result.", "data": "This is some other data." } return ResponseFactory.getSentResponse(jsonObj); However, it's no longer working this way in 3.3.1. Now, when you look at the response message in the message view, you see: [object Object] And if you try to use the response in a response transformer, you get an error like this: Response Transformer error ERROR MESSAGE: Error evaluating response transformer com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL: HTTP Client with JSON CONNECTOR: Destination 1 SCRIPT SOURCE: response SOURCE CODE: 39: } 40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 41: } 42: } 43: function doScript() { 44: msg = JSON.parse(connectorMessage.getResponseTransformedData()); 45: function doTransform() { 46: 47: 48: var mapping; LINE NUMBER: 44 DETAILS: SyntaxError: Unexpected token: o at d89555a6-f1d2-4738-a164-48b213af267f:44 (doScript) at d89555a6-f1d2-4738-a164-48b213af267f:91 at com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call(JavaScriptResponseTransformer.java:160) at com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call(JavaScriptResponseTransformer.java:118) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) I've attached a couple of channels (an HTTP Sender that sends to an HTTP Listener with JSON as the data type) that demonstrate this. The channels work perfectly fine under 3.3.0, but cause an error under 3.3.1.

    Mirth Project | 11 months ago | Eric Butterfield
    com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL: HTTP Client with JSON CONNECTOR: Destination 1 SCRIPT SOURCE: response SOURCE CODE: 39: } 40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 41: } 42: } 43: function doScript() { 44: msg = JSON.parse(connectorMessage.getResponseTransformedData()); 45: function doTransform() { 46: 47: 48: var mapping; LINE NUMBER: 44 DETAILS: SyntaxError: Unexpected token: o at d89555a6-f1d2-4738-a164-48b213af267f:44 (doScript) at d89555a6-f1d2-4738-a164-48b213af267f:91
  3. 0

    How to consume simple SOAP webservice through MirthConnect? - Mirth Community

    mirthcorp.com | 8 months ago
    com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL: wsdl_reader CONNECTOR: currency service SCRIPT SOURCE: response SOURCE CODE: 20: } 21: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 22: } 23: } 24: function doScript() { 25: msg = new XML(connectorMessage.getResponseTransformedData()); 26: if (msg.namespace('') != undefined) { default xml namespace = msg.namespace(''); } else { default xml namespace = ''; } 27: function doTransform() { 28: 29: LINE NUMBER: 25 at 304423fc-979c-4676-b2dd-48b7499bb9e3:25 (doScript) at 304423fc-979c-4676-b2dd-48b7499bb9e3:37
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I use the following code in my PreProcessor under a Mirth Connect Channel: // initialize a first_iteration flag. // we don't want to add a carriage return // before the MSH segment var first_iteration = true; // initialize the new message as an empty string var new_message = ''; // loop over each line in the message // by splitting on the hl7 standard carriage return for each (var line in message.split(/\r/)) { // if it is a valid hl7 segment, we'll // append the new line to the new message logger.error(line); if(line.match(/^[a-zA-Z0-9]{3}\|/)) { // see the first comment if( ! first_iteration){ new_message += '\r'; } new_message += line; } else { // if it isn't a valid hl7 segment, // we'll append it to the end of the // previous segment instead new_message += ' ' + line; } // it will never be the first_iteration again first_iteration = false; } logger.error(new_message); new_message = new_message.replace(/[']{1}/gi,"''"); new_message = new_message.replace(/[\x08]{1}/gi,""); //Look for the Backspace character //send the fixed message to the channel message = new_message; return message; I GET THE FOLLOWING ERROR MESSAGE: Preprocessor Script error ERROR MESSAGE: Error running preprocessor scripts com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}\|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:490) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:184) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

    Mirth Project | 3 years ago | Ivan Olmos
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}\|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72
  6. 0

    I use the following code in my PreProcessor under a Mirth Connect Channel: // initialize a first_iteration flag. // we don't want to add a carriage return // before the MSH segment var first_iteration = true; // initialize the new message as an empty string var new_message = ''; // loop over each line in the message // by splitting on the hl7 standard carriage return for each (var line in message.split(/\r/)) { // if it is a valid hl7 segment, we'll // append the new line to the new message logger.error(line); if(line.match(/^[a-zA-Z0-9]{3}\|/)) { // see the first comment if( ! first_iteration){ new_message += '\r'; } new_message += line; } else { // if it isn't a valid hl7 segment, // we'll append it to the end of the // previous segment instead new_message += ' ' + line; } // it will never be the first_iteration again first_iteration = false; } logger.error(new_message); new_message = new_message.replace(/[']{1}/gi,"''"); new_message = new_message.replace(/[\x08]{1}/gi,""); //Look for the Backspace character //send the fixed message to the channel message = new_message; return message; I GET THE FOLLOWING ERROR MESSAGE: Preprocessor Script error ERROR MESSAGE: Error running preprocessor scripts com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}\|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:490) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:184) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

    Mirth Project | 3 years ago | Ivan Olmos
    com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE: 36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}\|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mirth.connect.server.MirthJavascriptTransformerException

      CHANNEL: HTTP Client with JSON CONNECTOR: Destination 1 SCRIPT SOURCE: response SOURCE CODE: 39: } 40: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')'); 41: } 42: } 43: function doScript() { 44: msg = JSON.parse(connectorMessage.getResponseTransformedData()); 45: function doTransform() { 46: 47: 48: var mapping; LINE NUMBER: 44 DETAILS: SyntaxError: Unexpected token: o at d89555a6-f1d2-4738-a164-48b213af267f:44 (doScript) at d89555a6-f1d2-4738-a164-48b213af267f:91

      at com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call()
    2. com.mirth.connect
      JavaScriptResponseTransformer$ResponseTransformerTask.call
      1. com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call(JavaScriptResponseTransformer.java:160)
      2. com.mirth.connect.server.transformers.JavaScriptResponseTransformer$ResponseTransformerTask.call(JavaScriptResponseTransformer.java:118)
      2 frames
    3. Java RT
      Thread.run
      1. java.util.concurrent.FutureTask.run(Unknown Source)
      2. java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      3. java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      4. java.lang.Thread.run(Unknown Source)
      4 frames