Deploy Scalatra on Heroku error - scala

I followed the guide of deploying a Scalatra app on Heroku and I get the following error:
[error] Not a valid command: stage (similar: last-grep, set, last)
[error] Expected '/'
[error] Expected ':'
[error] Not a valid key: stage (similar: state, target, tags)
[error] stage
[error] ^
Any help would be much appreciated.

I had a similar issue. In the end I just looked through this complete example and made sure I had everything in place from there - https://github.com/scalatra/scalatra-website-examples/tree/master/2.2/deployment/scalatra-heroku

Related

How can I migrate from avro4s 3.0.4 to 4.0.0-RC2?

How can I migrate from avro4s 3.0.4 to 4.0.0-RC2?
I have the following compiling errors:
[error] /Users/nicolae.marasoiu/proj/data-availability-global-topic-conveyor/src/main/scala/com/ovoenergy/globaltopics/serdes/AvroFormatImplicits.scala:8:15: value const is not a member of object com.sksamuel.avro4s.SchemaFor
[error] SchemaFor.const(new Schema.Parser().parse(getClass.getResourceAsStream(hasSchema.resourcePath)))
[error] ^
[error] /Users/nicolae.marasoiu/proj/data-availability-global-topic-conveyor/src/main/scala/com/ovoenergy/globaltopics/serdes/AvroFormatImplicits.scala:11:26: not enough arguments for method apply: (implicit evidence$1: com.sksamuel.avro4s.Encoder[T], implicit evidence$2: com.sksamuel.avro4s.Decoder[T])com.sksamuel.avro4s.RecordFormat[T] in object RecordFormat.
[error] Unspecified value parameter evidence$2.
[error] RecordFormat.apply[T](AvroSchema[T](readSchema))
[error] ^
[error] /Users/nicolae.marasoiu/proj/data-availability-global-topic-conveyor/src/main/scala/com/ovoenergy/globaltopics/serdes/SerdeProvider.scala:29:37: org.apache.avro.Schema does not take parameters
[error] val schema = SchemaFor[T].schema(DefaultFieldMapper)
[error] ^
[error] /Users/nicolae.marasoiu/proj/data-availability-global-topic-conveyor/src/main/scala/com/ovoenergy/globaltopics/serdes/SerdeProvider.scala:37:70: no arguments allowed for nullary method build: ()com.sksamuel.avro4s.AvroOutputStream[T]
[error] val os = AvroOutputStream.binary[T].to(output).build(schema)
[error] ^
[error] four errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 17 s, completed 28-Jul-2020 19:42:21
[IJ]sbt:global-topic-conveyor>
First of all, you can always follow the changes at avro4s github repository. Furthermore, you can see the specific changes made between the versions you specified.
You did not attach any source code, so I'll try to address your failures as I can understand them from your failures.
SchemaFor.const was removed at version 3.0.5 . You can see that in the diff between the versions. Assuming you had Schema s, and you initiated so far the SchemaFor.const(s), Now you'll need to initiate it: SchemaFor(s). The default fieldMapper will be used. You can see it here.
RecordFormat does not take arguments anymore. Therefore assuming you had a type T, that was applied at RecordFormat.apply[T](AvroSchema[T](readSchema)), you need to change it into: RecordFormat[T].
Very similar to number 1. SchemaFor.schema was removed. Instead, you can just do: SchemaFor[T].schema. Schema does not take parameters anymore, so you cannot call it with parentheses.
AvroOutputStream.build used to take a schema as a parameter. It doesn't take it anymore. You need to change AvroOutputStream.binary[T].to(output).build(schema) into: AvroOutputStream.binary[T].to(output).build()

Error:Expected letter.. while running play multi project

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

Spark: Error while compressing and saving to text file

I have a scala Spark job. I want to compress the output using Gzip and then saveToTextFile.
compressedEvents.saveAsTextFile(outputDirectory, org.apache.hadoop.io.compress.GzipCodec)
But I get the following error:
[error] /var/lib/jenkins/workspace/producer-data-test/producer-data-test-build/src/main/scala/IpFromLogs.scala:46: object org.apache.hadoop.io.compress.GzipCodec is not a value
[error] compressedEvents.saveAsTextFile(outputDirectory, org.apache.hadoop.io.compress.GzipCodec)
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
I tried different variations of the same but none of them work. Please help!
Correct way of saving is
compressedEvents.saveAsTextFile(outputDirectory, classOf[GzipCodec])
Or
before you save set the configuration as
sc.hadoopConfiguration.setClass(FileOutputFormat.COMPRESS_CODEC, classOf[GzipCodec], classOf[CompressionCodec])
And save it as
compressedEvents.saveAsTextFile(outputDirectory)

