Topic
  • 7 replies
  • Latest Post - ‏2013-08-19T19:45:23Z by Dae Young
Dae Young
Dae Young
430 Posts

Pinned topic TeamworksException unterminated string literal

‏2013-08-14T20:29:30Z |

Good afternoon,

I have to apologize first posting very vague exception. My team member and I built a BPM application that have multiple processes. Deployed to BPM v8.0.1.1 environment. Tested well in one environment let's say A then passed it to another environment called B. One of the process calls RESTful Web Service which returns back json object and we parse it out then move on. It worked just fine in the environment A, but it broke in the environment B after parsing the json object it seems like. Unfortunately in the environment B I can not debug the deployed application.

When I viewed SystemOut.log file and following exception got captured and I don't think it has to do with javascript I wrote b/c it usually tells me where it breaks by naming the server side script and shows variable names I created, but none of them show up and again it worked in the environment A where I and my team member developed and tested (test went fine via a dedicated test engineer). I am curious at this point has anyone seen following exception and knows when it throws.

#######################################################

TeamworksjavaScriptException created non-nested. Error: [TeamworksException name='SyntaxError', message='SyntaxError: unterminated string literal ([JSScript>#1(eval)#1)', line=1, pos=182 nested=<none>]........

com.lobardisoftware.core.script.js.javaScriptRunner.execute(JavaScriptRunner.java:280) at .....
......

SessionManage I org.cometd.server.AbstractService exception Exception while invoking session#public ovid com.ibm.bpm.socialbus.session.SessionManager.handleMessage(org.cometd.bayeus.server.ServerSession.org.cometd.bayeux.Message) from BPM_JMS_BAYEUX_BRIDGE_4cvfcnjo6v8lq4x88lztsmqbv - last connect 0 ms ago with {channel=/bpm/notifications/collaboration/t811/3028......../EDITOR_CHANGE, data={editorID=.....}} java.lang.reflect.InvocationTargetException ....

...

Caused by: java.lang.NullPointerException at com.ibm.bpm.socialbus.session.SessionManager.handleMessage(SessionManager.java:84)...

#####################################################

Thank you and have a blessed day.

Sincerely,

