Spring Boot Azure Deployment Unable to Update Code - java

I have followed step by step instruction for this document. And it works perfectly fine.
However, I tried changing the return from "Greetings from Spring Boot!" to "Greetings from Spring Boot! v2.0" and made necessary changes (on tests). And then ran mvn clean package to remove any existing jar and create a new one and finally ran ./mvnw azure-webapp:deploy it does update the existing web service. And also states "BUILD Success"
Not sure where am i going wrong.

Just as hujtomi said in the comment, every time the maven deploy task will create different web app. Could you please have a check with that?

Alright, here is the solution - pretty simple. Basically you need to change version under pom.xml i.e.
<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<version>0.1.1</version>
update version value every time you want to publish. thanks to #hujtomi however you need to do one more thing. i.e. change the value under web.config under httpPlatform
by default it will point to 0.1.0 version, but you will need to change to 0.1.1 (basically to the version that you want).
In that way, it is actually quite good, so if there are any crashes, you can simply roll back to prev. version.
-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\gs-spring-boot-0.1.0.jar"
to
-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\gs-spring-boot-0.1.1.jar"

Related

Automatically restart configuration on source code change

I've got simple application which builds into jar and starts in 2-3 seconds.
Is it possible to configure Intellij IDEA to rebuild/restart configuration on any source code change (it differs from hotswap)?
This problem should be perfectly solved by DCEVM+Hotswap-Agent technologies.Look at this project: https://github.com/HotswapProjects/HotswapAgent

Vert.x fails to "Run your module and see your changes immediately"

I am working with the Vert.x Gradle template hosted at the Vert.x Github space.
The build file suggests that there is a runModIDEA target that runs IDEA-built class files so that rebuild/redeploy is not required to pick up changes:
runModIDEA - run the module from the project resources in IDEA. This allows you to run the module without building it
first!
... yet the task does not exist per ./gradlew tasks.
I am not tied to this particular build task per se.
I just want a working auto-redeploy solution that enables me to see updates without a two minute rebuild/redeploy cycle.
EDIT: I also tried running it directly, pointing to InteliJ IDEA output classpath. It works fine, but doesn't pick up changes.
vertx runmod com.mycompany~vert-x-reverse-proxy~1.0.0-final -c conf.json -cp out/production/vert-x-reverse-proxy
EDIT: I also tried ./gradlew runmod -m, first changing vertx_classpath.txt so that the IDEA files (out/production) are looked at first. Still no redeploy. In fact, while it was running, I deleted the out directory and it continued working.
EDIT: I also tried vertx run com.mycompany.myproject.ReverseProxyVerticle -c conf.json -cp out/production/vert-x-reverse-proxy... same results. It ran as expected but did not pick up changes. Only way to pick up changes was to gradlew clean and re-assemble.
EDIT: I have been through these instructions as well.
For anyone who stumbles upon this question, I had the same problem and managed to fix it by deleting everything under the /mods folder in the /target directory. This is in fact mentioned in the vertx documentation - though maybe could be a little more emphatic. Once everything under /mods is removed, start up the application and it redeploys whenever anything is changed.
If you are new to vertx and stumble with this problem or similar, it might be worth to have a look at this vertx google group entry. It describes the changes that need to be done to the generated project by the Vertx Gradle Template to get it running.
I know, this does not answer directly the question posted here but I hope it helps you further.

How do I run a DropWizard / Jersey server locally without having to restart & repack to get asset file updates?

