How to automatically upgrade a Java application during its startup? - java

I have a Java 1.6 application deployed on several machines (~ 30), and started as a Windows service.
My main problem concerns the maintenance of these deployed artifacts: if I develop a new version of this application, I don't want to manually redeploy it on every machine.
Ideally, when the Windows service is starting, it checks on a remote server if an update exists, and if it is found, then it upgrades the application.
Note that it is acceptable that after this upgrade the service requires to be restarted again.
This mechanism can be compared to the Maven snapshot verification: if there is a newer version of a SNAPSHOT version on a remote repository, then Maven download it before running it.
Note that the application itself will be deployed on a Maven repository (in our case Nexus), so the check for an update will be done against this Nexus instance.
What are my technical solutions to implement such an automatically application update?
Do not hesitate to ask me more details about technical information or about the context...
Thanks.
Edit: As stated by Peter Lawrey, I can use Java Web Start. However, how can I integrate JWS within a Java application that is run as a Windows service?

I would look at Java Web Start

A common technique for this is to use a launcher. The steps are something like this:
Start the launcher.
The launcher checks to see if the application should be updated. If yes, the launcher updates the application (I think of this as "the update step").
After the update step, the launcher runs the application.

Related

Transferring java application to server

I have created a java application in intellij ide. The application is working well. Now that my application is ready I want to transfer my java application from my machine to server and make it live. I have one server, domain and all the basic rights in the server. Can any one help me figuring out?
I am very new in this part. I dont know anything about hosting my own website and application.
The answer depends on what technology you use. If you use application that needs to be deploy into servlet container you can deploy it onto e.g. Tomcat.
Whatever technology you use you definiately should build your application - it also depends on what building system you use.
E.g.fFor gradle, you can use gradlew build.
For maven: mvn compile.
Tell us more details about technology you use to allow us to help you.
You have a java application (Dropwizard) and first need a server to run it on, which means that it must be a server with java installed or where you can install it yourself.
Then you need to transfer the application "fat" jar (typically you find this in the target directory, depending on how you built it) to this server and start it with java -jar my-application.jar.
Then you need to make sure that the port that the application runs on is available externally. This usually means that you need to have a web server installed (commonly nginx or httpd) which redirects from port 80 or 443 to the port of your application.
Only then is you app "live".

Building production environment for Java Server Faces application on server

I am about to start working on a JSF application and I am trying to decide on how to set up my production environment.
I enjoy working off my VPS for production instead of my local host. Is there a way to launch a JSF app to my server and then build on it from there? Or is that not going to work because I have to have a compiler to compile the java each time I update?
If that is the case would it make sense to just install a compiler to the server?
This is my first JSF and real java application so if there is some good info on this please lead me there.
I have someone working with me and I was assuming if we both work of the server it would be easiest.
How would this work in a professional environment, or in other words how would a team working for a company set their environment up?
How it generally works is that each team member has a local installation, and deployments up the chain to servers are handled by the systems admin guys on requests, them being provided with an installation package containing the compiled application (a WAR or EAR file), any other files needed, and quite likely a script with database changes, an installation manual, and things like that.
You should never develop directly on a production server. Only deploy stuff there once it's complete, tested, and verified to be in working order, and secured against attacks.

How to use Eclipse for Spring REST development with Brackets like editor for JavaScript/front end development?

We have two separate web projects for our application
One for Spring REST services
Other for AngularJS, the front end of the application.
We have been using eclipse for development of both and also for running those locally on tomcat server.
It is a great deal of pain to view updates to JavaScript and CSS part of the second project from eclipse, because it requires restart or publish of the tomcat server every time which takes a long time.
So I wanted to use eclipse for development of REST and front-end development editor like Brackets for development of AngularJS/JavaScript and CSS. But then they run on different ports causing Cross Site requests errors, and I don't want to write any CORS filter like this for this purpose.
Is there any better way to get these tools work together ?
Spring Tool Suite (STS) uses the pivotal tc server will automatically deploy resources without redeploying the application. Download it and give it a go, STS is just eclipse anyway with different branding. Maybe you can just download it, copy the pivotal server folder to your eclipse folder and add it to your servers view in your eclipse version. One thing I have noticed is that the application must be running under a context for this to work, deploying to root does not automatically deploy resources for some reason (at least this was the case when I was using the previous vfabric server about a year ago).

