access to Rhino debugging from embedded rhino

233 views
Skip to first unread message

Mitch Trachtenberg

unread,
Jan 8, 2018, 3:09:05 PM1/8/18
to mozilla-rhino
Hi,

I'm using eclipse and the Java program Mirth Connect, which uses an embedded rhino debugger.  A few years back, there were tantalizing posts about being able to get to the Rhino debugger to debug javascripts interpreted from within Mirth Connect, but it appears that a redesign has rendered those posts no longer workable.

Within Mirth's, JavaScriptTask.java is a line "compiledScript.exec(context, scope);" which, I'm fairly certain, is where Mirth's embedded Rhino is called upon to run the script. 

I've tried adding this:
             org.mozilla.javascript.tools.debugger.Main rhinoDebugger = org.mozilla.javascript.tools.debugger.Main.mainEmbedded(contextFactory, scope, "test"); and get a java.awt.Headless exception, even though eclipse connects to my display just fine.

Reading the docs, it sounds as if embedded Rhino can communicate to a "remote" rhino debugger, and I am able to run the Rhino 1.7 release 4 2014 05 02 debugger on my Ubuntu system in parallel with Eclipse and Mirth.  But I cannot figure out how to instruct rhino to talk to that instance as a remote debugger.  Can anyone help, either on the headless exception or on setting up the embedded Rhino to talk with an external Rhino debugger? 

Thanks in advance,
Mitch T

Mitch Trachtenberg

unread,
Jan 8, 2018, 5:36:44 PM1/8/18
to mozilla-rhino
Adding a bit of information from not-knowing-what-I-am-doing-experimentation...

I've set up an alternate Xnest X server on my Ubuntu platform and have run Mirth Connect on Eclipse invoked on that platform, setting everything up to display on that X server rather than the standard one with Ubuntu.  I am now able to create debugger instances, which display their GUI.  I've added code like this:

        if(rhinoDebugger==null)
            rhinoDebugger = org.mozilla.javascript.tools.debugger.Main.mainEmbedded(contextFactory, scope, "MirthDebug");
        rhinoDebugger.attachTo(contextFactory);
        rhinoDebugger.setBreakOnEnter(true);
        System.out.println("Rhino debugger: " + rhinoDebugger);
        context.setOptimizationLevel(-1);
        Object v = compiledScript.exec(context, scope); <-- this is the Javascript from Mirth
        System.out.println("Returned from rhino debugger session?");
        Debugger x = context.getDebugger();
        System.out.println("Result of getDebugger" + x);
        System.out.println("Context: " + context);

Here's what happens.  The first time, I get the debugger popping up.  The second time, I get a new copy of the debugger and the OLD copy gets access to the script's variables... I can see them in the watch window.  However, instead of the script getting displayed, the Rhino debugger somehow pulls in an HTML welcome page from Tomcat, which is running on my system.  It jumps from line to line, appearing to follow the line numbers from my script, but not displaying it.

I'm attaching a screen shot.

There is another weirdness as well -- although my Eclipse and Mirth windows appear on the Xnest display, the debugger initiated from inside Mirth shows on my regular display (:0).

Anyone with any theories?  Thanks in advance.
Screenshot from 2018-01-08 14-32-39.png
Reply all
Reply to author
Forward
0 new messages