Do JSR-286 portlets require a web.xml file in their WAR files?

Does the JSR 286 specification require a web.xml in WARs containing portlets? I thought so at first, but then I created a portlet without web.xml , deployed it to Liferay, and worked flawlessly. So is it an extension (or error) of Liferay, or is there no need to have such a file?

+1
source share
2 answers

As Olaf correctly said, a portlet is nothing more than a web application. Liferay has a listener that starts when the portlet is deployed. It explodes the war and adds web.xml and the necessary content. You can check the logic if you have a source. The class name is PortletDeployer and the method is getServletContent. After adding web.xml and filling it in, they simply touch it with FileUtil.touch.

+1
source

I really need to understand the specifications, but my assumption is that it conforms to the servlet specification in this regard: the portlet application is first deployed to the application server. If web.xml is required for the servlet specification, this requirement must be met. Otherwise, the application server will not deploy WAR (this is more or less a question if the WAR file format is required or recommends web.xml

Liferay will only hit as soon as Apperver deploys the web application. Liferay alone doesn't care about web.xml

Based on this statement (and not looking at the specification, so I give a reasonable assumption here), I expect JSR 286 will not make an expression about web.xml. However, it probably refers to the servlet specification, and this, in turn, may require / recommend / mention web.xml.

And if this requires application administrators or how they behave, if it is missing, this is another story.

+1
source

Source: https://habr.com/ru/post/906987/


All Articles