Error:Expected letter.. while running play multi project - scala

I was trying to run a play sbt multi-project using command 'sbt "project subproject" ~run'
But received following error:
`Expected letter
[error] Expected symbol
[error] Expected '!'
[error] Expected '+'
[error] Expected '++'
[error] Expected 'debug'
[error] Expected 'info'
[error] Expected 'warn'
[error] Expected 'error'
[error] Expected ';'
[error] Expected end of input.
[error] Expected '--'
[error] Expected 'show'
[error] Expected 'all'
[error] Expected '*'
[error] Expected '{'
[error] Expected project ID
[error] Expected configuration
[error] Expected key
[error] Expected '-'
[error] “
[error] ^
`

I think what you want is sbt "~subproject/run"

I had this same problem and, it was because I was running sbt . (with a trailing period).
Just using sbt or sbt [command] solved the problem for me

Related

How to add parameters to run SBT in Ammonite?

I want to run this SBT command in Ammonite:
sbt -mem 3000 clean compile docker:publishLocal
I tried a few things like:
%.sbt("-mem 3000", 'clean, 'test)(pwd)
Which gives this exception:
[error] Expected symbol
[error] Not a valid command: -
[error] Expected end of input.
[error] Expected '--'
[error] Expected 'debug'
[error] Expected 'info'
[error] Expected 'warn'
[error] Expected 'error'
[error] Expected 'addPluginSbtFile'
[error] -mem 3000
[error] ^
How is this done?
I recently had to the same thing, and i can tell you that is not fun when those "random" errors happen.
// I had to put the full path where sbt is, like this
val SBT = "C:\\Program Files (x86)\\sbt\\bin\\sbt.bat"
%(SBT, "-mem", "3000", "clean", "compile", "docker:publishLocal")(pwd)
with this the solution is:
%.sbt("-mem", "3000", 'clean, 'test)(pwd)

What is the maximum number of case class fields in scala?

It used to be 22, I heard someone say it's now 512? Is that correct? Can someone provide a source.
In Scala 2.11 there is an implicit limit, it seems if you create a case class with about more than 100 fields you get a stack overflow (see bottom of answer).
A workaround to get the number of fields higher (up to 254) is
export SBT_OPTS="-XX:MaxPermSize=2G -Xmx2G -Xms2G -Xss8M"
If you try any higher than 254 you get
[error] /Users/sams/src/.../src/main/scala/com/MegaClass.scala:6:12: Platform restriction: a parameter list's length cannot exceed 254.
[error] case class MegaClass(
Stack overflow error:
[error] null
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transformSelect$1(SuperAccessors.scala:253)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:335)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:359)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:71)
...
[error] scala.reflect.internal.Trees$class.itransform(Trees.scala:1345)
[error] scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:16)
[error] scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:16)
[error] scala.reflect.api.Trees$Transformer.transform(Trees.scala:2555)
[error] scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:44)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.mayNeedProtectedAccessor$1(SuperAccessors.scala:186)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transformSelect$1(SuperAccessors.scala:332)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:335)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:359)
[error] scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:71)
[error] scala.reflect.internal.Trees$class.itransform(Trees.scala:1345)
[error]
[error] java.lang.StackOverflowError
[error] at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:178)
[error] at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:359)
[error] at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:71)
[error] at scala.reflect.internal.Trees$class.itransform(Trees.scala:1345)
[error] at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:16)
[error] at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:16)
[error] at scala.reflect.api.Trees$Transformer.transform(Trees.scala:2555)
It's 22 if you want json (de)serialisation. At least in pre Scala 3. It might have changed in Scala 3.

How to debug scalajs linker error: non-existent method java.lang.Class.getDeclaredFields

