28

A Java EE 7 application server, and specifically a Servlet 3.1 container should allow us to deploy a WAR file that contains a web application. And a WAR file is essentially a JAR with deployment descriptor (web.xml) and couple of other elements.

On the other hand, Java 9 introduces a notion of modular JAR file, that is, a JAR with module descriptor (module-info.class) which makes a module in terms of project Jigsaw.

So, can a WAR file contain a module descriptor as well and make a "modular WAR file"?

Are there already application servers capable of accepting deployment of a "modular WAR file"?

Generally what is the future of servlet containers and WAR files in terms of Java 9 modularity ?

malloc4k
  • 1,742
  • 3
  • 22
  • 22

2 Answers2

18

Currently there are no links between Java EE and java 9(jigsaw) modules. Future Java EE releases might introduce spec defined behavior on how to interact with jigsaw modules.

At this point all app servers run in "classpath mode" when running on JDK9 which in practice mean they do not utilize jigsaw.

In most cases introducing module-info to your war deployment can only cause deployment issues as JDK might try to load it in different way than other parts of the app server. Or it could not even make a difference as most app servers have custom logic for loading jars & classes.

Some application servers out there today already implement some kind of modularity such as OSGi(GlassFish, Liberty) or jboss-modules (Wildfly) But at this time jigsaw still has some limitations to be able to run such modular systems on top of it.

So in short, until there is EE spec (probably 9+) that is updated to describe how EE deployments should run on jigsaw enabled runtime there is no "official" way on how such deployment should behave. Until such time, each app server can implement some custom support for it but it wont be standard.

Tomaz Cerar
  • 5,761
  • 25
  • 32
3

So, can a WAR file contain a module descriptor as well and make a "modular WAR file"

Yes, it can. Since it could now essentially be Modular JAR file with deployment descriptors like web.xml.


Generally what is the future of servlet containers and WAR files in terms of Java 9 modularity ?

From the Dynamic configuration aspect of the module system,

For the Java EE Platform, in particular, the goal is to enable a future modular war-file standard in which the components in a war file can be developer modules.


Are there already application servers capable of accepting deployment of a "modular WAR file"?

Though I am currently unaware of any such existing tool or servers, yet a capability to create Modular Jar is already added to JMOD and JAR tools which provide a futuristic view of the integration of application servers and module system.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • 2
    At this time no app server can run modular deployments yet. The dynamic configuration part of jigsaw is there to be able to allow such things for app servers, but it is severely limited in what it can support; which is also a reason why app servers are not there yet with their support. – Tomaz Cerar Oct 24 '17 at 09:44
  • @ctomc Thanks. Good to learn [that](https://stackoverflow.com/a/46907106/1746118). – Naman Oct 24 '17 at 09:47