2015-04-13 1 views
1

J'écris une application Java en utilisant Vertx. J'essaie de déployer un de mes modules en utilisant le code suivant. Mais je fais face à IllegalArgumentException, que je ne suis pas capable de résoudre.java.lang.IllegalArgumentException - 'other' a une racine différente

Une partie de ma classe principale:

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(); 

L'erreur dans la console se présente comme suit:

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) 

Toute aide à cet égard sera apprécié.

+0

'new FileInputStream (System.getProperty (" user.dir ") + ...' - est-ce que cela fonctionne réellement? – immibis

+0

En note, les noms de variable longs ne vous mordront pas. votre code est plus facile à lire –

+0

Vous pouvez jeter un oeil à cette réponse: http://stackoverflow.com/questions/16299604/creating-a-path-between-two-paths-in-java-using-the- path-class – tddmonkey

Répondre

0

J'ai trouvé la solution pour mon cas.

Pour un projet vertx, il y aura un fichier mod.json dans le projet. Il devrait avoir le json suivant.

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

"preserve-cwd": true fait l'aide.