title: Rhino debugger - can't hit a breakpoint?
body: <p>I have this legacy web application on inspection, that utilizes Rhino to script some database import tasks. Scripted task is executed properly.  </p>
  
  <p>However, I can't seem to hit a breakpoint in the JS script file. I'm not even sure if it's possible to debug JS script this way, so if anyone can give some more insight or advice... The core setup is as follows:  </p>
  
  <p><strong>Debugger (listener):</strong>  </p>
  
  <pre><code>// executes when the app is launched...  
  if (!ContextFactory.hasExplicitGlobal()) {
  
      ContextFactory cxf = new ContextFactory();
      ContextFactory.initGlobal(cxf);
      String rhino = "transport=socket,suspend=y,address=9999";
      System.out.println("&gt;&gt;&gt;&gt;&gt;&gt; RHINO &lt;&lt;&lt;&lt;&lt;&lt;");
      RhinoDebugger debugger = new RhinoDebugger(rhino);
      debugger.start();
      cxf.addListener(debugger);
  }
  ...
  </code></pre>
  
  <p><strong>Scripting context:</strong>  </p>
  
  <pre><code>@Component("importDebugMockup")
  public class ImportDebugMockup extends Import {
  
      @Autowired private SomeDAO someDAO;
      @Autowired private SomeOtherDAO someOtherDAO;
      ...
      private ContextFactory cxf;
      private Document doc;
  
      public ImportDebugMockup() {
          this.cxf = ContextFactory.getGlobal();
      }
      ...
      @Transactional
      public Map&lt;String, Object&gt; doImport(final String scriptName, final String filePath) 
      throws ScriptException, IOException {
  
          final Map&lt;String, Object&gt; results = new HashMap&lt;&gt;();
          final String scriptSource = this.readJSFileToString(filePath, Charset.forName("UTF-8"));
          Context context = this.cxf.enterContext();
          try {
              Scriptable scope = new ImporterTopLevel(context);
              ScriptableObject.putProperty(scope, "doc", doc);
              ScriptableObject.putProperty(scope, "someDAO", this.someDAO);
              ScriptableObject.putProperty(scope, "someOtherDAO", this.someOtherDAO);
              ...
              ScriptableObject.putProperty(scope, "results", results);
  
              Object functionArgs[] = { "null" };
              String scriptExecName = "script" + scriptName + ".js";
              context.evaluateString(scope, scriptSource, scriptExecName, 1, null);
              Function fct = (Function) scope.get("doImport", scope); // call doImport()
              Object result = fct.call(context, scope, scope, functionArgs);
  
          } finally {
              Context.exit();
          }
          return results;
      } 
  }
  </code></pre>
  
  <p><strong>The script:</strong>  </p>
  
  <pre><code>importPackage(java.io);
  importPackage(some.package);
  // ...
  // some utility functions here
  // ...
  function doImport() {
      ...
      var i = 0;    // set breakpoint here - can't hit it
      someDAO.doSomething(...);  // using propagated java object
      ...
      someOtherDAO.doSomethingElse();
      ...
  }
  </code></pre>
  
  <p><strong>EDIT</strong>  </p>
  
  <p>Remote JS Debug configuration (with Mozilla Rhino - Attaching Connector at port 9999) is set up, like in <a href="http://illegalargumentexception.blogspot.com/2013/02/javascript-debugging-with-embedded.html" rel="nofollow">this article</a>, for example. Source is configured to point to directory where the JS script is located, however it does not suspend on breakpoint...</p>