Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-16233

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

    Details

      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...

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            cariou Christophe Cariou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                --Sprint 12/11
                6.1.0 CE RC1