SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

error in reading config file under windows #365

Closed AmmRage closed 5 years ago

AmmRage commented 5 years ago

encounter exception: Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in opaque part at index 2

Expected Behavior

load config file

Current Behavior

throw exception

Context

the exception thrown when start restheart at standalone jar file

Environment

window 10 pro 64 bit restheart 4.1.0 mongodb 4.0.3

Steps to Reproduce

  1. download restheart 4.1.0 and run with as the simplest scenario specifying config and property file.

Possible Implementation

check the platform, if it's windows replace '\' to '/' in file path before new DefaultMustacheFactory().compile(configFile);

mkjsix commented 5 years ago

Hi @AmmRage

Could please tell us how you are passing the configuration from the command line? The path is coming from there.

Besides I can't find a reference in the source code to the line you mentioned DefaultMustacheFactory().compile(configFile);

I only have Mustache m = new DefaultMustacheFactory().compile(CONFIGURATION_FILE.toString());, line 216 of Bootstrapper.java

A more complete Java stacktrace will help us identifying the issue.

AmmRage commented 5 years ago

Hi @AmmRage

Could please tell us how you are passing the configuration from the command line? The path is coming from there.

Besides I can't find a reference in the source code to the line you mentioned DefaultMustacheFactory().compile(configFile);

I only have Mustache m = new DefaultMustacheFactory().compile(CONFIGURATION_FILE.toString());, line 216 of Bootstrapper.java

A more complete Java stacktrace will help us identifying the issue.

Sorry for misleading. It's exactly line 216 of Bootstrapper.java. fully exception stacktrace as below: Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in opaque part at index 2: D:\restheart\etc\restheart.yml at java.base/java.net.URI.create(URI.java:883) at com.github.mustachejava.resolver.ClasspathResolver.getReader(ClasspathResolver.java:37) at com.github.mustachejava.resolver.DefaultResolver.getReader(DefaultResolver.java:44) at com.github.mustachejava.DefaultMustacheFactory.getReader(DefaultMustacheFactory.java:118) at com.github.mustachejava.MustacheParser.compile(MustacheParser.java:26) at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) at com.github.mustachejava.DefaultMustacheFactory.compile(DefaultMustacheFactory.java:179) at org.restheart.Bootstrapper.loadConfiguration(Bootstrapper.java:216) at org.restheart.Bootstrapper.main(Bootstrapper.java:140) Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: D:\restheart\etc\restheart.yml at java.base/java.net.URI$Parser.fail(URI.java:2915) at java.base/java.net.URI$Parser.checkChars(URI.java:3086) at java.base/java.net.URI$Parser.parse(URI.java:3122) at java.base/java.net.URI.<init>(URI.java:600) at java.base/java.net.URI.create(URI.java:881) ... 8 more

mkjsix commented 5 years ago

Issue reproduced, we'll fix it in 4.1.2 which will be released next week.