title: Implementing Java interface from JavaScript fails with a TypeError
body: <p>I have an interface <code>ru.focusmedia.odp.server.scripts.api.Script</code> and tried to implement it according to the example in <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html</a>:</p>
  
  <pre><code>new Packages.ru.focusmedia.odp.server.scripts.api.Script() {
      ...
  };
  </code></pre>
  
  <p>However, this gives the following exception:</p>
  
  <blockquote>
    <p>javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: [JavaPackage ru.focusmedia.odp.server.scripts.api.Script] is not a function, it is sun.org.mozilla.javascript.internal.NativeJavaPackage. (#1) in  at line number 1</p>
  </blockquote>
  
  <p><code>new Packages.java.lang.Runnable()</code> works. What is the problem?</p>
  
  <p>UPDATE: I initially thought <a href="https://groups.google.com/forum/?fromgroups#!topic/mozilla-rhino/_i-36l_yyZ0" rel="nofollow">setting thread context class loader</a> fixed this problem, but it reoccurred after minor changes in the script.</p>