Reputation: 11
I am trying to use the Jasper interface from SICStus to start a SICStus server from Java as part of an Eclipse RCP Application using the SICStus
class and the startServer()
method:
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
I have tried to include the jasper.jar from the SICStus installation through the common methods that I am aware of (wrapping it as a plugin project, importing & adding to build path, creating a user library). However, when I instantiate the SICStus class I receive the stack trace as posted below. The triggering lines in the source of SICSTus.class
are as follows:
URL classURL = SICStus.class.getResource("SICStus.class");
if (debugLevelValueOrig>0) dbgPrintln("classURL==" + classURL);
String realLibName = System.mapLibraryName(libName);
try {
JarURLConnection juc = (JarURLConnection)classURL.openConnection();
…
Upon trying to make the cast of the classURL
variable to a JarURLConnection
the instantiation fails because eclipse loads dependencies as BundleURLConnection
and the cast cannot be made. The class should be loaded from an Eclipse plug-in project associated with a product configuration. The question being: are there any workarounds to the Eclipse classloader? Does anyone have any advice on how to use this class in an Eclipse plug-in?
Thank you in advance, -John
STACKTRACE:
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
Upvotes: 1
Views: 316
Reputation: 10487
The jasper jar will only work if it is located in the file system, in the original file system location relative the other SICStus-files it depends on. This is so that it can find and load the SICStus JNI-library etc. Packaging the jasper jar file is therefore unlikely to work.
If at all possible I would recommend against using Jasper. It is often better to instead start a SICStus (runtime-) process as a sub-process and just communicate via the standard streams. This avoids the possibility of incompatibilities between the Java and the SICStus runtimes trying to co-exist in the same process. It is also much easier to debug since you can use a full blown development system while developing (possibly communicating via sockets instead of the standard streams).
Upvotes: 1