package names and EcmaError: TypeError: Cannot call property JavaScriptDemo in object

641 views
Skip to first unread message

David Walend

unread,
Oct 14, 2014, 11:16:08 PM10/14/14
to scal...@googlegroups.com
My first evening with scala-js, and I've got a strange problem to unwind.

The code from the tutorial at http://www.scala-js.org/doc/tutorial.html works fine, as written, in package tutorial.webapp. 

I change the package to one.two.three, and it works fine.

I change the package to net.walend.graph and I get 

[info] Running net.walend.graph.JavaScriptDemo

org.mozilla.javascript.EcmaError: TypeError: Cannot call property JavaScriptDemo in object [JavaPackage net.walend.graph]. It is not a function, it is "object". (Generated launcher file#1)

at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)

at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)

at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3693)

at org.mozilla.javascript.ScriptRuntime.typeError3(ScriptRuntime.java:3719)

at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3786)

at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2269)

at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2236)

at org.mozilla.javascript.ScriptRuntime.getElemFunctionAndThis(ScriptRuntime.java:2204)

at org.mozilla.javascript.gen.Generated_launcher_file_3112._c_script_0(Generated launcher file:1)

at org.mozilla.javascript.gen.Generated_launcher_file_3112.call(Generated launcher file)

at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)

at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)

at org.mozilla.javascript.gen.Generated_launcher_file_3112.call(Generated launcher file)

at org.mozilla.javascript.gen.Generated_launcher_file_3112.exec(Generated launcher file)

at org.mozilla.javascript.Context.evaluateString(Context.java:1079)

at scala.scalajs.sbtplugin.env.rhino.package$ContextOps$.evaluateFile$extension(package.scala:21)

at scala.scalajs.sbtplugin.env.rhino.RhinoJSEnv.runJS(RhinoJSEnv.scala:98)

at scala.scalajs.sbtplugin.ScalaJSPluginInternal$.scala$scalajs$sbtplugin$ScalaJSPluginInternal$$jsRun(ScalaJSPluginInternal.scala:396)

at scala.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$46$$anonfun$apply$26$$anonfun$apply$27.apply(ScalaJSPluginInternal.scala:460)

at scala.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$46$$anonfun$apply$26$$anonfun$apply$27.apply(ScalaJSPluginInternal.scala:454)

at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

[trace] Stack trace suppressed: run last compile:run for the full output.

java.lang.RuntimeException: Exception while running JS code: TypeError: Cannot call property JavaScriptDemo in object [JavaPackage net.walend.graph]. It is not a function, it is "object". (Generated launcher file#1)

at scala.sys.package$.error(package.scala:27)

at scala.scalajs.sbtplugin.env.rhino.RhinoJSEnv.runJS(RhinoJSEnv.scala:103)

at scala.scalajs.sbtplugin.ScalaJSPluginInternal$.scala$scalajs$sbtplugin$ScalaJSPluginInternal$$jsRun(ScalaJSPluginInternal.scala:396)

at scala.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$46$$anonfun$apply$26$$anonfun$apply$27.apply(ScalaJSPluginInternal.scala:460)

at scala.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$46$$anonfun$apply$26$$anonfun$apply$27.apply(ScalaJSPluginInternal.scala:454)

at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

[trace] Stack trace suppressed: run last compile:run for the full output.

[error] (compile:run) Exception while running JS code: TypeError: Cannot call property JavaScriptDemo in object [JavaPackage net.walend.graph]. It is not a function, it is "object". (Generated launcher file#1)

[error] Total time: 10 s, completed Oct 14, 2014 11:00:36 PM

which I don't feel I deserve.

What do I need to read to understand what's going on?

Thanks,

Dave

Sébastien Doeraene

unread,
Oct 15, 2014, 2:21:12 AM10/15/14
to David Walend, scal...@googlegroups.com

Hi,

Waw, that might be a new occurrence of a very old bug:
https://github.com/scala-js/scala-js/issues/364
But with the package `net` this time.

You should be able to either apply the same workaround, or use Node or PhantomJS.

Cheers,
Sébastien

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/592d43b6-f5ff-425c-a5bb-d3c54c6981e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Walend

unread,
Oct 15, 2014, 9:24:01 AM10/15/14
to scal...@googlegroups.com, da...@walend.net
Thanks! I thought I'd lost my cut-paste skills. I'll update the bug report with a pointer back to here.
Reply all
Reply to author
Forward
0 new messages