我正在尝试使用 SICStus 的Jasper接口从Java启动 SICStus 服务器,作为使用类和方法的Eclipse RCP 应用程序的一部分:SICStus
startServer()
http://sicstus.sics.se/sicstus/docs/3.12.7/html/sicstus/Jasper.html http://sicstus.sics.se/sicstus/docs/4.0.8/html/jasper/se/sics /jasper/SICStus.html
我尝试通过我知道的常用方法(将其包装为插件项目、导入并添加到构建路径、创建用户库)从 SICStus 安装中包含 jasper.jar。但是,当我实例化 SICStus 类时,我会收到如下所示的堆栈跟踪。源码中的触发线SICSTus.class
如下:
URL classURL = SICStus.class.getResource("SICStus.class");
if (debugLevelValueOrig>0) dbgPrintln("classURL==" + classURL);
String realLibName = System.mapLibraryName(libName);
try {
JarURLConnection juc = (JarURLConnection)classURL.openConnection();
…
在尝试将classURL
变量转换为JarURLConnection
实例化失败时,因为 eclipse 加载依赖项BundleURLConnection
并且无法进行转换。该类应该从与产品配置关联的 Eclipse 插件项目中加载。问题是:Eclipse 类加载器有什么解决方法吗?有人对如何在 Eclipse 插件中使用这个类有任何建议吗?
提前谢谢你,-约翰
堆栈跟踪:
eclipse.buildId=unknown
java.version=1.6.0_65
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments: -product com.ios.solstice.base.app.product -cl
earPersistedState
Command-line arguments: -product com.ios.solstice.base.app.product
-data /Users/iosDev11/Documents/ProjectSolstice/../runtime-solstice.
base.product -dev file:/Users/iosDev11/Documents/ProjectSolstice/.me
tadata/.plugins/org.eclipse.pde.core/solstice.base.product/dev.prope
rties -os macosx -ws cocoa -arch x86_64 -consoleLog -clearPersistedS
tate
!ENTRY org.eclipse.ui 4 0 2014-07-10 09:58:04.865
!MESSAGE Unhandled event loop exception
!STACK 0
**org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastExcept
ion: org.eclipse.osgi.framework.internal.core.BundleURLConnection ca
nnot be cast to java.net.JarURLConnection**
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRe
questor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(In
jectorImpl.java:243)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl
.java:224)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(Cont
extInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.exec
ute(HandlerServiceHandler.java:167)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java
:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks
(ParameterizedCommand.java:508)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.execute
Handler(HandlerServiceImpl.java:213)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionIte
m.executeItem(HandledContributionItem.java:850)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionIte
m.handleWidgetSelection(HandledContributionItem.java:743)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionIte
m.access$7(HandledContributionItem.java:727)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionIte
m$4.handleEvent(HandledContributionItem.java:662)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4166)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4
012)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:365
1)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.r
un(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Rea
lm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run
(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(
E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Rea
lm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbenc
h.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:
150)
at com.ios.solstice.base.app.Application.start(Application.java:21)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseApp
Handle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.run
Application(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.sta
rt(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStart
er.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStart
er.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessor
Impl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod
AccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
**Caused by: java.lang.ClassCastException: org.eclipse.osgi.framework.
internal.core.BundleURLConnection cannot be cast to java.net.JarURLC
onnection
at se.sics.jasper.SICStus.loadNativeCode(SICStus.java:536)
at se.sics.jasper.SICStus.initSICStus(SICStus.java:834)
at se.sics.jasper.SICStus.<init>(SICStus.java:933)**
at com.ios.solstice.base.core.prolog.PrologServer.connectSession(Pr
ologServer.java:52)
at com.ios.solstice.base.ui.handler.RunHandler.execute(RunHandler.j
ava:44)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerPro
xy.java:290)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4Handle
rProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessor
Impl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod
AccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRe
questor.java:56)
... 41 more