AWS ec2 instance java EE web app deployment - java

This would be a opinion based question. I would like to know the community opinion on the following.
I have a JAVA EE web application, which is using ANT as build tool. Now I have to deploy this application to multiple ec2 instances. What would be the best and most efficient way to do this.
I am using chef to fire up the instances and then installing custom jboss from a private repository.

chef is generally used for setting up of infrastructure, and deployment activities should'nt be managed by that.
i prefer writing the scripts which actually does the deployment activities to the range of servers, or if having a CI for code, use CI for deployment as well.

Related

DataSource Deployment Tool

Reading this tutorial on DataSource the text keeps saying thins like:
The system administrator would typically use a deployment tool, so the
code fragments shown in this section are the code that a deployment
tool would execute.
I have no idea on the deployment tools available, could anyone point me out the top options?
I am using Tomcat for my web application.
When a web-app has to run in the J2EE environment, it typically is done using a server like Tomcat (as you are right now doing in your application).
Now, apart from just placing files in a directory, a web-app requires a number of other steps to be done, before you can access all the intended functionality. For more on what deployment is and how to assemble your files, refer here
That said, J2EE evolution and the emergence of many web-servers has over the years resulted in simplifying the deployment using batch files for example or APIs. These are what your article is referring as deployment tools. For Tomcat specifically, the detail can be found here
Hope this helps you with the bigger picture of J2EE application management
I think the author is talking about java deployment tools. Below are the few deployment tools I'm aware of,
jenkins
go
bamboo
These java deployment tools typically need configuration/orchestration tools to streamline the configuring and maintaining applications and the hosts. Below are some tools which does this :
ansible
Chef
For dependency, build and project management, maven and gradle are widely used.
To generate config files for different environments,xslt transformation language can also be used.
I might have missed many deployment tools, but these are more popular in java realm.
With the help of these tools, a system administrator can manage the deployments without having any working knowledge of programming languages.
Hope this helps!

Spring Boot Application deployment on remote server

I have a Java Spring Boot Application, and I build it with Maven. With
spring-boot-maven-plugin,
I can create fat, executable jar file.
Then I copy it to the remote server and run. But sometimes,
I change only one line or event one word in my code and I had to do whole build/copy step again. I'm sure that I'm doing it wrong, but I couldn't find another way that more efficient (Like capistrano in Rails).
At this point, I'm planning to clone source code to server, push from local, pull from remote, build and run approach. What is the correct (or elegant) way of doing this deployment?
For automatic build and deployment process (continuous integration), you can use Jenkins. Refer this documentation for more details: https://jenkins.io/doc/
I would say it depends where are you trying to do it.
The best and the most agile way to do it for a controlled environment is surely a CI-CD (Continuous Integration and Continuous Deployment) pipelines, which complies-builds-tests-deploys your code against every commit made to the source code BUT it may be too slow to use CI-CD for a development environment where you had like to have a shorter feedback cycle and faster feedback to see how the code is progressing.
However, if you are talking about development environment, I will hit another chord and ask you why to deploy to the external server AT ALL while developing. When you use Spring Boot, which helps you develop a self-contained application, you get the Tomcat Server embedded with it for free. That gives you the choice to run the code anywhere you develop and test to move forward.
A simple maven goal - mvn spring-boot:run can make the code run anywhere you had like.
There is another magical library available in Spring-Boot, known as Devtools, which is meant to support agile developers. The library once in the app classpath, performs hot-swapping of byte-code to auto reload of code into the running application (running locally with embedded Tomcat) as soon there is a saved change. This is one of the coolest gadget that a developer can have.
Use of Spring-Loaded (or JRebel for non spring-boot apps) libraries can also help a developer do hot-swapping of byte code to load changes in running application as soon saved.
I hope it helps.

Java - how are Akka, Play, Vertx etc. applications deployed?

I've been reading about some of the (relatively) new application frameworks for Java such as Akka, Play and Vertx. I can't find a clear answer however on whether or not applications created with these frameworks are deployed like traditional EE applications? That is, are they packaged as WAR/EAR files and deployed to an application server like WebSphere? I my mind, a lot of the WAR/EAR infrastructure was built with traditional EE apps in mind.
In there default they are not deployed like normal EE Applications. These Frameworks try to simplify things and make writing code faster and easier and so they most of the time have there own deployment mode and bring there own web server. Also they follow more the Docker approach of having fat jars and be able to be used as micro service.
So from my point of view it looks like this (could be wrong I did not use them):
Akka its possible to add to an WEB-INF/lib in an war file
Play native installer is recommended. They dropped the war possibility but there seems to be an github plugin
vert.x seems no support for ear or war files

Implications of building a java program against the jars of one web container and deploying it in another

What are the implications of building a java program against the jars of one web container (say Jetty) and running it in another (say Tomcat)?
I have an application which I run in Jetty durring development but which is deployed into a tomcat server for production (Why? because it seems easier to develop without having to run a whole tomcat server.)
You should compile against only the official Java EE API's for the level you target, for any non-developer builds. Preferably by a build engine. Preferably on a different operating system than you develop on.
For a web application this mean the appropriate servlet API as downloaded from Oracle. Similar for an enterprise application.
In my experience this is the best way to keep it straight.
Edit: Java EE SDK is available from http://www.oracle.com/technetwork/java/javaee/downloads/index.html. If you need an older version than Java EE 6, then follow the "Previous Releases" link.
You can get issues such as MethodNotFoundError. You can usually resolve these by making sure versions of jars installed on the servers match.
you typically want to develop where you deploy. It might be slightly harder to develop with tomcat vs jetty, but you have identified a potential mess of a problem with jar conflicts, so doesn't it seem worth it to develop with tomcat, since you deploy to tomcat?
Also, typically the pain of developing against tomcat/your container of choice is mitigated by putting in the time to write a ant (or other) task that will deploy your code to your development container. The work cycle bemoes
1) Write new code
2) make sure tests pass
3) run your 'redeploy' script
4) poke around in the running instance
You probably want to do that.
Finally, in the spirit of loose coupling, you probably do not want to depend on a container-specific libraries if you can avoid it; only do that as an absolute last resort.

Automatic VM deployment

I have an idea to streamline deployments of prototypes within our team using VMs. The idea would be that a developer would be able to deploy their artifacts to Maven, then use a Web interface to pull them onto a development VM for integration/regression testing. They would then be able to to push those artifacts to a reference system, and finally onto production.
I'm currently thinking of doing this myself using the vSphere Java API ( http://vijava.sourceforge.net/ ), and some simple scripting to grab artifacts from the Maven repository, configuration from SVN, and then start up a JBoss server. It feels like the kind of thing that may already be available though, has anyone heard of something similar?
Isn't it the thing that Continuous Integration is made for? We have done similar stuffs by using JetBrains TeamCity and Jira Bamboo.

Categories