3

Micro services components/services are suites of independently deployable services which provides its services through HTTP request.

If I talk in terms of java/j2ee, http requests are always handled through servlet. And to deploy the servlet on web/app container, archive packaging has to be war file. So my understanding is archive can not be jar file, it has to be war file. Is that correct ?

Update:-

Its not duplicate of Java war vs. jar - what is the difference? at all. I understand the diff b/w jar vs war that is clear in my post too but this question is asked in context of microservices i.e. whether microservices can deployed as jar also . Please open it for answers.

user3198603
  • 5,528
  • 13
  • 65
  • 125
  • Possible duplicate of [Java war vs. jar - what is the difference?](https://stackoverflow.com/questions/5871053/java-war-vs-jar-what-is-the-difference) – Roshana Pitigala Sep 09 '18 at 14:52
  • @RoshanaPitigala Its not duplicate. I understand the diff b/w jar vs war but this question is asked in context of microservices. – user3198603 Sep 09 '18 at 14:54
  • Servlets are not the only way to handle HTTP requests. Plenty of frameworks allow embedding an HTTP server in an application. Even servlet containers can be embedded. That's what Spring Boot does by default for example. – JB Nizet Sep 09 '18 at 15:01
  • @JBNizet I agree that servlet containers/HTTP server can be embedded like in spring boot. Per my understanding spring boot(jar) internally makes the web server up and must be deploying the war file on it internally . So even in those cases internally, servlet will handle the request internally.Is n't it ? Consider the second case where I already have web server with me(do not want to use the embedded one) and I need to deploy micro services on it. In that case also , micro services has to be war file not jar file. Right ? – user3198603 Sep 09 '18 at 15:11
  • Yes, Java EE webapps are deployed as war files. – JB Nizet Sep 09 '18 at 15:13
  • so micro services and restful webservices are also kind of Java EE webapps which needs to be deployed as war files. Correct ? Its a different thing whether we do it manually or framework like spring boot internally does it . – user3198603 Sep 09 '18 at 15:17
  • 1
    No. Restful web services are services that provide restful services over the web. They can be implemented using whatever you want. Micro-services are a buzzword which refer to an architecture where complex applications are splitted between small services communicating between each other over the network. They can be implemented using whatever you like. Java EE is a set of Java specifications, one of which defining servlets and war files. And yes, servlets deployed as war files can be the basis for restful web services, and you might choose to use that to create a micro-service. – JB Nizet Sep 09 '18 at 16:03
  • @user3198603 you can also use PHP, JavaScript and many other languages for mucroservices – Constantin Galbenu Sep 10 '18 at 05:21
  • @user3198603 also, you can use docker to deploy it; then all you have to do is to write code and execute `docker build` – Constantin Galbenu Sep 10 '18 at 05:24
  • @JB Nizet I start getting your point. Basically both micro services and restful web sevices can either be jar or war. Bottom line is they should be able to provide services over http. Servlet is one os the most common way. In that case it has to be war file. Another way can be jar file (like in spring boot where request can be handled by servlet or some other method which can understand http and parse request over rocket. – user3198603 Sep 10 '18 at 09:15

0 Answers0