Try to run sbt shell gives me error server failed to start error 5 - eclipse

I was following the tutorial for build an scalable websocket app in Heroku, following the tutorial Writing Scalable WebSocket Applications on Heroku and trying to set up Play Framework to work on Eclipse IDE, downloaded play-samples-play-java-hello-world-tutorial from Play Framework site, added sbt-plugin annotation in plugins.sbt file, git bashed from project folder and tried the command sbt, it gives me, following error and I can't proceed with compile command:
server failed to start on local:sbt-server-cc02d04ca19b451f676c. java.io.IOException: Could
not create lock for \\.\pipe\sbt-server-cc02d04ca19b451f676c_lock, error 5

Related

Heroku error running Play: controllers/routes has been compiled by a more recent version of the Java Runtime

I am trying to run Play on Heroku...
The full error is:
play.api.UnexpectedException: Unexpected exception[RuntimeException: java.lang.UnsupportedClassVersionError: controllers/routes has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0] (58 is Java 14 and 55 is Java 11).
The Heroku help says:
Make sure you are using the correct JDK version by setting it in the system.properties file.
I added the following to system.proprties:
java.runtime.version=14.0.1.
And I can see it gets used by the Heroku compile. But I still get the error.
I thought that maybe the problem was the other way around so I also tried:
java.runtime.version=11.0.8
I also tried adding the following to application.conf
java.source=11.0.8
And for completeness java.source=14.0.1
When I run locally without Heroku (sbt compile stage) all is fine.
I have tried with the Play example from Heroku and also the Play example from Play (adding a procfile)... the result is the same.
The Play version is:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.2")
I tried putting in some older versions but Heroku failed to compile.
I went back to trying to get the Heroku version to run locally (rather than the other way around). From the resulting error message I found that sbt installed via brew adds a dependency to JDK 13:
SBT fails with `String.class is broken`
I followed the fix listed there and installed sbt using SDKMAN (instructions here:
https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Mac.html)
This got me to the next error which was due to "old SBT version":
java.lang.NullPointerException in project root running sbt
After fixing this, I can now run Play on Heroku and locally

How to resolve: ERROR Error while starting connector "java.lang.NoSuchFieldError: SYSTEM"

I am not able to get kafka-connect-jdbc
working with Kafka 0.10.1 on HDInsight Cluster. Here are the steps I went thru so far:
I cloned the repo and ran mvn install and after struggling with the dependencies (not SNAPSHOTS), I got the jar.
moved it to ./libs and I was able to see io.confluent.connect.jdbc.JdbcSourceConnector & io.confluent.connect.jdbc.JdbcSinkConnector when hitting GET /connector-plugins.
I created a source connector to Azure SQLServer & a topic.
I am getting the following error once, the source connector is created:
[2018-02-14 15:46:16,960] ERROR Error while starting connector azure-source-connector-test (org.apache.kafka.connect.runtime.WorkerConnector:108)
java.lang.NoSuchFieldError: SYSTEM
at io.confluent.connect.jdbc.source.JdbcSourceConnectorConfig.(JdbcSourceConnectorConfig.java:184)
at io.confluent.connect.jdbc.JdbcSourceConnector.start(JdbcSourceConnector.java:69)
at org.apache.kafka.connect.runtime.WorkerConnector.doStart(WorkerConnector.java:100)
at org.apache.kafka.connect.runtime.WorkerConnector.start(WorkerConnector.java:125)
at org.apache.kafka.connect.runtime.WorkerConnector.transitionTo(WorkerConnector.java:182)
at org.apache.kafka.connect.runtime.Worker.startConnector(Worker.java:165)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder.startConnector(DistributedHerder.java:773)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder.startWork(DistributedHerder.java:747)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder.handleRebalanceCompleted(DistributedHerder.java:708)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder.tick(DistributedHerder.java:204)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder.run(DistributedHerder.java:174)
at java.lang.Thread.run(Thread.java:748)
I tried different versions/branches of kafka-connect-jdbc but all trials end with the same error.
This question
has same issue, so I tried to force the build to use connect-api-0.10.1.2.6.2.3-1.jar via systemPath in pom.xml but if the build goes thru, it still has the same issue.
Any idea?

Failed to load sbt configuration Play-Scala

i was trying to make a new project with play-scala in my activator, but i keep getting this error:
java.lang.NoClassDefFoundError: play/Play$
Use 'last' for the full log.
Failed to load project.
I found the answer here:
Why does sbt fail with NoClassDefFoundError: play/Play$ in Play 2.2.x projects after sbt compile in Play 2.3 project?
The project/play-fork-run.sbt file in the your-project-name\project folder needs to be removed if you tried the entire process through the "activator ui" web interface.

Deploying Play Framework 2.3.x (Java style) on Ubuntu 14.04 production server

