-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: Master
-
Fix Version/s: 7.3.3 CE GA4, 7.3.10 DXP GA1, Master
-
Component/s: Core Infrastructure
-
Labels:
-
Fix Priority:3
-
OS:Windows 10
-
Git Pull Request:
"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
- Start Liferay in a Windows machine.
- Go to "Control panel" => "Configuration" => "Server Administration" => "Script" tab
- 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
- Start Liferay in a Windows machine.
- Go to "Control panel" => "Configuration" => "Server Administration" => "Properties" tab
- In System Properties tab, filter by "liferay.lib.global"
- Expected behavior: properties start with "C:/..."
- Wrong behavior: properties start with "/C:/..."
- Expected 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
- PR: https://github.com/brianchandotcom/liferay-portal/pull/88864
- Line that causes the issue: https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-search-elasticsearch7/portal-search-elasticsearch7-impl/src/main/java/com/liferay/portal/search/elasticsearch7/internal/sidecar/ProcessExecutorPathsImpl.java#L34
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)
- is related to
-
LPS-112075 Sidecar can not be started on windows
- Closed
-
LPS-113450 Elasticsearch 7: make unit tests compatible with Sidecar (decouple Embedded away)
-
- Closed
-
- Testing discovered
-
LPS-112840 Groovy Script with Paths.get(PortalUtil.getGlobalLibDir()) crashes server admin on Websphere
- Closed