- This topic has 8 replies, 4 voices, and was last updated 18 years, 9 months ago by bcichowlas.
-
AuthorPosts
-
bcichowlasParticipantHi!
I don’t know if I have unreasonable expectations for the Javascript debugger or whether I am setting things up wrong. I’ve tried several variations using different Ajax technologies, but it seems to come down to the same result. I’ll show it here using Dojo.
1) I create a servlet using the default servlet creation without modifying the result, i.e. I use New…Servlet…. (The default servlet just produces a short HTML page.)
2) I add an appropriate entry to web.xml:
<servlet>
<description>XYZ Test Servlet</description>
<display-name>XYZ Test Servlet</display-name>
<servlet-name>XYZServlet</servlet-name>
<servlet-class>com.affirmtech.test.xyz.XYZServlet</servlet-class>
</servlet><servlet-mapping>
<servlet-name>XYZServlet</servlet-name>
<url-pattern>*.xyz</url-pattern>
</servlet-mapping>3) I make a .html page that calls Javascript code like this:
function process(type, data, evt){
alert(“process: ” + data);
}function tryDojo4(){
dojo.io.bind({
url: “abc.xyz”,
load: process
});
}Of course, there is no real abc.xyz file. It’s supposed to be handled by the servlet.
If I run this starting a Tomcat 5 server and invoking an appropriate URL using the browser icon next to the application server icons, it works correctly. The ouput is “process: ” followed by the generated web page.
However, if I start it by right clicking the html file and selecting Javascript debugger, it hangs whether or not the Tomcat 5 server is running.
I tried putting in a full URL in the Dojo bind statement:
http://localhost:5050/DojoLand/abc.xyz
instead of
abc.xyz
However, this didn’t help.
Similarly, if I have a JSP page in my WebRoot, it is interpreted if I go through the Tomcat 5 server but it is uninterpreted if I just go through the Javascript debugger.
It doesn’t have anything to do with Dojo. I first discovered the symptoms using DWR.
Maybe this is working as intended. In that case, how can I debug an Ajax program that makes web calls? Do I set up the web-service portion as a separate project? Should I be using something other than DWR or Dojo? What is the best way to set up a project that involves an Ajax application making calls to web services or the like? I didn’t see an example like that on your site. Possibly a call to a local URL could be added to the Mario example.
Thanks,
Bruce
Riyad KallaMemberBruce,
The execution of the debugger can be a bit misleading and we are working on that. What you want to do is deploy your app to Tomcat 5, then run Tomcat 5. Then you want to go into your HTML or JSP page and set a breakpoint in your JavaScript, say the tryDojo4 function. Then you want to right click and Debug > Javascript, then when the location box pops up with a path to the file, change it instead to the URL, say: http://localhost:5050/DojoLand/abc.html, you basically want to cause execution to enter your HTML/JSP page. From there you can step/pause/continue/etc. like normal.
bcichowlasParticipantThanks much. It had not been clear to me that I needed to run both the external Tomcat app server and the special Web Browser 2.0 Javascript debugger together. I think I had been hesitant to do it like this because the JS_Mario examples has all run successfully without starting an app server. I figured that you clever people had built some kind of special-purpose app server within the Javascript debugger!
Now I see better how they interrelate. I also have a better model of where the Javascript debugger starts and where it leaves off. I’m successfully getting JSP pages expanded when loaded from the Ajax page. Probably the servlets will work fine now as well. I’m wondering whether this will make the DRW work as well. (I’m thinking it might not because it seems to resolve Javascript references on the fly, intercepting references to Javascript files in a “drw” virtual directory…or at least that’s the way I think it works. I don’t know whether you debugging system would be up to that.)
I think that it would be useful to extend the JS_Mario example to call upon a JSP page or a servlet, perhaps to retrieve some trivial piece of information that is kept on the server. This could just be appended as a few additional steps at the end.
Thanks again,
Bruce
GregMemberWe do have a DWR example application that we have been playing with that demostrates how we can debug on client side and then debug on server side. And then again on client side when DWR call returns. DWR is tricky those since they dynamically serve the .js files that are needed. We are planning on enhancing the JavaScript debugger to be able to debug javascript code even when you don’t have the source in a local file. Once we support this, it will be much easier to support JSP/Servlet environments.
bcichowlasParticipantSome of this may be my own clumsiness, but I was not able to get DWR working properly with the debugger. I think the problem was that I was trying to step through JavaScript that made DWR calls. If you think this should work, I will try it again.
I have been successful at calling servlets through Dojo, so right now I am converting my DWR methodology to using Dojo with JSON strings of what would have been the DWR parameters.
My background is in using your product for Java, not Javascript. Some of the things that drive me a bit batty are the way the program seems to hang (with or without the debugger) when a reference can’t be resolved. When I get stuck with this sort of behavior I usually resort to using Firefox and the Venkman debugger. Sometimes even the Javascript console messages in Firefox or Netscape are enough for me to see the problem.
Another problem which I’ve had perhaps half a dozen times but do not yet understand enough to reproduce is having MyEclipse/eclipse disappear giving a JVM error when certain debugging situations go astray. There are many lines of information in the JVM error dialog produced. Perhaps I should copy them down. Nothing seems to point me to a particular error in my debugging procedure or in my coding.
Thanks for your attention,
Bruce
bcichowlasParticipantI just caught one of those unexpected crashes. I had just redeployed the program and am trying to get a dojo.io.bind call to call a servlet.
I don’t know how to copy and paste from these dialog boxes since I don’t seem to be able to select the text. I’d send a screen shot, but I can’t post it to the forum, so here goes the manual transcription:
JVM terminated. Exit code=1
C:\WINDOWS\system32\javaw.exe
-Duser.language=en
-Xms128M
-Xmx512X
-XX:PermSize=64M
-xx:MaxPermSize=128M
-Dosgi.splashLocation=C:\a3\MyEclipse\eclipse\MyEclipseSplash.bmp
-jar C:\a3\eclipse\startup.jar
-os win32
-ws win32
-arch x86
-launcher C:\a3\eclipse\eclipse.exe
-name Eclipse
-showsplash 600
-exitdata 1084_4c
-vm C:\WINDOWSD\system32\javaw.exe
-vmargs
-Duser.language=en
-Xms128M
-Xmx512M
-XX:PermSize=64M
-XX:MaxPermSize=128M
-Dosgi.splashLocation=C:\a3\MyEclipse\MyEclipseSplash.bmp
-jar C:\a3\eclipse\startup.jarI just noticed how some of it is repeated.
Here’s what I was doing. I had just finished setting up a servlet, updating the web.xml, updating my Javascript call to call it and restarting Tomcat 5. When I tried to start the Web Browser, using the Globe icon near the server dropdown, the Eclipse window disappeared, leaving the dialog box information above.
The Dojo call looked like this:
function passwordCheck(nodeu, nodep){
var u = nodeu.value;
var p = nodep.value;myLogin = new Object();
myLogin.method = “checkLogin”;
myLogin.username = u;
myLogin.password = p;
var s = JSON.stringify(myLogin);
dojo.io.bind({
url: “weservlet/checkLogin”,
load: loadCheckLogin,
content: myLogin,
mimetype: “text/plain”
});alert(‘url request sent’);
}
and loadCheckLogin simply looks like this:function loadCheckLogin(type, data, evt){
alert(‘loadCheckLogin’);
}I had placed a breakpoint in my servlet so that I could see whether it actually got called. Hopefully, I didn’t lose much whrn it crashed.
Maybe I need to pass the “stringified” value s rather than the object itself, though I thought Javascript would do the conversion for me.
Bruce
bcichowlasParticipantIt now appears that the above crash happened when it hit a breakpoint within my servlet code.
This is why I think that is the case: I started up Eclipse and started Tomcat 5 from within MyEclipse as before. But this time I used Firefox instead of the MyEclipse browser (as started by the globe icon). This time MyEclipse stopped properly when the breakpoint was reached and did not crash. I am using a Dojo net.io.bind call, but I am inclined to think that had nothing to do with it. What do you think?
Bruce
support-jedKeymasterHey Bruce,
Can you check on two files and send them to us?
First, in your workspace directory there should be a file .metadata/.log.
Second, in your Eclipse directory there may be a Java crash log. It should be named hs_err_pid????.log, where ???? is a 4 digit number.
Thanks!
bcichowlasParticipantYeah, I’ll do that in a few minutes and put your name in the message and a link to the message thread in the message itself.
I did a few more tests and the general pattern seems to be this:
1) If I put a breakpoint in the servlet code and then start the server from Firefox, the breakpoint will act properly, i.e. the application will be paused and I will see a message from MyEclipse asking if it should change to the debug perspective. From there I can look at things and resume the program.
2) If I put a breakpoint in the servlet code and then use Web Browser 2.0 by clicking on the globe icon on the toolbar, either I will get a fatal crash or else the application will proceed, but the breakpoints will be ignored.
Bruce
-
AuthorPosts