WebXMLBuilder does'nt work with empty web-app tag (without explicit closing tag)

Description

I use LIDE 1.2 in order to build an ext plugin.

All is perfect inside LIDE, with an attached LP6.0.5 bundle : my ext is deployed and run as expected.

Now, I'm trying do build my ext for a deployment on a production server.
I've launch the ant "deploy" task from Eclipse, that generate me a war for my ext.
Next I've pasted this war on the deploy dir of my running server.
The deployment start, the war is copied end expanded in /webapps and BOUM : I've this error :
------------------------------------------------- 09:16:52,796 INFO [ExtHotDeployListener:137] Registering extension environment for my-ext
java.lang.StringIndexOutOfBoundsException: String index out of range: -321
at java.lang.String.substring(String.java:1937)
at com.liferay.portal.tools.WebXMLBuilder.<init>(WebXMLBuilder.java:96)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:44)
....
----------­---------------------------------------
And of course, my ext isn't deployed (the ROOT app has no changes).

I reproduced it on a fresh new install of a Liferay bundle (6.0.5 or 6.0.6).

Why does it work well inside LIDE and not outside ? Does LIDE do "something" more than just paste the war inside a deploy dir ?

=> ANSWER :

The error was coming from the web.xml parsing by WebXMLBuilder. The method look for "<web-app" tag and "/web-app>". BUT, by default the web.xml file in an ext plugin created from IDE contains a <web-app ..../> tag ! So the parsing failed and the deployment goes down...

------Code from WebXMLBuilder.WebXMLBuilder() method--------- String customContent = FileUtil.read(customWebXML);

int x = customContent.indexOf("<web-app");

x = customContent.indexOf(">", x) + 1;

int y = customContent.indexOf("</web-app>");

customContent = customContent.substring(x, y);

String originalContent = FileUtil.read(originalWebXML);

int z = originalContent.indexOf("<web-app");

z = originalContent.indexOf(">", z) + 1;

String mergedContent =
originalContent.substring(0, z) + customContent +
originalContent.substring(z, originalContent.length());

mergedContent = organizeWebXML(mergedContent);

FileUtil.write(mergedWebXML, mergedContent, true);
--------------
The problem should be the same from the direct-deploy ant script, but it doesn't revert the whole deployment process as from the hotdeploy listener.

The above code should be corrected in order to take care of this case...

Environment

LP 6.0.5 GA / 6.0.6 GA

Activity

Show:

Juan Fernández April 25, 2011 at 2:25 AM

Closing this issue. The work will be done in https://liferay.atlassian.net/browse/IDE-331#icft=IDE-331
Thanks for the feedback, Christophe

Christophe Cariou March 31, 2011 at 6:23 AM

Not Aligned with the Roadmap
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Priority

Zendesk Support

Created March 31, 2011 at 6:15 AM
Updated June 26, 2023 at 2:50 PM
Resolved February 8, 2023 at 2:49 AM