Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript
Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648158] Tue, 11 January 2011 14:22 Go to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Hi,

Following the instructions on this page I managed to start my Rhino interpreter (Running inside Tomcat 6) with a debugger listener attached.
When starting my server (Rhino context initialization also occurs on startup) I got this message:

Rhino attaching debugger
Start at time: 16:12:44 IST 11 Tuesday 2011
Listening to socket on port: 9999
Started suspended - waiting for client resume...


Then I launch the debug configuration from eclipse and the process resumes. My server loads successfully.

When I look in the debug perspective, I see 1 thread in "suspended" mode, the following scenario occurs the same way whether I resume the thread or not.

When I run a command that essentially invokes some JavaScript code that runs on the server (I have the sources in eclipse -> They are sent to the server and invoked there) an error pops up in Eclipse with the message:
'children update' has encountered a problem

An internal error occurred during: "children update"

when clicking "details" I see the text:
An internal error occurred during: "children update".
1

This is the stacktrace from the Error log:
java.lang.ArrayIndexOutOfBoundsException: 1
	at org.eclipse.debug.internal.ui.viewers.model.ChildrenUpdate.setChild(ChildrenUpdate.java:99)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider.retrieveChildren(ElementContentProvider.java:90)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider$1.run(ElementContentProvider.java:42)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


It seems like it's either a bug with eclipse or something in my configuration / architecture is not as intended.
If anyone thinks they can shed some light on the situation I would really appreciate it.

Thank You.

Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648161 is a reply to message #648158] Tue, 11 January 2011 14:27 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Sorry, the first message should say "January" instead of "Tuesday". My console printed Jibrish because of Hebrew locale.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648163 is a reply to message #648158] Tue, 11 January 2011 14:36 Go to previous messageGo to next message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
I am glad to hear you got it up and running.

The problem you describe sounds like the issue reported in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=326431 which was fixed in JSDT 1.3.

If you update the version of JSDT you are using (if it is less than 1.3) than the problem will go away. If updating does not solve the problem, than please file a new bug.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648268 is a reply to message #648163] Wed, 12 January 2011 08:20 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Where can I find this version?
The CVS repository doesn't state the version anywhere, it's sorted by dates.
Plus I wouldn't want to build it on my own, I would prefer finding a package and the latest WTP has version 1.1.2 (I don't even see 1.2, let alone 1.3...)

Thanks.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648289 is a reply to message #648268] Wed, 12 January 2011 09:51 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Ok, So I downloaded the 3.2.3 maintenance build, tried the process again and I don't get the exception.
Instead nothing happens.

I see the thread but it doesn't stop on my breakpoint, in fact it runs and nothing happens.
My gut feeling says that now it has more to do with my server's configuration, but I don't know..

I'll update as I carry on with this task for future reference.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648330 is a reply to message #648289] Wed, 12 January 2011 13:29 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Damn a very big reply I wrote got lost when I took too long to post, session died I guess.

Anyway, I found version 1.3 here: http://build.eclipse.org/webtools/committers/jsdt-R1.3.0-I/2 0101130073738/I-1.3.0-20101130073738/
The link was in http://build.eclipse.org/webtools/committers I just didn't notice.

Here are some problems I encountered. I downloaded the traditional zip and tried replacing all of the relevant packages in my Eclipse -> didn't work.
I took a fresh j2ee eclipse download and the p2 repo zip, and tried "Install New Software" -> I pointed the "archive" browse button to the zip file and it found the 2 features in the p2 repo zip. BUT when trying to proceed I got an error telling me jsdt won't be installed because it is already installed and that an update will be performed instead, Except now the "next" buttons are disabled and I can only cancel. Choosing "help -> Check for updates" quickly tells me there are no updates.
I also tried many variations of manually replacing the files in the plugins/features directory but nothing worked, I couldn't get the damn thing to update.

