【问题标题】:java.lang.IllegalArgumentException - 'other' has different rootjava.lang.IllegalArgumentException - “其他”有不同的根
【发布时间】:2015-06-18 17:49:25
【问题描述】:

我正在使用 Vertx 编写一个 java 应用程序。我正在尝试使用以下代码部署我的模块之一。但我面临 IllegalArgumentException,我无法解决。

我的主要课程的一部分:

System.out.println(System.getProperty("user.dir")
                + File.separator + "modules" + File.separator
                + "agents-0.0.1-SNAPSHOT-mod.zip");
        InputStream agf = new FileInputStream(System.getProperty("user.dir")
                + File.separator + "conf" + File.separator
                + "dbproperties1.json");
            String json = IOUtils.toString( agf );
            LOGGER.debug("db json:::"+json);
        JsonObject configprop =  new JsonObject(json);
        pm.deployModuleFromZip(System.getProperty("user.dir")
                + File.separator + "modules" + File.separator
                + "agents-0.0.1-SNAPSHOT-mod.zip", configprop, 1,
                new AsyncResultHandler<String>() {
                    public void handle(AsyncResult<String> asyncResult) {
                        LOGGER.debug("Deployment agnet ID dddd");
                        if (asyncResult.succeeded()) {
                            LOGGER.debug("Deployment agnet ID is "
                                    + asyncResult.result());
                        } else {
                            LOGGER.debug("Deployment agnet  ID is null "
                                    + asyncResult.result());
                            asyncResult.cause().printStackTrace();
                        }
                    }
                }); 
        agf.close();

控制台报错如下:

java.lang.IllegalArgumentException: 'other' has different root
    at sun.nio.fs.WindowsPath.relativize(WindowsPath.java:392)
    at sun.nio.fs.WindowsPath.relativize(WindowsPath.java:44)
    at org.vertx.java.platform.impl.DefaultPlatformManager.setPathResolver(DefaultPlatformManager.java:1128)
    at org.vertx.java.platform.impl.DefaultPlatformManager.access$2000(DefaultPlatformManager.java:55)
    at org.vertx.java.platform.impl.DefaultPlatformManager$18.run(DefaultPlatformManager.java:1276)
    at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:171)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:353)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:366)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    at java.lang.Thread.run(Thread.java:745)

我们将不胜感激。

【问题讨论】:

  • new FileInputStream(System.getProperty("user.dir") + ... - 这真的有效吗?
  • 附带说明,长变量名不会咬你。他们所做的只是让您的代码更易于阅读。
  • 你可能想看看这个答案:stackoverflow.com/questions/16299604/…
  • immibis - 是的 FileInputStream 正在工作。我正在使用相同的语法部署另外两个模块。但我只面临这个特定模块的问题。
  • QPaysTaxes - 抱歉!匆忙中,我写了一个测试代码。我只是把它复制到这里。下次我会记住为变量提供正确的名称。

标签: java eclipse illegalargumentexception vert.x


【解决方案1】:

我找到了适合我的情况的解决方案。

对于一个vertx项目,项目中会有mod.json文件。它应该具有以下 json。

{
  "main": "com.company.agent.Manager",
  "preserve-cwd": true
}

"preserve-cwd": true 提供帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-20
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-20
    相关资源
    最近更新 更多