我的 jfinal 项目内嵌了jetty服务器, 在eclipse上运行没问题, 但是我将项目导出成runnable jar文件, 却出现了问题, 我看了一眼可能是路径问题,但是不知道怎么解决, 请帮我看一下。
cmd 控制台信息:
F:\>java -jar biomarker.jar
Jetty Server and Jfinal is starting--
Starting JFinal 2.2
ERROR [main] (LogKit.java:75) - java.net.URISyntaxException: Expected
scheme-specific part at index 5: rsrc:
java.lang.RuntimeException: java.net.URISyntaxException: Expected scheme-specific part at index 5: rsrc:
at com.jfinal.kit.PathKit.detectWebRootPath(PathKit.java:90)
at com.jfinal.kit.PathKit.getWebRootPath(PathKit.java:72)
at com.jfinal.server.JettyServer.getStoreDir(JettyServer.java:157)
at com.jfinal.server.JettyServer.persistSession(JettyServer.java:164)
at com.jfinal.server.JettyServer.doStart(JettyServer.java:94)
at com.jfinal.server.JettyServer.start(JettyServer.java:65)
at com.jfinal.core.JFinal.start(JFinal.java:154)
at com.unimelb.zhex3.j2eeFramework.MainConfig.main(MainConfig.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 5: rsrc:
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.failExpecting(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.net.URL.toURI(Unknown Source)
at com.jfinal.kit.PathKit.detectWebRootPath(PathKit.java:87)
... 12 more
在我写的代码是启动服务器出现问题的,也就是调用JFinal.start("WebRoot", 80, "/", 5);出现了问题,具体的问题出现位置是在框架的PathKit.class中
private static String detectWebRootPath() {
try {
String path = PathKit.class.getResource("/").toURI().getPath();
return new File(path).getParentFile().getParentFile().getCanonicalPath();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
抛出了run time 异常,请问是什么原因造成的路径错误,怎样解决呢?