setting development environment of Heroku template java application - java

I have installed Heroku java plug-in and trying to set example application i.e. "Web & Asynchronous worker with Spring, CloudAMQP". This project is following maven and application gets deployed on heroku thru maven.
Would it be possible to run same application using local java container, rabbitmq and worker running in same and/or different JVM?

Yes, Foreman will start any project that has a Procfile. If there are multiple processes defined it will start them all.
https://devcenter.heroku.com/articles/procfile#developing-locally-with-foreman
You'll have to build the project locally with Maven first. You can either set the config info for your rabbitmq instance into environment variable or save them in a .env file which foreman will pick up. You can look at your Heroku app with 'heroku config' to see the variables that the app is expecting.

Related

grails 4.x: Creating a WAR with a custom env always runs under development

I can't get my custom environment to run under Tomcat. It always loads the development profile.
I create a WAR with the following under Grails 4.0.5:
grails -Dgrails.env=qa war
The resulting grails.build.info looks correct:
info.app.version=2.0.7
info.app.name=myapp
grails.env=qa
info.app.grailsVersion=4.0.5
However, when I drop it into Tomcat 8 and run, I get this:
[ost-startStop-1] com.myapp.ApplicationLoader : The following profiles are active: development
Running standalone, though, works just fine:
./gradlew -Dgrails.env=qa bootRun
grails.util.Environment, defines a number of pre-configured environments.
Environment APPLICATION
Environment CUSTOM
Environment DEVELOPMENT
Environment PRODUCTION
Environment TEST
In application.yml we get pre-configured development, test, and production environments. So if we want to add custom environments we add similarly. In your case it will be qa.
With Grails command line we can execute any command within the context of a specific environment. The format is:
grails [environment] [command name]
Suppose if want to create a WAR for the test environment you wound run:
grails test war
To target other environments you can pass a grails.env variable to any command:
grails -Dgrails.env=UAT run-app
I create a WAR with the following under Grails 4.0.5:
grails -Dgrails.env=qa war
Yes, all looks good as per grails documentation and configuration.
I have Created POC app for same with Grails 4.0.5 and also downloaded external tomcat apache-tomcat-8.5.63.
My application.yml with qa ENV:
Running standalone, though, works just fine:
./gradlew -Dgrails.env=qa bootRun
Yes. This also works fine.
So, now i have created war file with grails -Dgrails.env=qa war
Then i started my tomcat and dropped my poc-app-0.1.war file into tomcat.
when tomcat deployed/extracted my war, entered local url into browser.
You can see in above image, Environment is qa
So everything is running as i passed to env while creating war.
I tested with multiple environments, both pre-configured and custom environments. But did not got any issue like created war for qa and running on dev.
Also i have tested with java -jar poc-app-0.1.war and it's running on same env as we given.
Application details:
and tomcat version is apache-tomcat-8.5.63
It may be some versions or configuration issue with your app.
Please refer this link of my poc. Can you please try to create war and deploy in same way to your tomcat and let me know.
If you are still getting issue, then please share your minimal code or poc.
Even i got one more similar kind of issue on grails repo, please do refer this.
I have followed lot of documentation and references but still not able to reproduce your issue.
Links:
Environment class
Upgrade Doc
Command Line
API Doc
Conf Doc

jni4net on Docker Ubuntu Host

I have a application developed in Java 8 with SpringBoot, that use jni4net for consuming a dll library.
It's posibble make a docker container in Ubuntu to run this application ?
Thanks
Spring Boot with Docker
This guide walks you through the process of building a Docker image for running a Spring Boot application.
What you’ll build
Docker is a Linux container management toolkit with a "social" aspect, allowing users to publish container images and consume those published by others. A Docker image is a recipe for running a containerized process, and in this guide we will build one for a simple Spring boot application.
What you’ll need
About 15 minutes
A favorite text editor or IDE
JDK 1.8 or later
Gradle 2.3+ or Maven 3.0+
You can also import the code straight into your IDE:
Spring Tool Suite (STS)
IntelliJ IDEA
If you are NOT using a Linux machine, you will need a virtualized server. By installing VirtualBox, other tools like the Mac’s boot2docker, can seamlessly manage it for you. Visit VirtualBox’s download site and pick the version for your machine. Download and install. Don’t worry about actually running it.
You will also need Docker, which only runs on 64-bit machines. See https://docs.docker.com/installation/#installation for details on setting Docker up for your machine. Before proceeding further, verify you can run docker commands from the shell. If you are using boot2docker you need to run that first.

hotdeploy / hotswap classes using wildfly maven docker intellij

I have a current setup of intellij 2016 which compiles my java files on the fly. Due to some configuration in intellij it is possible to propagate any changes directly to tomcat. This way I don't have to manually build a new application and deploy it to tomcat which increases user productivity.
We want to remove tomcat and start using wildfly10 but also keep the hotdeploy functionality. On top of that the wildfly server will be hosted in a docker container.
So what I did is that I mounted the wildfly/standalone/deployment/myapp.war using docker to my host directory myapp/target/myapp.war. In addition I configured a jboss remote server configuration with remote stating set to same file system and let maven build an exploded war. This way if a maven build is performed, the contents of the target/myapp.war directory is directly available in my docker container. When I run the container and perform a new maven package, I do see that wildfly states that the new changes are found and redeploying has succeeded. Unfortunately this only goes well once or two times in a row.
So coming from the tomcat hotdeploy where no maven build was involved and any changes where directly available in tomcat, I'm wondering if the same can be achieved with the setup: intellij, maven, wildfly and docker. So if a change of a java file in intellij is compiled and pushed to wildfly without redeploying or maven build?
Wild-fly - eclipse supports 100 % Hot Code replacement
you have to start web-app in debugging mode .
For every change in java code just do a maven install and refresh
the target .
Limitations :
you can only replace statements in method .
you are not allowed to change whole class and new methods .

Deploying/Running jvm application on a remote-host from Intellij

Would it be possible to deploy/run (for testing purposes) a standalone Java application on a remote server from intellij? I'm not trying to connect to an already running JVM, but to start a new JVM on the remote host from intellij just like it was running on my local machine?
There is no built-in support for it at the moment. You can deploy an application to an application server running on a remote machine, but if you have a standalone application, there is no built-in feature to deploy it.
That said, you can write an Ant script or a shell script to deploy your app, and use either the Ant integration or the external tool feature to run it from with in IntelliJ IDEA.

Continuous deployment/integration on Heroku for Java web app

I have a Java web application that I have managed to successfully deploy and get running on Heroku using the 'git push heroku master' method, but I would like to automate deployment and have a full CI setup. I've had a go at using Atlassian Bamboo with the Heroku plugin but it's really only suitable for standalone .war files - I need to be able to specify additional config via the Procfile definition in my project.
What have other people used for CI/CD of Java web applications to Heroku?
Jenkins has a good Heroku Plugin, that allow you to deploy WARs and interact with Heroku in many ways, including setting variables, scaling your dynos and running one-off processes:
https://github.com/heroku/heroku-jenkins-plugin/blob/master/README.md
To change the Procfile on Heroku, you need to commit and push the new file. You can do that as a step on your CI build. Jenkins can run scripts as part of your build, where you could easily push a new Procfile if that is needed.

Categories

Resources