Play 2.5.4 application not starting on Heroku - heroku

I'm trying to deploy a play 2.5.4 application, but it's not working.
Here is how my procfile looks like :
web: target/universal/stage/bin/playproject
plugins.sbt
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.4")
build.sbt
name := """playproject"""
scalaVersion in ThisBuild := "2.11.8"
....
On heroku here are the logs :
Any idea what's the problem ?

If you try to build your project, e.g try sbt stage, you will see, that there is no target/universal/stage/bin/playproject under the root folder of your project. Real Play app you have under examples folder, so in your Procfile you need to specify:
web: examples/target/universal/stage/bin/examples

Related

Dependencies put twice into Spring Boot (>2.x) jar when using Gradle

adding Cloud SDK like this for CF:
compile "com.sap.cloud.s4hana:s4hana-all:${cloudSDKVersion}"
compile ("com.sap.cloud.s4hana.cloudplatform:scp-cf:${cloudSDKVersion}")
leads to duplicate jars in spring boot jar which is deployed to CF.
examples:
core-2.3.1.jar
connectivity-2.3.1.jar
This leads to :
ClassNotFoundExceptions during runtime
prevents cf push commands with error:
Comparing local files to remote cache...
Aborting push: File BOOT-INF/lib/core-2.3.1.jar has been modified since the start of push. Validate the correct state of the file and try again.
FAILED
gradle skips the component name when building the boot package.
After some googling around this was the solution:
https://github.com/spring-projects/spring-boot/issues/10778
bootJar {
rootSpec.filesMatching('**/*.jar', { jar ->
String groupId = jar.file.parentFile.parentFile.parentFile.parentFile.name
jar.name = "$groupId-${jar.name}"
})
}

Angular Spring Boot Packaging Issue

I have the current project structure for a spring boot angular project
+--app-ui
|--+--src
|--+--dist
|--app-backend
|--+--src
|--+--+--main
|--+--+--+--resources
|--+--+--+--+--static
|--+--+--+--java
app-ui contains the angular 6 code app backend contains the spring boot code. Now everytime I build app-ui i want the dist folder contents in app-ui to be copied to app-backend/src/main/resources/static
In order to do that I have added these lines in the angular build
"predeploy": "rimraf ../app-backend/src/main/resources/static/ && mkdirp ../app-backend/src/main/resources/static",
"deploy": "copyfiles -f dist/** ../app-backend/src/main/resources/static/
This creates the static folder inside Spring boot project but it doesn't copy the files and folders inside dist folder.
If you are using AngularCLI (with an angular.json file), simply change the outputPath property to specify your desired static directory.
"outputPath": "../app-backend/src/main/resources/static"
I tried this way for integrating my angular app with spring-boot so the static code is atleast in spring boot app path. But I still couldn't see user interface when my spring app is running on port 8080.
Not sure if I'm missing something but majority of my frontend code that is; ng components .ts, .html and .css files are in frontend/src dir, which I didn't move anywhere. Any suggestions?

Differences in ivy/maven publishing for sbt plugin

I have two SBT plugins: PluginA and PluginB. PluginA depends on tasks in PluginB. Whenever I publish PluginB locally to "~/.ivy2" using "publishLocal", then PluginA works. Though the dependency still resolves when I publish PluginB using "publishM2" to my local "~/.m2" the compile task for PluginA fails:
"object xxx is not a member of package yyy".
I have tried setting "publishMavenStyle" to both true and false and adjusting the resolver, but neither work.
Why does this happen and is there a way to get this to work when publishing in a maven style?
This was a mistake on my part. I added plugin incorrectly by using from
addSbtPlugin("com.xxyy" %% "PluginA" % "0.0.2" from "http://internal.repo.com")
Though the POM was found, so the resource was found, the correspoinding the jar was not found so the build would fail.
To fix this I added a resolver before adding the plugin
resolvers += "xxyy" at "http://internal.repo.com"
addSbtPlugin("com.xxyy" %% "PluginA" % "0.0.2")

Play framework 2.5 not compiling source files (inside app folder)

We have a Play project with folder structure given in the link https://www.playframework.com/documentation/2.5.x/Anatomy.
We have addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.2") in plugins.sbt and in build.sbt we have added the below lines,
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.7"
While we give compile command (through activator), the project loads the dependency jars from build.sbt, but the .classes files are not generated in target folder.
Could anyone please help us in solving the issue?
We have solved the issue by adding the following line to build.sbt file,
javaSource in Compile := baseDirectory.value / "app"
After the addition of this, the .java files and .scala files inside the "app" folder gets compiled.

Heroku Golang - command 'main' not found

I got a Go API up on Heroku to which I push some code; in my procfile I have the following
web: main
In order to launch the Go built binary on Heroku's side. When I build it on my side with
go build cmd/main.go
It produces a binary file namned 'main' in my project root and works as expected but on Heroku I get
app[web.1]: bash: main: No such file or directory
The build process on Heroku seems fine, it finds all my dependencies and installs/compiles it all.
This was super simple once I realised this;
All main packages in the repo are compiled and binaries placed in the /app/bin directory, which is in the PATH. Binaries are named after the directory that contains them.
Another thing to note: Like other Go programs, the code in main.go has to belong to package main:
package main
func main() {
// your code here
}
I'm afraid I totally forgot about this at first and it stumped me for a while.

Resources