Play 2.0 not auto-reloading - java

My Play 2.0 test application dose not seem to auto-reload after I change some files. The console shows [info] Compiling 1 Java source to /java/todolist/target/scala-2.9.1/classes... when I change + save a file, but the the content in the browser stays unchanged. Play is running in Dev mode with auto-reloading enabled.
Console output:
$ play run
[info] Loading project definition from /data/dev/java/todolist/project
[info] Set current project to todolist (in build file:/data/dev/java/todolist/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on port 9000...
(Server started, use Ctrl+D to stop and go back to the console...)
[info] play - Application started (Dev)
[info] Compiling 1 Java source to /data/dev/java/todolist/target/scala-2.9.1/classes...

Run play clean and restart your Play application and Play should start auto-reloading the files on the next startup.

Related

Server error 500 when accessing deployed springboot-vaadin app on Google Cloud

Please can somebody help with this problem? I am new to Google Cloud and my deployed springbboot - vaadin app on Google Cloud says server error 500 when accessing via browser.
Context:
spring boot driven vaadin app in jar format
google cloud dependencies added to maven
spring security embedded in app with encrypted credentials in MySql db
app was deployed via Google Cloud CLI
service account in google cloud created - maybe missing some permissions
Error reporting in google cloud says this error:
java.io.IOException: Server returned HTTP response code: 403 for URL: https://clouddebugger.googleapis.com/v2/controller/debuggees/register
I studied a lot about this issue, but maybe main reason of this error is not clear for me. Why any security solution for access for public users is needed from google cloud? ... I supposed, that this is solved by spring boot security on the app side and that app will have a public access without any restrictions from google cloud side. As I say - I probably miss concept of this whole. So please can me somebody explain this and help with solving that exception? Thank you very much.
...
Cloud Run ... this service seems to be disabled
App Engine ... this service is running, but the "instance summary" section seems to be empty ... however by the logs and usage of app.yaml it seems this is intended to run on App Engine (I am sorry - I only followed the steps from this manuals - I have no experience with Google Cloud platform) ... app.yaml contains onle one single row -> "runtime: java11"
I followed these manuals before:
book: Building Modern Web Apps with Spring Boot and Vaadin
web: https://vaadin.com/docs/latest/production/cloud-providers/google
Certain steps (... and some of log records from console) were these:
in Intellij Idea (Run Configuration) ... package appengine:deploy -Pproduction
in console ... generally log records about building backend and frontend
[INFO] Staging the application to: D:<APP-NAME>\target\appengine-staging
[INFO] Detected App Engine app.yaml based application.
okt 14, 2022 4:22:32 AM com.google.cloud.tools.appengine.operations.GcloudRunner run
INFO: submitting command: C:\Users\Ján\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\bin\gcloud.cmd app deploy --project
[INFO] GCLOUD: Services to deploy:
[INFO] GCLOUD: descriptor: [D:<APP-NAME>\target\appengine-staging\app.yaml]
[INFO] GCLOUD: source: [D:<APP-NAME>\target\appengine-staging]
[INFO] GCLOUD: target project: []
[INFO] GCLOUD: target service: [default]
[INFO] GCLOUD: target version: [20221014t042237]
[INFO] GCLOUD: target url: [https://.lm.r.appspot.com]
[INFO] GCLOUD: target service account: [App Engine default service account]
[INFO] GCLOUD: Beginning deployment of service [default]...
[INFO] GCLOUD: #============================================================#
[INFO] GCLOUD: #= Uploading 1 file to Google Cloud Storage =#
[INFO] GCLOUD: #============================================================#
[INFO] GCLOUD: File upload done.
[INFO] GCLOUD: Updating service [default]...
[INFO] GCLOUD: ...done.
[INFO] GCLOUD: Setting traffic split for service [default]... done.
[INFO] GCLOUD: Deployed service [default] to [https://.lm.r.appspot.com]
[INFO] GCLOUD: You can stream logs from the command line by running:
[INFO] GCLOUD: $ gcloud app logs tail -s default
[INFO] GCLOUD: To view your application in the web browser run:
[INFO] GCLOUD: $ gcloud app browse
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -----------------------------------------------------------------------
... and theses are the last rows from Logs Explorer:
2022-10-14 02:35:29.389 INFO 10 --- [ main] : Started - Application in 10.057 seconds (JVM running for 11.18)
2022-10-14 02:35:29.476 INFO 10 --- [nio-8081-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-10-14 02:35:29.477 INFO 10 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-10-14 02:35:29.478 INFO 10 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2022-10-14 02:35:29.524 INFO 10 --- [nio-8081-exec-2] c.v.f.s.DefaultDeploymentConfiguration : Vaadin is running in production mode.
Exceeded hard memory limit of 256 MB with 265 MB after servicing 0 requests total. Consider setting a larger instance class in app.yaml.
[start] 2022/10/14 02:35:30.579484 Quitting on terminated signal

Azure App Service deploy of Spring Boot app not working from Jenkins

I have a Spring Boot application running as an Azure App Service. I can deploy it using the Maven plugin, but not from Jenkins. The strange thing is that it has already worked from Jenkins before.
When deploying with Maven (using mvn azure-webapp:deploy), I see something like:
[INFO] Auth Type : AZURE_CLI, Auth Files : [/Users/wdb/.azure/azureProfile.json, /Users/wdb/.azure/accessTokens.json]
[INFO] [Correlation ID: ab463b1c-xxxx-xxxx-xxxx-xxxxxxxxxxxx] Instance discovery was successful
[INFO] Subscription : MY_SUBSCRIPTION(797bdef0-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
[INFO] Updating App Service Plan...
[INFO] Updating target Web App...
[INFO] Successfully updated Web App.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to /Users/wdb/Projects/my-project/target/azure-webapp/my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e20
[INFO] Trying to deploy artifact to my-project-backend-staging...
[INFO] Renaming /Users/wdb/Projects/my-project/target/azure-webapp/my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e20/my-project-backend-staging-0.0.1-SNAPSHOT.jar to app.jar
[INFO] Deploying the zip package my-project-backend-staging-80a97da7-6abf-49f4-9f4f-df92b8d38e204401718728513612670.zip...
[INFO] Successfully deployed the artifact to https://my-project-backend-staging.azurewebsites.net
I have this in my Jenkinsfile (using the Azure App Service Jenkins Plugin):
dir('target') {
sh '''
cp my-project-backend-*.jar app.jar
'''
azureWebAppPublish azureCredentialsId: 'JenkinsMyProjectBackendServicePrincipal',
resourceGroup: 'MYPROJECT-BACKEND',
appName: 'myproject-backend',
filePath: "app.jar"
}
When the build is run, I see this in the logging:
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://myproject-backend-staging.scm.azurewebsites.net:443/myproject-backend-staging.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Counting objects: 74, done.
remote: Compressing objects: 2% (1/48)
remote: Compressing objects: 4% (2/48)
remote: Compressing objects: 6% (3/48)
remote: Compressing objects: 8% (4/48)
remote: Compressing objects: 10% (5/48)
remote: .
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:802)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:154)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:375)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:73)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
The problem is that the Azure Jenkins plugin checks the linuxFxVersion to contain jre. But if you use Java 11, this is not the case (The value is something like JAVA|11-java11). Because of that, it wrongly thinks that it is not a Java platform to deploy to.
I fixed the issue and opened a PR at https://github.com/jenkinsci/azure-app-service-plugin/pull/63.
I am currently using my locally build version until they pick up this PR.
Next to that, I also had to create a zip file to make it fully work:
dir('target') {
sh '''
cp my-project-backend-*.jar app.jar
'''
zip zipFile: 'app.zip', glob: 'app.jar'
azureWebAppPublish azureCredentialsId: 'JenkinsMyProjectBackendServicePrincipal',
resourceGroup: 'MYPROJECT-BACKEND',
appName: 'my-project-backend-staging',
filePath: "app.zip"
}

Network errors while creating a new play application

I'm trying to create a new play application and I'm getting java.net.SocketTimeoutException.
I'm also getting it while trying to update dependencies.
My network connection is just fine. I'm able to browse, however my feeling is that every time I run an activator / play command, I get network error.
Is there any settings which can effect this? Proxy settings? Maybe something in the Java level?
Here's an example of my errors:
D:\Git_Work\RSVP>activator ui
Checking for a newer version of Activator (current version 1.3.4)...
... failed to get latest version information: java.net.SocketTimeoutException: Read timed out
Found previous process id: 6464
Local repository: activator-launcher-local # file:////D:/Program%20Files/PlayFramework/activator-1.3.5-minimal/repository
Local repository: activator-local # file:////D:/Java/typesafe-activator-1.3.4/activator-1.3.4/repository
Play server process ID is 6900
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /127.0.0.1:8888
[info] a.e.s.Slf4jLogger - Slf4jLogger started
[info] application - Failed to record a clone of 'play-java-intro-preview': java.net.SocketTimeoutException: Read timed out
I'll appreciate your help!

Why does system downloads Google App Engine Java SDK from Maven everytime in a new workspace?

Why does system retrieve Google App Engine Java SDK from Maven everytime I run mvn appengine:devserver in new project? This process takes a lot of time because of large size. Moreover I have already downloaded Google App Engine Java SDK. I have added the <sdk>/bin
in PATH environment variable.
Following are the messages in my terminal.
[INFO]
[INFO] <<< appengine-maven-plugin:1.8.7:devserver (default-cli) # project-ear <<<
[INFO]
[INFO] --- appengine-maven-plugin:1.8.7:devserver (default-cli) # project-ear ---
[INFO]
[INFO] Google App Engine Java SDK - Running Development Server
[INFO]
[INFO] Retrieving Google App Engine Java SDK from Maven
Downloading: http://repo.maven.apache.org/maven2/com/google/appengine/appengine-java-sdk/1.8.7/appengine-java-sdk-1.8.7.zip
Before starting the server, pom.xml in the main application directory should be modified so that inside the element points to the installed App Engine SDK version.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<appengine.target.version>1.9.5</appengine.target.version>
</properties>
In the above code, version is to be mentioned in the <appengine.target.version> tag.
If you have already downloaded the SDK zip file install it to maven as following.
Change file name and version as required.
mvn install:install-file -Dfile=appengine-java-sdk-1.9.36.zip -DgroupId=com.google.appengine
-DartifactId=appengine-api-1.0-sdk -Dversion=1.9.36 -Dpackaging=zip

Sinatra Jruby Heroku - jruby: No such file or directory -- trinidad (LoadError)

I'm trying to get this application running: github.com/Soliah/sinatra-jruby-heroku.git
One update was necessary according to this release note from Heroku:
http://devcenter.heroku.com/articles/release-note-java-2011-09-29
The build goes fine, without any errors. Bellow some log parts:
[INFO] --- jruby-rake-plugin:1.6.3:jruby (install-bundler) # jruby-heroku ---
[INFO] Successfully installed bundler-1.0.21
[INFO] 1 gem installed
[INFO]
[INFO] --- jruby-rake-plugin:1.6.3:jruby (bundle-install) # jruby-heroku ---
[INFO] Fetching source index for http://rubygems.org/
[INFO] Installing jruby-rack (1.0.10)
[INFO] Installing rack (1.3.2)
[INFO] Installing tilt (1.3.3)
[INFO] Installing sinatra (1.2.6)
[INFO] Installing trinidad_jars (1.0.1)
[INFO] Installing trinidad (1.2.3)
[INFO] Using bundler (1.0.21)
[INFO] Your bundle is complete! It was installed into ./vendor/bundle
(...)
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.408s
[INFO] Finished at: Tue Jan 31 10:58:03 UTC 2012
[INFO] Final Memory: 9M/490M
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> jruby, web
-----> Compiled slug size is 18.6MB
-----> Launching... done, v5
http://jrubyandjava.herokuapp.com deployed to Heroku
But when I access the deployed application. An application error occurs.
Here is the log, with the error:
$ heroku logs
2012-01-31T10:57:21+00:00 heroku[slugc]: Slug compilation started
2012-01-31T10:58:13+00:00 heroku[web.1]: State changed from created to starting
2012-01-31T10:58:19+00:00 heroku[web.1]: Starting process with command `sh script/jruby -S trinidad -p 52233`
2012-01-31T10:58:20+00:00 app[web.1]: Classpath is: :/app/etc:/app/target/dependency/jruby-complete.jar
2012-01-31T10:58:21+00:00 app[web.1]: jruby: No such file or directory -- trinidad (LoadError)
2012-01-31T10:58:23+00:00 heroku[web.1]: State changed from starting to crashed
2012-01-31T10:58:23+00:00 heroku[web.1]: State changed from crashed to created
2012-01-31T10:58:23+00:00 heroku[web.1]: State changed from created to starting
2012-01-31T10:58:23+00:00 heroku[web.1]: Process exited
2012-01-31T10:58:28+00:00 heroku[web.1]: Starting process with command `sh script/jruby -S trinidad -p 26224`
2012-01-31T10:58:28+00:00 app[web.1]: Classpath is: :/app/etc:/app/target/dependency/jruby-complete.jar
2012-01-31T10:58:31+00:00 app[web.1]: jruby: No such file or directory -- trinidad (LoadError)
2012-01-31T10:58:32+00:00 heroku[web.1]: State changed from starting to crashed
2012-01-31T10:58:33+00:00 heroku[web.1]: Process exited
2012-01-31T10:58:33+00:00 heroku[router]: Error H10 (App crashed) -> GET jrubyandjava.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
It seems that JRuby is not finding the gems.
But I've tried all kinds of configurations (in script/jruby, heroku config:add, Procfile, etc.) and no one worked.
One more thing: this is the actual heroku config output (stack cedar).
$ heroku config
DATABASE_URL => postgres://kfgubrhars:mYBlJ2YKewqG7LwmPqVI#ec2-50-17-200-129.compute-1.amazonaws.com/kfgubrhars
JAVA_OPTS => -Xmx384m -Xss512k -XX:+UseCompressedOops
MAVEN_OPTS => -Xmx384m -Xss512k -XX:+UseCompressedOops
PATH => /usr/local/bin:/usr/bin:/bin
SHARED_DATABASE_URL => postgres://kfgubrhars:mYBlJ2YKewqG7LwmPqVI#ec2-50-17-200-129.compute-1.amazonaws.com/kfgubrhars
Here is the updated repository: https://github.com/tomasmuller/sinatra-jruby-heroku
Thank's in advance!
Ok! I found the solution. Here are the steps:
Adjust the GEM_HOME, in script/jruby to:
GEM_HOME="$APPDIR"/vendor/bundle
Created the script/bundle, with ENV['GEM_HOME'] and ENV['GEM_PATH'] pointing to 'vendor/bundle' dir.
Adjusted the executions of jruby-rake-plugin, in pom.xml:
install-bundler: <args>-S gem install bundler --no-ri --no-rdoc --install-dir vendor/bundle</args>
bundle-install: <args>script/bundle install --without development:test</args>
There's been a recent change to where the gems get installed. The launcher script/jruby expects the gems to be in .gems but it looks like that has now changed to vender/bundle.
Try changing the line https://github.com/tomasmuller/sinatra-jruby-heroku/blob/master/script/jruby#L94 to export GEM_HOME="$APPDIR"/vender/bundle instead.
I've been meaning to update my blog post with these changes but just haven't got around to it.
As of Bundler 1.2 you are now able to specify the Ruby implementation and version in your Gemfile. The nice thing about this is that Heroku will understand these settings and prepare the your Heroku application for your environment.
Take this Gemfile for example:
source "https://rubygems.org"
ruby "1.9.3"
gem "rails"
gem "puma"
What's cool about this is that by default Celadon Cedar uses Ruby 1.9.2. However, when you specify ruby "1.9.3" in the Gemfile it'll actually compile Ruby 1.9.3 for your Heroku environment.
Now, if you want to add a different Ruby implementation to your Heroku environment, you can do so like this:
source "https://rubygems.org"
ruby "1.9.3", :engine => "jruby", :engine_version => "1.7.0.preview1"
gem "rails"
gem "puma"
Now it'll install and use JRuby 1.7.0.preview1 in Ruby 1.9 mode for your Heroku application upon deployment. It'll also even define the proper JVM options in the Heroku environment variables.
Best of all is that this comes with the official Heroku buildpack, so there is no need to switch to a 3rd party buildpack to get the JRuby/JVM going on Heroku. Although I haven't gotten it to work yet, this should also work with Rubinius, but I believe it's currently bugged. Either that, or I'm doing it wrong.
This is in my opinion an awesome and scalable feature. Just define the Ruby implementation/version/mode you're using in your Gemfile along with your other dependencies and Heroku will ensure the environment is prepared.
It is no longer necessary to use a workaround or use 3rd party buildpacks using this method. It is also no longer necessary to create a hacky Jemfile. Instead, just do everything as you would normally do with MRI, keep the Gemfile, don't use 3rd party buildpacks, just define the Ruby implementation/runtime in the Gemfile via the ruby method and Heroku should take care of things.

Categories

Resources