crosstool-ng build fails: CT_TARGET command not found

I am trying to build a cross compiler for raspberry pi. I am using crosstool-ng to build this compiler. I am following this link for reference. I have made all configurations as told in the link. But when i tried to build, I am getting "CT_TARGET command not found" error. I tried googling about the error couldn't able to find any hits. Could someone help me in overcoming this issue? Here is the complete build output.
/opt/cross/bin$ sudo ct-ng build
/opt/cross/bin/.config.2: line 30: CT_TARGET: command not found
[ERROR]
[ERROR] >>
[ERROR] >> Build failed in step '(top-level)'
[ERROR] >>
[ERROR] >> Error happened in: source[/opt/cross/bin/.config.2#30]
[ERROR] >> called from: main[scripts/crosstool-NG.sh#25]
[ERROR] >>
[ERROR] >> There is a list of known issues, some with workarounds, in:
[ERROR] >> '/opt/cross/share/doc/crosstool-ng/ct-ng.1.21.0/B - Known issues.txt'
[ERROR]
[ERROR] (elapsed: 24087567:26.24)
make: *** [build] Error 127
It seems you made a mistake entering the configuration options.
You need to make sure that you put a $ symbol in front of CT_TARGET:
$CT_TARGET
or else it thinks it is a command that will return the value it wants.
Posting your exact config instead of the website you got the instructions from would provide much more details to solve your specific issue.

Simple scalatra-test specs2 example throws Exception

I'm getting this exception when running the scalatra specs2 example from the scalatra docs:
ThrowableException: org.eclipse.jetty.http.HttpGenerator.flushBuffer()I (FutureTask.java:138)
Here is the test code (starting on line 5, skipping imports):
class MyAppTest extends MutableScalatraSpec {
addServlet(classOf[MyApp], "/*")
"GET / on AdminApp" should {
"return status 200" in {
get("/") {
status must_== 200
}
}
}
}
Here is the app definition:
class MyApp extends ScalatraServlet {
get("/") {
"aloha"
}
}
I'm using scalatra-specs2 2.0.4 and scala 2.9.1. I'm running an embedded jetty server using xsbt-web-plugin 0.2.10 with sbt 0.11.2. The test was executed using sbt test.
Here is the full trace:
[info] GET / on AdminApp should
[error] ! Fragment evaluation error
[error] ThrowableException: org.eclipse.jetty.http.HttpGenerator.flushBuffer()I (FutureTask.java:138)
[error] org.eclipse.jetty.testing.HttpTester.generate(HttpTester.java:225)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:46)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:71)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.get(ScalatraTests.scala:127)
[error] com.example.MyAppTest.get(MyAppTest.scala:5)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
[error] org.eclipse.jetty.http.HttpGenerator.flushBuffer()I
[error] org.eclipse.jetty.testing.HttpTester.generate(HttpTester.java:225)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:46)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.submit(ScalatraTests.scala:71)
[error] com.example.MyAppTest.submit(MyAppTest.scala:5)
[error] org.scalatra.test.ScalatraTests$class.get(ScalatraTests.scala:127)
[error] com.example.MyAppTest.get(MyAppTest.scala:5)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
[error] com.example.MyAppTest$$anonfun$1$$anonfun$apply$3.apply(MyAppTest.scala:10)
This is the only search result that has turned up so far:
Fragment Evaluation Error.
Can someone point me in the right direction?
Thanks,
-f
Still unsure of the root cause, but the test executes successfully after rolling jetty-webapp back from 8.0.3.v20111011 to 7.6.0.v20120127.
You probably have a conflict in your dependencies, more specifically with the Jetty library version. Since the "flush" method on HttpGenerator has changed between Jetty 6 and Jetty 7, you might be getting a "NoSuchMethodFoundError" which explains the strange "org.eclipse.jetty.http.HttpGenerator.flushBuffer()I" signature in the exception message.
This also explains why you get a "fragment evaluation error" and not a regular failure as explained in the link you mentioned.
If you give a go at the latest specs2-1.10-SNAPSHOT, you will get a better message for "fragment evaluation error" showing 'NoSuchMethodError' when that happens. This will help you diagnosing the issue faster.