I have a Play application on my laptop, which I am trying to get running on my production server. Locally the application compiles and works without errors.
On my production server, I do the following:
root#example:~/mysite# ./activator
[info] Loading project definition from home/mysite/project
[info] Set current project to mysite (in build file:/home/mysite/)
[mysite] $ ~run
--- (Running the application, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 4 Scala sources and 2 Java sources to /home/mysite/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling...
Killed
root#example:~/mysite#
As you can see, `compiler-interface' is not yet compiled. I am wondering why this is. Is this because I don't have the Scala compiler installed?
Probably the Killed part is because you don't have enough memory to compile your application.
Either way I think it would be better to deploy your app already compiled than compile it on place. You can do that using ./activator dist.
This will generate a zip file in YOUR_PROJECT_DIR/target/universal named YOUR-PROJECT-NAME-VERSION.zip with everything already compiled and with every needed dependency packaged already. You can then upload this file to somewhere in your production server, extract it and then start the server using
$ EXTRACTED_FOLDER/bin/YOUR-APP-NAME
If you still want to build it in your production server, try to reduce the memory used by activator using
$ ./activator -mem 200 # MAX 200mb
// (...)
[PROJECT-NAME] ~start
Note that ~run will start your server in dev mode (ie sensible information like stacktraces etc can be shown on error) and recompile it on changes, so you may want to use start or ~start instead.

How to use IntelliJ with Play Framework and Scala

I am trying to use IntelliJ with a play framework 2.11 application.
I installed the Play Framework 2 plugin and the Scala plugin for IntelliJ.
I created a Play application. I have been struggling writing and running Specs 2 tests in IntelliJ. My run config says to run "make" first when running the Specs 2 test, however it doesn't look like my test classes are being generated. Keeps on telling me that it could not find the specification. When I look on the file system, there is no code in target/test-classes, the directory is empty. Further, it seems to take a LONG time to do the build, at least compared to running the Play console.
I wanted to see how people are using Play with IntelliJ. Do you just use IntelliJ as an editor, and run everything through the Play console?
Is there a way whereby you can run your Application tests in IntelliJ (getting your test classes to run)?
I have never had any problem running the Play console and running ~test-only test=xxx.Spec. It has typically been rather fast.
Here is the exception I am getting in IntelliJ when I try to run my Specs2 tests:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:130)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.RuntimeException: can not create specification: test.ApplicationSpec
at scala.sys.package$.error(package.scala:27)
at org.specs2.specification.SpecificationStructure$.createSpecification(BaseSpecification.scala:96)
at org.specs2.runner.ClassRunner.createSpecification(ClassRunner.scala:64)
at org.specs2.runner.ClassRunner.start(ClassRunner.scala:35)
at org.specs2.runner.ClassRunner.main(ClassRunner.scala:28)
at org.specs2.runner.NotifierRunner.main(NotifierRunner.scala:24)
... 11 more
Update: In newer versions if IntelliJ IDEA, it is no longer necessary to create the module from play/activator. IntelliJ IDEA has now a really good support for SBT projects. If exists, delete all the idea related directories inside your project. Then in IntelliJ IDEA click File -> Open and choose your build.sbt file. That's all.
IntelliJ IDEA has a good integration for the Play Framework 2. Sometimes it jams, but most of the time it runs. I use it to run(single, all) tests, start or debug the play application and edit my code (o; And this all from within the IDE and without the sbt console.
Here is a short tutorial with the most important steps. Currently I use IntelliJ IDEA 12.1 with the newest Play Framework 2 and Scala plugins.
1. Create a new application
play new myapp
2. Create the IDE module
Start the play console:
cd newapp
play
Create the module:
idea with-sources=yes
exit
3. Configure the IDE
Open the newly created project
Open the module settings(select project and press F4)
Add the Scala library to your project
Select Modules->myapp->Dependencies
Press the plus Icon and select Library(2)
Add the Scala 2.10.0 Project Library
Select the Compiler Library in the Scala Facet
Select Facets->Scala(myapp)
Set the Compiler library to Scala 2.10.0
Fix the errors
Select Modules->myapp-build->Dependencies->scala-2.9.2 and press the minus icon
Select Libraries->Scala 2.9.2 and press the minus icon
Fix the output Path for the myapp-build module
Select Modules->myapp-build->Paths
Append classes to the Output path(X:\projects\myapp\project\target\scala_2.9.2\classes)
Append test-classes to the Test output path(X:\projects\myapp\project\target\scala_2.9.2\test-classes)
4. Run a test
Select the ApplicationSpec under the test directory and click Run 'ApplicationSpec' from the context menu. You should get an error that the compiled template could not be found. This is because the IDE doesn't compile the templates, but this can be done by run the application once. Also follow point 5 and then run the test again.
5. Run the application
Select a controller and click Run Play 2 App from context menu. This should start the application on address: http://localhost:9000/.
6. Update dependencies
If you update your application dependencies then you must tell the IDE about this changes. Also after running the play update command you must close the IDE and remove some files from project directory. If you execute the play idea command before removing the files, you get double dependencies in your play project.
Execute the following steps to update your dependencies:
Run the update task from your play console
Remove the .idea_modules and .idea/libraries directories
Run the idea with-sources=yes command in the play console
Run step 3 again
Play console includes a fork of a sbt plugin named sbt-idea. The play's fork got a little lagged behind the original plugin, and has some problems in IntelliJ when you run play idea. You can use the original plugin, which doesn't have any issues. In order to use this plugin in your play project, you need to..
1.Add the following lines to project/plugins.sbt file: (the blank line in the middle is required)
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
2.Run gen-idea from the play console.
I usually used IntellijIDEA (version 12.0.4) only for Play Framework code editor because of:
Auto saving feature by default
Rather fast IntelliSense feature
Dracula UI, it is an eye-pleasure for me
And I usually run and debug the apps with Play SBT console. It's reasonable fast. But, sometimes when executing play command on console, I found that the loading-project-info task take too long time (nearly 10 minutes). I don't know why this sometimes happen, but overall the use of Play SBT console is my choice.
I'm doing that because there is usually should-not-be-the-problem-things intepreted as error like following :
The first time when I start learning Play Framework, I was facing such problem. So, at the end, I choose to use Play SBT console to run and debugging app then.
And sorry I cannot answer for the question number 2. Until now I only tried running and debugging play application. For testing purpose I've never tried before for Play 2.x.