Dae
 

  • kolban
    kolban
    3322 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-14T21:04:31Z  

    I get the sense that there may be something wrong in the data coming back from the REST service.  You are executing a JavaScript "eval" against the returned data and it may be that the data you are "evaling" is bad.  You might consider logging the data you are evaling and see if there is anything "odd" about it.

    Neil

  • Dae Young
    Dae Young
    430 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-16T11:16:30Z  
    • kolban
    • ‏2013-08-14T21:04:31Z

    I get the sense that there may be something wrong in the data coming back from the REST service.  You are executing a JavaScript "eval" against the returned data and it may be that the data you are "evaling" is bad.  You might consider logging the data you are evaling and see if there is anything "odd" about it.

    Neil

    Neil,

    Hope you get this reply back finally. I've been trying many times yesterday, but the system didn't allow me to write for whatever the reasons.

    When you mentioned eval(), I knew where to go and look at the problem. Although data coming back from two different environments looked exactly same, in one instance eval() intrepreted it correctly, but it looks like the other instance didn't. I will keep looking into it.

    Thank you again for your advice and have a blessed day.

    Dae

  • kolban
    kolban
    3322 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-16T12:19:11Z  
    • Dae Young
    • ‏2013-08-16T11:16:30Z

    Neil,

    Hope you get this reply back finally. I've been trying many times yesterday, but the system didn't allow me to write for whatever the reasons.

    When you mentioned eval(), I knew where to go and look at the problem. Although data coming back from two different environments looked exactly same, in one instance eval() intrepreted it correctly, but it looks like the other instance didn't. I will keep looking into it.

    Thank you again for your advice and have a blessed day.

    Dae

    Dae,

    The use of "eval" seems to be quite contentious.  See for example:

    http://www.w3resource.com/javascript/functions/eval-function.php

    If you are parsing a JSON data structure, it appears that there are some other more elegant ways to achieve this.  I see references to a package called "JSON.parse" which might be safer and more useful.  It always makes me nervous when we take in a "string" of data and say "execute that string".  I wouldn't have to be much of a rocket science hacker to see that I could potentially inject some malicious code for execution at that point.

    Neil

  • Dae Young
    Dae Young
    430 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-16T13:37:39Z  
    • kolban
    • ‏2013-08-16T12:19:11Z

    Dae,

    The use of "eval" seems to be quite contentious.  See for example:

    http://www.w3resource.com/javascript/functions/eval-function.php

    If you are parsing a JSON data structure, it appears that there are some other more elegant ways to achieve this.  I see references to a package called "JSON.parse" which might be safer and more useful.  It always makes me nervous when we take in a "string" of data and say "execute that string".  I wouldn't have to be much of a rocket science hacker to see that I could potentially inject some malicious code for execution at that point.

    Neil

    Neil,

    Thanks for the reference! I will definltely look into other option as you said if indeed eval() is the one causing a trouble in our environment.

    Glad that you got my message back. Usually IE is a trouble not FireFox, but this time IE is my friend b/c I can put reply back to you and others.

    Have a blessed day!

    Dae

  • AndrewPaier
    AndrewPaier
    847 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-19T15:45:32Z  
    • Dae Young
    • ‏2013-08-16T13:37:39Z

    Neil,

    Thanks for the reference! I will definltely look into other option as you said if indeed eval() is the one causing a trouble in our environment.

    Glad that you got my message back. Usually IE is a trouble not FireFox, but this time IE is my friend b/c I can put reply back to you and others.

    Have a blessed day!

    Dae

    Dae -

    Can you post the code that is causing the problem.  Also the data it is choking on.  Any chance there is some difference between the 2 environments as to the details of the data?  This feels like the types of problems I've seen in SQL where someone wasn't ready for a random apostrophe in the data so someone writing "don't" cause the SQL to break since they didn't use a parameterized query and the SQL saw the apostrophe as the end of a string.

    It would eliminate that as a possibility if you were to log out the JSON before parsing it so we could see in the logs exactly the string that is causing the probem

    As a side note, I've found no browser dependable for posting to the forum, but apparently if I go through the "you were logged out, please log in" dialog 3 times for every post it eventually works.

    Andrew Paier  |  Director  |  BP3 Global, Inc.
    BP3 Global's Website  |  Twitter  |  Linkedin  |  Google+  |  Blogs

  • Dae Young
    Dae Young
    430 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-19T19:14:00Z  

    Dae -

    Can you post the code that is causing the problem.  Also the data it is choking on.  Any chance there is some difference between the 2 environments as to the details of the data?  This feels like the types of problems I've seen in SQL where someone wasn't ready for a random apostrophe in the data so someone writing "don't" cause the SQL to break since they didn't use a parameterized query and the SQL saw the apostrophe as the end of a string.

    It would eliminate that as a possibility if you were to log out the JSON before parsing it so we could see in the logs exactly the string that is causing the probem

    As a side note, I've found no browser dependable for posting to the forum, but apparently if I go through the "you were logged out, please log in" dialog 3 times for every post it eventually works.

    Andrew Paier  |  Director  |  BP3 Global, Inc.
    BP3 Global's Website  |  Twitter  |  Linkedin  |  Google+  |  Blogs

    Good afternoon Andrew,

    Thanks for your reply and sharing the trouble you ran into. I will keep it in my mind in case I would run into similar situation.

    System engineers in a team I belong to found an answer for it with the help of IBM SME. Handling JSON data was correct at a service level and eval() was not the cause of the trouble rather it has to do with a certificate in the environment B, but exception handling at the integration service level was not correct b/c it could not catch it I believe if ssl related exception was thrown in the environment B. I made an appropriate change, but need some advice.

    Below code comes from a java class that is wrapped in a jar file attached to the deployed bpm application.  The "urlString" contains https protocol and points to restful web service for GET call which returns json data if everything goes ok. If the server is down I know for sure it throws IOException. What if ssl hand shake is failed. The line where it calls url.openConnection() would throw IOException?

    public String callBackEndToGetJsonData(String urlString,SomeDataType var1) throws IOException {

    try {

    url = new URL(urlString);

    urlConn = (HttpURLConnection) url.openConnection();

    ......

    } catch() {...}

    }

    Updated on 2013-08-19T19:35:31Z at 2013-08-19T19:35:31Z by Dae Young
  • Dae Young
    Dae Young
    430 Posts

    Re: TeamworksException unterminated string literal

    ‏2013-08-19T19:45:23Z  
    • Dae Young
    • ‏2013-08-19T19:14:00Z

    Good afternoon Andrew,

    Thanks for your reply and sharing the trouble you ran into. I will keep it in my mind in case I would run into similar situation.

    System engineers in a team I belong to found an answer for it with the help of IBM SME. Handling JSON data was correct at a service level and eval() was not the cause of the trouble rather it has to do with a certificate in the environment B, but exception handling at the integration service level was not correct b/c it could not catch it I believe if ssl related exception was thrown in the environment B. I made an appropriate change, but need some advice.

    Below code comes from a java class that is wrapped in a jar file attached to the deployed bpm application.  The "urlString" contains https protocol and points to restful web service for GET call which returns json data if everything goes ok. If the server is down I know for sure it throws IOException. What if ssl hand shake is failed. The line where it calls url.openConnection() would throw IOException?

    public String callBackEndToGetJsonData(String urlString,SomeDataType var1) throws IOException {

    try {

    url = new URL(urlString);

    urlConn = (HttpURLConnection) url.openConnection();

    ......

    } catch() {...}

    }

    My guess is yes by looking at java.io.IOException chain from Java API document.

     javax.net.ssl.SSLHandshakeException extends from IOException it looks like.