Are Ear Files build once and Deploy on Multiple Apps server thing? - ear

Is it Possible to build a simple ear with just one "Hello World" html page to be build just once as ear file and deployed on weblogic, JBoss or any other server?
Means if Ear file is very simple which does not uses any advance services provided by specific container, is it possible this ear to be usable across different application servers?

Yes. If the ear is J2EE compliant it should be able to be deployed to any J2EE compliant platform. If proprietary functionality like Websphere Scheduler is added then that would be different.

Related

How to make my spring boot application online on my domain?

I have recently learned how to work with Spring boot. Now, I have an application which works locally without any problem. Now, I would like to know how I can make it available as a website.
I have got a free web host from here and have followed the instructions to create a war file for my project. But I don't know what I should do with this war file and how I should use it to have my web page online.
In the meantime, my code is using Atlas Mongodb in it. Is using a database problematic? Should I consider something special for that?
Thanks in advance,
Shared hosting like 000webhost do not support Spring boot Hosting. As it was said earlier to host spring boot you have two choices either you host jar or war file. War is the traditional way of hosting it which needs Apache tomcat server and Jar is the Modern way which supports cloud based solutions. To host your solution you can create an account with AWS(Amazon web services) or GCP (Google Cloud Platform) and you will get free credits to use for a while or you can use Heroku(https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku) which is pretty much easier to use, its free also. For the database if you are using (https://www.mongodb.com/cloud/atlas) then you are good. All the best
If you are using Spring Boot, which have an embedded tomcat. You can just pack your project to a jar file, put the jar file to the server, and then simply execute it on the network interface that can connect to the outside world.
If you would like to pack your project as a war file, then you should first install the environment (application server) like tomcat, glassfish, jboss, etc. After that, you can deploy the war file on the application server.
Likewise, you should install the database server on your host, and edit the spring application.properties to let your spring application connect to the database.

Deploy multiple Spring Boot modules with Maven

I have created two separate maven modules (let's call them MODULE1 and MODULE2) which are submodules of a third integration module (SUPERMODULE).
MODULE1 and MODULE2 are both Spring Boot Web Applications. What I'm trying to achieve is to start (not build) both projects / web apps by means of SUPERMODULE.
As I see it, there are two options:
Deploy them both to the same tomcat server (probably the better & more interesting solution)
Deploy them to different tomcat servers with different ports
I found no viable example to achieve either one of these options (... by means of a single maven integration project). Hence, I would be glad if someone could point me into the right direction - or are both possibilities bad practice?
You said :
Deploy them both to the same tomcat server
(1) Build automation software
Any Build Automation tool (Jenkins, bamboo...) would allow you to create a job that deploys both your wars to tomcat (the same server or different server, you can setup your job as you wish).
Do you use an automation software ? I believe that would be the best the solution / best practices.
(2) Build an EAR - Deploy to Tomee
You said:
What I'm trying to achieve is to start (not build) both projects / web
apps by means of SUPERMODULE.
What you are really describing is an EAR!
I'll describe the idea, however, it seems Spring boot does not play well with EAR: Spring Boot EAR Packaging and https://github.com/purple52/spring-boot-ear-skinny-war
Since your 2 submodules are spring boot app, you could:
build the submodules as WAR
have your Supermodule build an EAR
include both WARs in the EAR (maven dependencies)
this however implies that you use (for instance) Tomee instead of tomcat (is that an option for you?).
as mentioned above, after some research it seems a spring-boot war does not work when packaged inside an EAR. The SpringServletContainerInitializer isn't called. So this would not be an option at the moment.

How can I redeploy multiple war files into a single Spring Boot deployable jar?

Currently I'm deploying multiple war files into a Tomcat container. Is it possible to use Spring Boot to put all war files into a single deployable jar? I know this is possible for a single app, but can it be done to deploy multiple apps that once were in separate war files?
Spring Boot by design will run one app (one war) per container. If you want to go for the uber-jar deployment I suggest you stay with this since it is following also 12-factor-app best practices.
If you want to run multiple war files in one tomcat I suggest you follow the "old way" wrapping up your spring boot apps in war files and deploy them in an already set up tomcat or jetty or ...
So the answer will be: in principle – and with a lot of tweaking – you might be able to achieve what you are trying to do but this is not the intend of the jar distribution of spring boot apps. And always remember: work with the framework and not against it.
Tomcat container browses through the web apps and maps each war with the context root defined in it (single property of the web.xml). So, i do not think you can do merge the files in only one and still treat them as separate web apps.
What can be done is to actually merge the code of the web apps in only war file and split the functionality based on different paths after the context root path.

Spring MVC project as jar

I am new to Spring MVC and I have now come accross tutorials that explain how to deploy your web project as a .jar. My IDE is the Spring Tool Suite. I have always used .war + Apache Tomcat.
Can someone elaborate a bit from the practical point of view why to use .jar instead of .war? Any problems to be aware of?
edit: other answers are welcome too
Spring Boot uses fat JAR packaging where is embeds Servlet container with all dependencies into this single JAR.
If you are using Maven, it uses spring-boot-maven-plugin to package the project.
Practical usage of this approach is simple. Ability to easily run Srvlet based Spring application from command line with externalized properties. Such configuration enables powerfully orchestration possibilities which are often used in modern enterprises in so called Microservices or SOA architecture.
There is group of people out there (including myself) which believe that deploying various WAR files of unrelated applications into single Servlet runtime is not very good idea.
So fat JARs are handy for separate Servlet runtime per application deployment.
About having .jar and Tomcat + .war on the same machine, it is possible and I use this. This may be not cool but I had a .war application running in a tomcat server before the rise up of spring boot. Now my new apps are spring boot apps, and we are migrating our architecture to SOA concept, but we can't change the tire with the moving car. The main application, the WAR is running in a tomcat server and the others (.jar) are self contained ( embedded tomcat ), each one running in a different port. It was the most viable solution available for us by the moment.

Replacing/deploying only the changes in the already depolyed ear in Jboss 7

I am deploying the ear file each time when i making a changes as my project is multi-module and it is really tedious to upload/deployed the entire ear again in Jboss 7.Is there any way to replace only the changed jar/war/files in the already deployed ear in jboss without deploying the entire ear file again.
Thanks.
You should consider using JRebel - it allows reloading changes. After you compile any class it will automaticaly reload it, supporting modern frameworks (like reloading spring beans, etc) and application servers (JBoss included). It works as a java agent. You will find more details on producent site: http://zeroturnaround.com/software/jrebel/features/
To introduce JRebel in Maven project you just need to add jrebel-maven-plugin

Resources