Next I tried downloading a fresh "Eclipse for Java Developers" copy (that doesn't have jsdt with it included). Then I went ahead and updated from the p2 repo zip without a problem. The IDE updated and I found all of the relevant features mentioned in the wiki page from above.

Now I can connect to the Rhino running on the server and it suspends on each script load.
I've got a couple of questions:

1. It can't find my sources, I've got the exact same problem the guy in this thread.

2. The reply there recommends to suspend at script load and continue from there, what I don't get is what does suspending at script load gives me? It still doesn't find my sources...

3. How can I update JSDT on a clean J2EE copy? or any eclipse that already has jsdt installed for that matter.

Thanks.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648356 is a reply to message #648158] Wed, 12 January 2011 15:08 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
I went over the transcript of the RhinoRequest / RhinoResponse the server printed and I don't see any "breakpoint" commands
( http://wiki.eclipse.org/JSDT/Debug/Rhino_Debug_Wire_Protocol #breakpoint)
I wonder why that is... How does the client supposed to send these requests? I'll go into some jsdt source code to see if I can find anything...
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648857 is a reply to message #648330] Fri, 14 January 2011 18:21 Go to previous messageGo to next message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
> 1. It can't find my sources, I've got the exact same problem
> the guy in this thread.

If the debugger is suspended at a script load, there will be no stackframe selected, so at this time, no source. If you notice in the debug when suspended at a script load the Step Into button is enabled, so you can step into the script, which will return you a stackframe and source. If this does not happen, check the log, perhaps there was a problem getting the source from your server.

> what I don't get is what does suspending at script load gives
> me? It still doesn't find my sources...

When you have it set to suspend on a script load, the debugging will pause execution as soon as Rhino has loaded the script. The script has not been run yet, Rhino is paused right before the script is about to run. At this point as mentioned above, you can step into the script to debug it right as it is being run.

if you have a stackframe selected the source should shown to you in the editor, if not you can check the 'External JavaScript Source' project that is automatically created in your workspace. The project might be hidden, so to check if it is there (in versions < 1.3) go to the view menu for the package explorer and select the Filters menu item. In the resulting dialog, uncheck the filter for 'External JavaScript Source'. In the latest versions of JSDT the project is not hidden and does a much better job of organizing source than using hashcodes.

> How can I update JSDT on a clean J2EE copy? or any
> eclipse that already has jsdt installed for that matter.

I have always found that using the update site: http://download.eclipse.org/webtools/updates works well for getting the latest official release of JSDT, to get the latest dev releases you can use the links you mentioned, or get the source and launch a target workspace, or install into your host.

I should note there is a known problem with breakpoints and relative paths from remote servers. The bug in question is https://bugs.eclipse.org/bugs/show_bug.cgi?id=328531 and I am evaluating the patch for that now.

I am going to write up some more wiki pages talking about source, breakpoints, etc, these are all excellent questions that I am sure many other people have as well.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648859 is a reply to message #648356] Fri, 14 January 2011 18:29 Go to previous messageGo to next message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
> I wonder why that is... How does the client supposed to send
> these requests? I'll go into some jsdt source code to see if I
> can find anything...

This is likely caused by https://bugs.eclipse.org/bugs/show_bug.cgi?id=328531.

When you double-click in the editor to set a breakpoint the JSDT debug model asks the VM if it has any loaded scripts that match the URI (or portion thereof), if it does a breakpoint request is sent to the VM, which in turn forwards a request to the remote debugger. If no script is found to have been loaded the model creates a script load request, so once the script you tried to set the breakpoint in is loaded by the remote debugger the model will then create the breakpoint, sending the breakpoint request.

In the bug mentioned there is a problem with the current code that fails to correctly map scripts from the server to the ones in the workspace, so breakpoints and other script URI sensitive operations do not work 100%

Another useful option is to view all loaded scripts. To do this, go to the Debug view menu > JavaScript > Show ALl Scripts. Enabling this option will show a 'Script' node in the debug for each debug target. If you expand the 'Scripts' node you can see all of the scripts that are currently loaded in the remote debugger.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648956 is a reply to message #648158] Sun, 16 January 2011 15:35 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Hey Michael, thanks for the responses!

I am definitely experiencing the effects of bug 328531.

Here are a few issues I'm facing now.

(**1**) Is there anything I can do on the server's side where the rhino interpreter is running to overcome the bug? I can't match any source my server runs to something local in the eclipse.

I decided to first try running the remote debugging process against a simple java program that only runs the interpreter with a debugger attached before trying to run against my server.
Here's my Interpreter code:
import java.io.FileReader;
import org.eclipse.wst.jsdt.debug.rhino.debugger.RhinoDebugger;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;

public class RhinoInterpreter {
	private static final String FILENAME = "C:/dev/HeliosClean/workspace/Rhino/src/com/worklight/temp/rhino/testing.js";

	public static void main(String[] args) throws Exception {
		ContextFactory contextFactory = ContextFactory.getGlobal();
		
		// Attach debugger
		RhinoDebugger debugger = new RhinoDebugger("transport=socket,suspend=y,address=9999,trace=y");
		debugger.start();
		contextFactory.addListener(debugger);
		
		// Create context and run.
		Context context = contextFactory.enterContext();
		Scriptable scope = context.initStandardObjects();
		FileReader fileReader = new FileReader(FILENAME);

		Object exec = context.evaluateReader(scope, fileReader, FILENAME, 0, null);     // Attempt 1
		
//		Script script = context.compileReader(fileReader, FILENAME, 0, null); // Attempt 2
//		Object exec = script.exec(context, scope);
		
		System.out.println(exec);
		
	}
}
This is testing.js:
function foo(str) {
	return "result is " + str;
}

function goo(i,j) {
	return i+j;
}

var a = 5;
var b = 6;
var c = goo(a,b) + goo(goo(a,a),b);
foo(c);


I run the interpreter as a simple Java application, then I attach the eclipse JSDT rhino debugger to port 9999.
I can see in my stdout the entire communication between the debug process and the client.
Using this scenario (Attempt 1 and when the access to the file is with an absolute path) eclipse manages to match the source in the stack to the original source.

(**2**) If I put in "testing.js" instead of FILENAME in the evaluateReader parameters, eclipse fails to match the source to the stack file.

(**3**) Another problem I have with this scenario is that if I put a breakpoint where you see
var a=5;
I immediately see a "setbreakpoint" request sent to the server, and when running the script I stop there. So far so good, BUT if I try to place a breakpoint inside on of the functions (like where you see
return "result is" + str; 
the "setbreakpoint" is never sent and the script doesn't stop there.

(**4**) If I try debugging with "attempt 2" -> compiling instead of evaluating, I've seen mostly the same behavior.

(**5**) In both scenarios, stepping into a function doesn't really work, it doesn't jump to the correct line, local stack variables aren't shown in the variables view and stepping over again is like step-returning. Multiple calls to functions in the same line only allows stepping into once.

So in conclusion I think every issue I have now marked with (**#**) is something I'm trying to figure out. Are these problems something that can be resolved? Any answer to any of these will be appreciated
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #648999 is a reply to message #648158] Mon, 17 January 2011 07:33 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Correction, I can't set a breakpoint on a line with a "return".
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #649003 is a reply to message #648158] Mon, 17 January 2011 08:31 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
Update:

In my server, I changed the scriptName parameter (of the compile method) hard-codedly to be the full path of my js file. (file:/c:/dev/.../something.js).
In addition I made sure the debug configuration had a project that contains this file in the source lookup path. Finally Eclipse managed to figure out the script from the server matches to the one in the project. Breakpoints are sent to the server and when invoking the script, it actually suspended but... NullPointerException from within eclipse.
java.lang.NullPointerException
at org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptVariable.getValue(JavaScriptVariable.java:68)
at org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptVariable.getReferenceTypeName(JavaScriptVariable.java:58)
at org.eclipse.wst.jsdt.debug.internal.ui.actions.FunctionFilterAction.select(FunctionFilterAction.java:42)
at org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider.shouldFilter(ModelContentProvider.java:1582)
at org.eclipse.debug.internal.ui.viewers.model.ChildrenUpdate.performUpdate(ChildrenUpdate.java:58)
at org.eclipse.debug.internal.ui.viewers.model.ViewerUpdateMonitor$1.runInUIThread(ViewerUpdateMonitor.java:99)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)


Using JSDT version 1.3 from the link I supplied above.

Sad
so close...
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #649005 is a reply to message #649003] Mon, 17 January 2011 08:39 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
This NPE may result from a problem at the server's side, because it only happens when eclipse tries to initialize the Variables view and I get an Exception in my server, I think the Variables view tries to access some restricted value.
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #649036 is a reply to message #648158] Mon, 17 January 2011 11:22 Go to previous messageGo to next message
Enrico Magen is currently offline Enrico MagenFriend
Messages: 15
Registered: September 2010
Junior Member
YEEEHHAAA!! Smile

Success! Code running on my server debugged with the JSDT RhinoDebugger! Smile

That NPE was indeed a problem on our server's side.
So I got this working and it looks GREAT!
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #649098 is a reply to message #648956] Mon, 17 January 2011 16:36 Go to previous messageGo to next message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
Sadly there is no real workaround for the source problem, other than supplying the full paths (as you already found).

As for not being able to set breakpoints, do you see a message in the status bar of Eclipse saying something like 'failed to create line breakpoint'? We did have a problem with setting breakpoints in closures, which is here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=313013

> So I got this working and it looks GREAT!

I am glad to hear you finally got it working.

I started to further update the wiki with some of the issues you discovered Enrico, thanks for all of your effort!

wiki updates:
http://wiki.eclipse.org/JSDT/Debug/FAQ
http://wiki.eclipse.org/JSDT/Debug/Rhino
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #764993 is a reply to message #649098] Tue, 13 December 2011 08:37 Go to previous messageGo to next message
Barent Brouwers is currently offline Barent BrouwersFriend
Messages: 2
Registered: December 2011
Junior Member
Hello all,

I am trying to do JSDT/Debug/Rhino/Embedding Rhino Debugger and then Testing Remote Rhino Locally.

Starting Rhino debugger locally using the class org.eclipse.wst.jsdt.debug.rhino.debugger.shell.DebugShell is no problem.

Connecting to the debugger from Eclipse with the Mozilla Rhino Attaching Connector isn't working unfortunately. I am getting this error : does anyone have a clue ? greetings......

!ENTRY org.eclipse.wst.jsdt.debug.core 4 0 2011-12-12 11:49:56.546
!MESSAGE Error occured while launching
!STACK 0
java.io.IOException: Invalid content length: HTTP/1.1 40
at org.eclipse.wst.jsdt.debug.internal.rhino.transport.RhinoSocketConnection.readPacket(RhinoSocketConnection.java:69)
at org.eclipse.wst.jsdt.debug.internal.rhino.transport.RhinoTransportService.handleAttach(RhinoTransportService.java:56)
at org.eclipse.wst.jsdt.debug.transport.socket.SocketTransportService.attach(SocketTransportService.java:142)
at org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.connect.RhinoAttachingConnector.attach(RhinoAttachingConnector.java:47)
at org.eclipse.wst.jsdt.debug.internal.core.launching.RemoteJavaScriptLaunchDelegate$ConnectRunnable.run(RemoteJavaScriptLaunchDelegate.java:65)
at java.lang.Thread.run(Unknown Source)
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #765173 is a reply to message #764993] Tue, 13 December 2011 14:59 Go to previous messageGo to next message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
That error would indicate that one of the packets read from the shell has a bad section in it.

What version of JSDT debug are you using?
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #765181 is a reply to message #765173] Tue, 13 December 2011 15:13 Go to previous messageGo to next message
Barent Brouwers is currently offline Barent BrouwersFriend
Messages: 2
Registered: December 2011
Junior Member
org.eclipse.wst.jsdt.debug.rhino.debugger_1.0.200.v201103080228.jar

js-14.jar

and

Eclipse IDE for JavaScript Web Developers.

Version: Indigo Service Release 1
Build id: 20110916-0149
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #1445038 is a reply to message #648158] Tue, 14 October 2014 23:31 Go to previous messageGo to next message
Sticky Bandit is currently offline Sticky BanditFriend
Messages: 2
Registered: October 2014
Junior Member
I am getting the same error trying to run a Rhino debugger.

Error:
Error occured while launching
Failed to parse content length:


Any idea how to resolve this?
Re: Remote Rhino debugging - Exception inside eclipse when evaluating JavaScript [message #1449105 is a reply to message #1445038] Mon, 20 October 2014 23:17 Go to previous message
Sticky Bandit is currently offline Sticky BanditFriend
Messages: 2
Registered: October 2014
Junior Member
I had to match the port 9009 in the debug config that was in the code. Then it worked.
Previous Topic:How to deploy persistence.xml in a web project?
Next Topic:Why is HttpServlet needed on the Java Build Path?
Goto Forum:
  


Current Time: Wed Apr 24 23:53:18 GMT 2024

Powered by FUDForum. Page generated in 0.04386 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top