I'm working on the client side of a project that is using DropWizard. Unfortunately what I'm experiencing is that for me to make a change to assets I have to stop the server, package the assets with maven, and then rerun the server or the assets will not be updated.
I tried adding dropwizard-configurable-assets-bundle but I'm still seeing the same behavior. Here's the service after adding it:
Service.java
public void initialize(strap<ServiceConfiguration> strap) {
// Assets
strap.addBundle(new ConfiguredAssetsBundle(
"/dashboard/app/", "/dashboard/", "index.html"
));
// Redirect /dashboard to /dashboard/
strap.addBundle(new RedirectBundle(ImmutableMap.<String, String>builder()
.put("/dashboard", "/dashboard/").build()));
}
I'm currently running mvn package && java -jar target/pack.jar server config.yml. I tried using Eclipse but I was having to restart it manually and it wasn't repackaging for me so it was slowing things down even further.
This whole process is reaaaally slowing me down and I'm hoping it's just my ignorance to the world that is Java.
In my Intellij Idea, i am using JRebel plug-in for this purpose. JRebel also supports Eclipse.
If your assets are packaged under src/main/resources then they should just update automatically with Eclipse without a restart being required, so long as you're running the executable service main() from within the IDE.
You may need to check that your Maven plugin is set to "generate-resources" on changes but that is just the default setting so should be in place already.
What you're describing is definitely possible in Eclipse - I have personal experience of making resource changes (e.g. change and save an HTML asset) and then seeing an immediate update upon doing nothing more than a browser refresh.

Maven + Tomcat + Eclipse Java hotswap

I have a problem. I start Tomcat in JPDA mode, and after that I execute:
mvn tomcat:stop tomcat:undeploy war:inplace tomcat:inplace
After which I connect to remote Java app from Eclipse. All works ok, I'm able to change some code and hot swap works.
When I add method/change parameters I redeploy the app:
mvn tomcat:stop tomcat:undeploy war:inplace tomcat:inplace
After which when I reconnect to the remote java app again, only now when I change any file (for example, placing a space or removing space, save) I get an error that code cannot been swapped out - "Hot Code Replace Failed - add method not implemented".
What is the problem?
Thanks.
JVM only supports hot swap for changes to the method body. For other changes, like changing the parameters or adding new methods, consider choosing JRebel which supports these.
The Spring Loaded JVM agent should work better. For one, it has the new parameters and methods feature that is lacking with current JVM hot code replace. I recently got this setup and verified that new methods in existing classes work as expected.

Setting fork and spawn in a maven plugin

We're converting a buildfile from ant to a maven plugin. We're trying to start/stop a database (hsqldb) in a maven plugin.
We succeeded to start the database. But we think that the plugin stops the database when the plugin is executed. The database should keep on running after the execution, but it seems to stop right away.
Our guess is that we should use the 'fork' and 'spawn' attributes (they are also in our build.xml from ant), but we don't have an idea how to implement them in our java class from our DatabaseController (which extends from AbstractMojo).
Any ideas?
We're using hsqldb, thisis the code how we initialize it:
hsqlServer = new Server();
hsqlServer.setLogWriter(null);
hsqlServer.setSilent(true);
hsqlServer.setDatabaseName(0, "database");
hsqlServer.setDatabasePath(0, "file:data/database");
getLog().info("Starting server!");
hsqlServer.start();
When we run the plugin, the database starts, we even managed to create tables and write data to it. Then the plugin stops, and the server stops automatically with it.
If we run another plugin, one to stop the server, we always get a nullPointerException at this line:
hsqlServer.stop();
Kind regards,
Jeroen
One thing you can do is, looking at existing maven plugins that does the forking of new java processes. Maven-surefire-plugin for one, do something similar. Surefire has a configuration (which will be specified in the pom.xml) called forkMode, which controlls the forking.
You may have to go through the source (svn checkout the code) of the plugin to figure it out.
I'm not much familiar with surefire much. But as a start, you may read the following class (#fork( Object testSet, Properties...)!
./maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
Any code executed in maven is forked in another process. I worked with processes in some projects realm, it doesn't have a clear documentation about that.
You could call your code something like that:
Thread.currentThread().setDaemon(true);
hsqlServer = new Server();
hsqlServer.setLogWriter(null);
hsqlServer.setSilent(true);
hsqlServer.setDatabaseName(0, "database");
hsqlServer.setDatabasePath(0, "file:data/database");
getLog().info("Starting server!");
hsqlServer.start();
With an daemon thread, maven could thing witch your code is to be runned in background.
It´s supposition, but you could try it.

Categories