构建Eclipse RCP应用程序,运行失败
-
20-09-2019 - |
题
在成功构建我的应用程序,因为它依赖于它位于META-INF目录,这个目录压缩到一个jar文件编译后的配置文件启动失败,从而使其无法访问配置文件。后手动解压的jar,删除罐子和重命名与xxx.jar程序没有问题,运行的目录。 该配置文件都需要SSO登录(Kerberos的)。 下面是代码:
Bundle bundle = Platform.getBundle(Application.PLUGIN_ID);
String path;
try {
path = new URL(bundle.getLocation().substring(18)).getPath();
} catch (MalformedURLException e1) {
System.out.println(e1);
path="";
}
System.setProperty("java.security.auth.login.config",path+"META-INF/jaas-win.config");
路径变量包含有类似 “插件/ mydomain.pluginame-xxxx.jar /” 但似乎该系统需要的jar解压。
这是我做错了构建应用程序? 感谢
解决方案
的代码变更为后:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL authconf = null;
authconf= cl.getResource("META-INF/jaas-win.config");
if (authconf == null) {
loginContext = null;
return;
}
String p;
try {
p = URLDecoder.decode(authconf.toExternalForm(), "UTF-8");
System.setProperty("java.security.auth.login.config", p);
} catch (UnsupportedEncodingException e1) {
loginContext = null;
return;
}
现在的工作。
不隶属于 StackOverflow