Subj : Still can't get Rhino debugger to work under servlet To : netscape.public.mozilla.jseng From : Jon Brisbin Date : Thu Sep 01 2005 11:29 am Thanks for the advice below, Igor. I tried it and was still unable to get the debugger to either block execution, or attach to the right context. Here's basically what I changed: 1) I had to take *everything* out of the method I had it in originally and left just: debug = Boolean.parseBoolean( script.attributeValue( "debug", "false" ) ); ContextFactory ctxFac = new ContextFactory(); ctxFac.call( new DoEval() ); 2) I put everything into an inner class: class DoEval implements ContextAction { /* (non-Javadoc) * @see org.mozilla.javascript.ContextAction#run(org.mozilla.javascript.Context) */ public Object run( Context cx ) { final String scriptStr; final Scriptable scope = new ImporterTopLevel( cx ); ..... File _debugTmpFile = null; try { if ( debug ) { _debugTmpFile = writeTmpFile( scriptStr ); if ( log.isInfoEnabled() ) { log.info( "Debugging with the following objects in context:" ); Object[] ids = scope.getIds(); for ( Object o : ids ) { log.info( "ID: " + o.toString() ); } } Main.mainEmbedded( cx.getFactory(), new ScopeProvider() { public Scriptable getScope() { return scope; } }, _args.get( Globals.Keys.XML_DEFINITION_URI ).toString() ); org.mozilla.javascript.tools.shell.Main.exec( new String[] { "-e", scriptStr } ); if ( ( _debugTmpFile != null ) && _debugTmpFile.exists() ) _debugTmpFile.delete(); } else { bsfEngine.eval( "", 0, 0, scriptStr ); } } catch ( Throwable t ) { error = generateException( t ); If you have any more ideas, I'd be happy to try them. I'm contemplating just writing my own debugger, since this has been so much trouble. It would probably take me just as long to understand how to make this work as it will to just write my own :-/ Jon Brisbin NPC International, Inc. igor.bukanov@gmail.com wrote: >1. Use mainEmbedded form from >http://lxr.mozilla.org/mozilla/source/js/rhino/toolsrc/org/mozilla/javascript/tools/debugger/Main.java#284 > >with properly initialized ContextFactory and ScopeProvider. > >2. In your servlet code do NOT use > >Context cx = Context.enter(); >try { > codeThatUseContextInstance >} finally { > Context.exit(); >} > >Instead use >instanceOfContextFactoryToPassToDebugger.call(new ContextAction() { > public Object run(Context cx) { > codeThatUseContextInstance > } > >}); > >Regards, Igor > >_______________________________________________ >mozilla-jseng mailing list >mozilla-jseng@mozilla.org >http://mail.mozilla.org/listinfo/mozilla-jseng > > > .