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

"Illegal char <:> at index 2: /C:/path..." error if you run Paths.get(PortalUtil.getGlobalLibDir()) java code in Windows

    Details

      Description

      "Illegal char <:> at index 2: /C:/path..." error if you run Paths.get(PortalUtil.getGlobalLibDir()) java code in Windows

      This can be reproduced if you activate Elasticsearch Sidecar in Windows (see LPS-103577).
      An "Illegal char <:> at index 2: /C:/path..." error is produced in this line of Sidecar.java

      • String bootstrapClasspath = _createClasspath(
        	Paths.get(_props.get(PropsKeys.LIFERAY_LIB_GLOBAL_DIR)),
        

      Root cause
      In Windows, for some environment variables, Liferay stores wrong paths that start with "/C:/...".
      I have detected the issue in following environment variables:

      • liferay.lib.global.dir: /C:/Liferay/Bundles_Builds/portal-master/tomcat-9.0.33/lib/ext/
      • liferay.lib.global.shared.dir: /C:/Liferay/Bundles_Builds/portal-master/tomcat-9.0.33/lib/

      These paths are not valid so Paths.get(...) call fails.
      Note: for legacy reasons File class considers them a valid path and that class with handle them correctly, see:

      Steps to reproduce using groovy script

      1. Start Liferay in a Windows machine.
      2. Go to "Control panel" => "Configuration" => "Server Administration" => "Script" tab
      3. Execute following groovy script:
        import com.liferay.portal.kernel.util.PortalUtil;
        import java.nio.file.Paths;
        out.println(Paths.get(PortalUtil.getGlobalLibDir()));
        

      Expected behavior: liferay.lib.global.dir value is printed
      Wrong behavior: "Illegal char <:> at index 2: /C:/path..." error is thrown

      Steps to reproduce checking environment properties

      1. Start Liferay in a Windows machine.
      2. Go to "Control panel" => "Configuration" => "Server Administration" => "Properties" tab
      3. In System Properties tab, filter by "liferay.lib.global"
        • Expected behavior: properties start with "C:/..."
        • Wrong behavior: properties start with "/C:/..."

      The issue can be also reproduced in a Windows machine, if you enable Elasticsearch 7 and Sidecar.
      In that environment, Sidecar won't startup due this issue. => For now, it was fixed removing the Paths.get usage, see: https://github.com/liferay/liferay-portal/commit/fc5a2d36a00c3abfd946db7f4cd55fff4cd6cb7b


      Update 20/05/2020

      After LPS-113450, this issue is reproduced again in a Windows machine, if you enable Elasticsearch 7 and Sidecar

      2020-05-20 14:41:47.072 WARN  [main][SidecarElasticsearchConnectionManager:92] Liferay is configured to use Elasticsearch engine running in a child process of current process named as sidecar. Do NOT use sidecar in production. Sidecar is useful for development and demonstration purposes. Refer to the documentation for details on the limitations of sidecar. Remote Elasticsearch connections can be configured in the Control Panel.
      2020-05-20 14:41:47.314 INFO  [main][Sidecar:125] Starting sidecar Elasticsearch
      2020-05-20 14:41:47.326 ERROR [main][ElasticsearchConnectionManager:93] bundle com.liferay.portal.search.elasticsearch7.impl:2.0.20 (1139)[com.liferay.portal.search.elasticsearch7.internal.connection.ElasticsearchConnectionManager(188)] : The activate method has thrown an exception 
      java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Liferay/Bundles_Builds/portal-master/tomcat-9.0.33/lib/ext/
      	at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
      	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
      	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
      	at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
      	at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
      	at java.nio.file.Paths.get(Paths.java:84)
      	at com.liferay.portal.search.elasticsearch7.internal.sidecar.ProcessExecutorPathsImpl.getLibPath(ProcessExecutorPathsImpl.java:34)
      	at com.liferay.portal.search.elasticsearch7.internal.sidecar.Sidecar.getBootstrapClassPath(Sidecar.java:226)
      	at com.liferay.portal.search.elasticsearch7.internal.sidecar.Sidecar._createProcessConfig(Sidecar.java:334)
      	at com.liferay.portal.search.elasticsearch7.internal.sidecar.Sidecar.start(Sidecar.java:133)
      	at com.liferay.portal.search.elasticsearch7.internal.connection.SidecarElasticsearchConnection.connect(SidecarElasticsearchConnection.java:41)
      	at com.liferay.portal.search.elasticsearch7.internal.connection.ElasticsearchConnectionManager.activate(ElasticsearchConnectionManager.java:270)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              victor.ware Victor Ware
              Reporter:
              jorge.diaz Jorge Diaz
              Participants of an Issue:
              Recent user:
              Tomáš Polešovský
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                14 weeks, 4 days ago

                  Packages

                  Version Package
                  7.3.3 CE GA4
                  7.3.10 DXP GA1
                  Master