After adding the following method to map case classes to Map or js.Dictionary - and I've tried now five or six variants of the following - my code compiles fine and without warnings, but then hits errors at the fastOptJS sjs linking stage.
The method
def ccToMap(cc: AnyRef) =
(Map[String, Any]() /: cc.getClass.getDeclaredFields) {
(a, f) =>
f.setAccessible(true)
a + (f.getName -> f.get(cc))
}
Note that all the variants I have tried do the same thing in a slightly different manner.
The error
[info] Fast optimizing /Users/justin/Desktop/arete/jt/client/target/scala-2.11/client-fastopt.js
[error] Referring to non-existent class java.lang.reflect.Field
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.ccToMap(java.lang.Object)scala.collection.immutable.Map
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.<init>()
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(japgolly.scalajs.react.extra.router.RouterCtl)japgolly.scalajs.react.ReactElement
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(java.lang.Object)java.lang.Object
[error] called from scala.collection.LinearSeqOptimized$class.foreach(scala.collection.LinearSeqOptimized,scala.Function1)scala.Unit
[error] called from scala.collection.mutable.MutableList.foreach(scala.Function1)scala.Unit
[error] called from scala.collection.TraversableLike$WithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from scala.collection.immutable.Stream$StreamWithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from org.scalajs.testinterface.internal.Slave.org$scalajs$testinterface$internal$Slave$$execute(scala.scalajs.js.Dynamic)scala.Unit
[error] called from org.scalajs.testinterface.internal.Slave.handleMsgImpl(java.lang.String,scala.Function0)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.handleMsg(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$anonfun$1(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.init()scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$js$exported$meth$init()java.lang.Object
[error] called from org.scalajs.testinterface.internal.BridgeBase.init
[error] exported to JavaScript with #JSExport
[error] involving instantiated classes:
[error] com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$
[error] com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2
[error] scala.collection.mutable.Queue
[error] scala.collection.mutable.MutableList
[error] scala.collection.TraversableLike$WithFilter
[error] scala.collection.immutable.Stream$StreamWithFilter
[error] org.scalajs.testinterface.internal.Slave
[error] org.scalajs.testinterface.internal.Master
[error] Referring to non-existent method java.lang.Class.getDeclaredFields() [java.lang.reflect.Field
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.ccToMap(java.lang.Object)scala.collection.immutable.Map
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.<init>()
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(japgolly.scalajs.react.extra.router.RouterCtl)japgolly.scalajs.react.ReactElement
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(java.lang.Object)java.lang.Object
[error] called from scala.collection.LinearSeqOptimized$class.foreach(scala.collection.LinearSeqOptimized,scala.Function1)scala.Unit
[error] called from scala.collection.mutable.MutableList.foreach(scala.Function1)scala.Unit
[error] called from scala.collection.TraversableLike$WithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from scala.collection.immutable.Stream$StreamWithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from org.scalajs.testinterface.internal.Slave.org$scalajs$testinterface$internal$Slave$$execute(scala.scalajs.js.Dynamic)scala.Unit
[error] called from org.scalajs.testinterface.internal.Slave.handleMsgImpl(java.lang.String,scala.Function0)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.handleMsg(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$anonfun$1(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.init()scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$js$exported$meth$init()java.lang.Object
[error] called from org.scalajs.testinterface.internal.BridgeBase.init
[error] exported to JavaScript with #JSExport
[error] involving instantiated classes:
[error] com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$
[error] com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2
[error] scala.collection.mutable.Queue
[error] scala.collection.mutable.MutableList
[error] scala.collection.TraversableLike$WithFilter
[error] scala.collection.immutable.Stream$StreamWithFilter
[error] org.scalajs.testinterface.internal.Slave
[error] org.scalajs.testinterface.internal.Master
[trace] Stack trace suppressed: run last client/compile:fastOptJS for the full output.
[error] (client/compile:fastOptJS) There were linking errors
[error] Total time: 36 s, completed May 10, 2016 2:01:07 AM
What I've tried
Being unfamiliar with the details of the linker I am only able to try some "obvious" diagnostics:
Whether I call the method or not, this error is thrown (it doesn't have to be in the code path, so this is getting thrown when the method itself is linked)
The Map type itself works just fine as an argument to the function where I am trying to invoke this
I know to a certainty that iff this method (or similar) is present, then I get the above linker error. (Without, no error.)
Any tips on how to proceed, debug, etc are appreciated.
Alternatively, any tips on how I may convert a case class to a Map without the above-style (reflection-based) function, please let me know
You simply can't use Java reflection in Scala.js:
Java reflection and, a fortiori, Scala reflection, are not supported. There is limited support for java.lang.Class, e.g., obj.getClass.getName will work for any Scala.js object (not for objects that come from JavaScript interop).
Use macros for this instead. See e.g. Scala Macros: Making a Map out of fields of a class in Scala

In the Play Route's file, how can indicate to use routes from a module?

Currently trying to follow Manning's Play for Scala, specifically the section on testing a module before publishing.
I've created a module named "Ean2BarcodePlayModule" with organization "net.nowhereatall.playforscala".
I've used activator to publish local to ~/.ivy2/local
In my test project, I've added the library dependency:
"net.nowhereatall.playforscala" %% "ean2barcodeplaymodule" % "1.0-SNAPSHOT"
Now, I'd like to modify my routes file to indicate
-> /barcode Ean2BarcodePlayModule.Routes
but this results in:
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
not found: value Ean2BarcodePlayModule
[error] -> /barcode Ean2BarcodePlayModule.Routes
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: no
t found: value Ean2BarcodePlayModule
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: va
lue setPrefix is not a member of Any
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
not found: value Ean2BarcodePlayModule
[error] -> /barcode Ean2BarcodePlayModule.Routes
[error] four errors found
[error] (compile:compile) Compilation failed
[error] Total time: 4 s, completed Mar 12, 2015 1:36:34 PM
alternatively, if I try:
Now, I'd like to modify my routes file to indicate
-> /barcode net.nowhereatall.playforscala.Ean2BarcodePlayModule.Routes
the result is:
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
object nowhereatall is not a member of package net
[error] -> /barcode net.nowhereatall.playforscala.Ean2Ba
rcodePlayModule.Routes
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: ob
ject nowhereatall is not a member of package net
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: va
lue setPrefix is not a member of Any
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
object nowhereatall is not a member of package net
[error] -> /barcode net.nowhereatall.playforscala.Ean2Ba
rcodePlayModule.Routes
[error] four errors found
[error] (compile:compile) Compilation failed
[error] Total time: 6 s, completed Mar 12, 2015 1:35:56 PM
What is the correct way to do this?
With thanks to #Sarvesh Kumar Singh for directing me to the page on "SubProjects", the solution was relatively simple.
Rename "routes" in the the module source to "barcode.routes".
Redo activator publish-local.
In the "Test" project route file, include the required line as
-> /barcode barcode.Routes
(Note the last "R" in "Routes" is capital. That seems to be important!)

Vaadin Compile widgets (addons) in NetBeans

I'm following the provided instructions but is not working. I'm getting this error:
INFO: Widgetsets found from classpath:
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:Z:/vaadin/vaadin-6.7.1.jar!/
org.vaadin.peter.contextmenu.ContextmenuWidgetset in jar:file:Z:/NetBeans/Xinco/2.01.xx/XincoLibs/ContextMenu3.1.0.jar!/
getAvailableWidgetSets
INFO: Search took 12ms
Exception in thread "main" java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:414)
at java.io.File.getCanonicalPath(File.java:589)
at com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder.updateWidgetSet(WidgetSetBuilder.java:79)
at com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder.main(WidgetSetBuilder.java:52)
I found a related bug but it's been reported for a long time without fix yet. Any ideas besides checking/modifying the code myself?
Edit: Looking closer at the output I noticed this errors:
Compiling module org.vaadin.peter.contextmenu.ContextmenuWidgetset
Validating newly compiled units
[ERROR] Errors in 'file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/Vaadin%20Addons/ContextMenu3-1-0/org/vaadin/peter/contextmenu/client/ui/VContextMenu.java'
[ERROR] Line 1: The declared package "org.vaadin.peter.contextmenu.client.ui" does not match the expected package "ContextMenu3-1-0.org.vaadin.peter.contextmenu.client.ui"
[ERROR] Line 5: The import org.vaadin.peter.contextmenu.client cannot be resolved
[ERROR] Line 125: VMenuItem cannot be resolved to a type
[ERROR] Line 174: VMenuItem cannot be resolved to a type
[ERROR] Errors in 'file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/Vaadin%20Addons/ContextMenu3-1-0/org/vaadin/peter/contextmenu/client/ui/VMenu.java'
[ERROR] Line 1: The declared package "org.vaadin.peter.contextmenu.client.ui" does not match the expected package "ContextMenu3-1-0.org.vaadin.peter.contextmenu.client.ui"
[ERROR] Line 219: The method itemClicked(VMenuItem) from the type VContextMenu refers to the missing type VMenuItem
[ERROR] Line 229: The method itemClicked(VMenuItem) from the type VContextMenu refers to the missing type VMenuItem
[ERROR] Line 239: The method itemClicked(VMenuItem) from the type VContextMenu refers to the missing type VMenuItem
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/com/google/gwt/editor/client/EditorDriver.java'
[ERROR] Line 20: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR] Line 97: ConstraintViolation cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/com/google/gwt/editor/client/impl/AbstractSimpleBeanEditorDriver.java'
[ERROR] Line 28: Name clash: The method setConstraintViolations(Iterable<ConstraintViolation<?>>) of type BaseEditorDriver<T,E> has the same erasure as setConstraintViolations(Iterable<ConstraintViolation<?>>) of type EditorDriver<T> but does not override it
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/com/google/gwt/editor/client/impl/BaseEditorDriver.java'
[ERROR] Line 31: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR] Line 67: ConstraintViolation cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/com/google/gwt/editor/client/impl/SimpleViolation.java'
[ERROR] Line 25: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR] Line 40: ConstraintViolation cannot be resolved to a type
[ERROR] Line 43: ConstraintViolation cannot be resolved to a type
[ERROR] Line 44: Missing code implementation in the compiler
[ERROR] Line 49: ConstraintViolation cannot be resolved to a type
[ERROR] Line 49: Missing code implementation in the compiler
[ERROR] Line 70: ConstraintViolation cannot be resolved to a type
[ERROR] Line 72: ConstraintViolation cannot be resolved to a type
[ERROR] Line 73: ConstraintViolation<?> cannot be resolved to a type
[ERROR] Line 77: ConstraintViolation<capture#2-of ?> cannot be resolved to a type
[ERROR] Line 81: ConstraintViolation<capture#3-of ?> cannot be resolved to a type
[ERROR] Line 89: ConstraintViolation<capture#4-of ?> cannot be resolved to a type
[ERROR] Line 93: ConstraintViolation<capture#5-of ?> cannot be resolved to a type
[ERROR] Line 98: ConstraintViolation cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/com/google/gwt/editor/client/testing/MockSimpleBeanEditorDriver.java'
[ERROR] Line 26: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR] Line 35: The type MockSimpleBeanEditorDriver<T,E> must implement the inherited abstract method EditorDriver<T>.setConstraintViolations(Iterable<ConstraintViolation<?>>)
[ERROR] Line 107: Name clash: The method setConstraintViolations(Iterable<ConstraintViolation<?>>) of type MockSimpleBeanEditorDriver<T,E> has the same erasure as setConstraintViolations(Iterable<ConstraintViolation<?>>) of type EditorDriver<T> but does not override it
[ERROR] Line 108: ConstraintViolation cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/javax/validation/super/javax/validation/Configuration.java'
[ERROR] Line 93: TraversableResolver cannot be resolved to a type
[ERROR] Line 105: ConstraintValidatorFactory cannot be resolved to a type
[ERROR] Line 182: TraversableResolver cannot be resolved to a type
[ERROR] Line 182: No source code is available for type TraversableResolver; did you forget to inherit a required module?
[ERROR] Line 194: ConstraintValidatorFactory cannot be resolved to a type
[ERROR] Line 194: No source code is available for type ConstraintValidatorFactory; did you forget to inherit a required module?
[ERROR] Line 202: ValidatorFactory cannot be resolved to a type
[ERROR] Line 202: No source code is available for type ValidatorFactory; did you forget to inherit a required module?
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/javax/validation/ConstraintViolationException_CustomFieldSerializer.java'
[ERROR] Line 30: ConstraintViolationException cannot be resolved to a type
[ERROR] Line 34: ConstraintViolationException cannot be resolved to a type
[ERROR] Line 34: No source code is available for type ConstraintViolationException; did you forget to inherit a required module?
[ERROR] Line 39: ConstraintViolation cannot be resolved to a type
[ERROR] Line 39: ConstraintViolation cannot be resolved to a type
[ERROR] Line 40: ConstraintViolationException cannot be resolved to a type
[ERROR] Line 44: ConstraintViolationException cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/javax/validation/super/javax/validation/MessageInterpolator.java'
[ERROR] Line 21: The import javax.validation.metadata cannot be resolved
[ERROR] Line 66: ConstraintDescriptor cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/javax/validation/super/javax/validation/constraints/Pattern.java'
[ERROR] Line 30: The import javax.validation.Constraint cannot be resolved
[ERROR] Line 31: The import javax.validation.Payload cannot be resolved
[ERROR] Line 49: Constraint cannot be resolved to a type
[ERROR] Line 49: The attribute validatedBy is undefined for the annotation type Constraint
[ERROR] Line 75: Payload cannot be resolved to a type
[ERROR] Errors in 'jar:file:/Z:/NetBeans/Xinco/3.00.xx/XincoLibs/gwt-user.jar!/javax/validation/super/javax/validation/spi/ConfigurationState.java'
[ERROR] Line 22: The import javax.validation.ConstraintValidatorFactory cannot be resolved
[ERROR] Line 24: The import javax.validation.TraversableResolver cannot be resolved
[ERROR] Line 93: ConstraintValidatorFactory cannot be resolved to a type
[ERROR] Line 107: TraversableResolver cannot be resolved to a type
I found this post about this issue pointing out to be a library mismatch but I'm using jars from the Vaadin SCM for the correct release: https://vaadin.com/forum/-/message_boards/view_message/384826
Issue finally fixed, hopefully that does the trick. After that had to add the following jars to the project so it could be compiled:
validation-api-1.0.0.GA.jar
validation-api-1.0.0.GA-sources.jar