Most efficient way to develop using WAR files?

So I'm really new to the Java webstack world, and had a question on the most efficient solution to my problem. Some background information first; I'm running Tomcat on a Lubuntu 14.04 server listening on Port 80, developing on a separate Windows computer in Spring Tool Suite (developing Spring applications obviously). Currently, whenever I want to test something, I...
1) Export the project as a WAR file from Spring Tool Suite
2) Undeploy the old WAR file from the server from the Tomcat manager webapp
3) Deploy the new WAR file that I just got from Spring Tool Suite (which takes ~15 seconds)
Is there any faster way to do this? Normally, I wouldn't be opposed to just developing on localhost. However, I'm going to be doing a group project, so we would all need access to the same SQL server, which would be the one hosted on the Lubuntu 14.04 server.
How can I solve this issue?
Most IDEs have the ability to deploy to server for both development and production purposes.
Those that don't have this ability inbuilt, ususally have a add-on that enables this.
You can also use build tools such as maven or gradle to undertake these actions.
Since you raised a good point of working with others it is important that all are across the deployment process and that the process is standardised to ensure no weird issues/bugs pop up.

Run Java EE app on EC2

Can anyone point me to the steps/resources that describe:
How to deploy a Java EE app on amazon-EC2
Maintain changes to the meta-data of the app server (deploy new applications) after an instance reboot (probably using amazon-ebs)
First check this out if you haven't already ran through it:
http://docs.aws.amazon.com/gettingstarted/latest/awsgsg-intro/intro.html
it'll give you an idea of how it all works.
With regard to running a Java EE app on EC2, you have a couple of choices - but they generally come down to the following recipe:
Start an instance
Install a Java EE application server (tomcat/glassfish/websphere/...)
Install your application (war/ear) into the application server
Now you can bundle the above into an ebs ami, or you can write a script (bash/sh/tcl) which applies those changes when your instance starts (which i prefer). The scripts allow you to modify what gets installed/started/moved around without having to rebundle your instance.
There's some great resources here: http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=100
Hope that helps.
How to deploy a Java EE app on amazon-EC2
You still deploy to an application server so it isn't really different. If you have more specific questions, please clarify. But have a look at Running JEE applications on Amazon EC2 and How to deploy a java web application on an ec2 instance.
Maintain changes to the meta-data of the app server (deploy new applications) after an instance reboot (probably using amazon-ebs)
If you use Amazon EBS, then you don't need to worry, Amazon EBS volumes are off-instance storage that persists independently from the life of an instance.
The Amazon AWS's newly Launched Elastic BeanStalk is here to resolve you concerns.
You can deploy Java EE apps on Amazon Ec2 instances via Bean Stalk. All you need to do is create a new applications and create a environment in it and add you WAR file for deploying, AWS has its own version of Tomcat 6/7 with open JDK which can be customized to Sun JDK if required.
Therefore Amazon offers complete Deployment tool to start using your app by just deploying in BeanStalk. BeanStalk offer Auto Scaling & Elastic Load balancing and a lots more to customize your application Environment.
If you start an ebs-booted instance, you do not need to care about persistency after a reboot (see http://aws.amazon.com/about-aws/whats-new/2009/12/03/amazon-ec2-instances-now-can-boot-from-amazon-ebs/)
Concerning the deployment of Java EE, I don't see any difference to deploying it on a non-virtual OS.
Boxfuse supports deploying Java EE applications using either Tomcat, TomEE Web Profile or TomEE Plus to AWS with a single command
boxfuse run mytomeeapp-1.0.war -env=prod
This will create an image, provision all necessary AWS infrastructure and launch the instances. It supports blue/green zero downtime updates with Elastic IPs and ELBs.
You can find a tutorial here: https://boxfuse.com/blog/javaee-aws.html
You don't have to worry about maintaining changes to the meta-data as all instances are immutable and contain all necessary app server info.
Disclaimer: I am the founder and CEO of Boxfuse

Categories