2009-06-22 153 views
1

我有一個RCP應用程序(簡稱RCP-APP)。我創建了一個包含媒體播放器api(.jar文件)的新插件(稱爲插件A)和一個媒體播放器api通過JNA訪問的C庫(dll)文件夾。然後我創建了另一個插件(稱爲插件B),其中包含依賴於插件A的媒體播放器應用程序。Eclipse RCP /插件問題

當插件B被激活時,我收到以下錯誤消息,通知我Plug-在B因找不到球員.DLL文件是媒體正在尋找:

 
!ENTRY org.eclipse.jface 4 2 2009-06-22 10:05:22.475 
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface". 
!STACK 0 
java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': The specified module could not be found. 

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:114) 
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:157) 
    at com.sun.jna.Library$Handler.(Library.java:123) 
    at com.sun.jna.Native.loadLibrary(Native.java:260) 
    at com.sun.jna.Native.loadLibrary(Native.java:246) 
    at org.videolan.jvlc.internal.LibVlc.(LibVlc.java:41) 
    at org.videolan.jvlc.JVLC.(JVLC.java:45) 
    at com.bah.gs.arts.jekyll.plugins.videolog.VideoLogDisplay.displayStream(VideoLogDisplay.java:32) 
    at com.bah.gs.arts.jekyll.core.extensionpoints.DisplayStreamFactory.getDisplayStreams(DisplayStreamFactory.java:57) 
    at com.bah.gs.arts.jekyll.core.views.medialist.MediaListView$1.doubleClick(MediaListView.java:91) 
    at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:799) 
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) 
    at org.eclipse.core.runtime.Platform.run(Platform.java:880) 
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48) 
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) 
    at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:797) 
    at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1419) 
    at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1173) 
    at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:237) 
    at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:234) 
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:295) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200) 
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at com.bah.gs.arts.jekyll.core.Application.start(Application.java:20) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1236) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1212) 

如何告知插件B(或RCP-APP)的.DLL文件是在一個特定的文件夾中的插件A

看來,api希望通過它的環境PATH變量找到.dll。

我該如何溝通「插件A /文件夾名稱」

感謝您的協助。

回答

1

要訪問的.dll文件的插件,-A /文件夾,您需要訪問的插件A.的Bundle實例的方法之一是實現一個Activator的插件中,其至少延伸類Plugin (「PluginA」)。

呼叫PluginA.getDefault().getBundle().getEntry("folder/some.dll")將返回一個URL到.DLL文件。

恕我直言,最好將直接訪問.DLL文件的所有代碼插入到插件A.這樣您就不需要將插件的內部文件結構公開給它的用戶。

+0

」恕我直言,最好將直接訪問.DLL文件的所有代碼插入到插件A.這樣您就不需要將插件的內部文件結構公開給它的用戶。「 確實如此。但是,這推斷出我創建的每個插件都使用媒體播放器api,它將包含dll和.jar文件的副本,這正是我試圖通過放置.jar文件和。 – 2009-06-22 15:01:45

+0

無論如何.....我api試圖通過PAT變量找到.dlls我誤以爲能夠將位置作爲參數傳遞給api – 2009-06-22 15:22:21

1

你可能會想看看插件片段;這提供了一種機制來讓公衆面對Java(特定於平臺的)dll/so文件。

SWT的包裝將是一個開始尋找這類問題的好地方。

0

你可以建立一個「二進制文件」插件,把dll放在它的一個子文件夾中,然後確保在清單 *中添加一個激活器+單件屬性。 *您檢查斌/「生成」,「運行時編譯」部分

在包含二進制文件的插件的功能,請務必檢查「安裝後解壓插件壓縮」

在您的二進制文件的插件的激活劑,添加如下內容:

public enum Tool {reach, ctl, ltl}; 
private static URI toolUri [] = new URI [3]; 

public static URI getProgramURI(Tool tool) throws IOException { 
    if (toolUri[tool.ordinal()] == null) { 
     String relativePath = "bin/its-"+ tool.toString() ; 
     URL toolff = getDefault().getBundle().getResource(relativePath); 
     if (toolff == null) { 
      log.severe("unable to find an executable [" + tool + "] in path " + relativePath); 
      Enumeration<URL> e = getDefault().getBundle().findEntries("bin/", "*", true); 
      log.fine("Lising URL available in bin/"); 
      while (e.hasMoreElements()) { 
       log.finer(e.nextElement().toString()); 
      } 
      throw new IOException("unable to find the tool binary"); 
     } 
     URL tmpURL = FileLocator.toFileURL(toolff); 

     // use of the multi-argument constructor for URI in order to escape appropriately illegal characters 
     URI uri; 
     try { 
      uri = new URI(tmpURL.getProtocol(), tmpURL.getPath(), null); 
     } catch (URISyntaxException e) { 
      throw new IOException("Could not create a URI to access the binary tool :", e); 
     } 
     toolUri[tool.ordinal()] = uri; 
     log.fine("Location of the binary : " + toolUri); 

     File crocExec = new File(uri); 
     if (!crocExec.setExecutable(true)) { 
      log.severe("unable to make the command-line tool executable [" + toolUri + "]"); 
      throw new IOException("unable to make the command-line tool executable"); 
     }  

    } 
    return toolUri[tool.ordinal()]; 
} 

我將複製我的一些代碼,粘貼,很遺憾它並不完全匹配您的DLL的例子,我是從限制列表中獲取可執行的路徑(見枚舉工具)。最後一步(在文件上設置+ x標誌)在您的情況下可能沒有用處。另一方面,你可以免費得到一些異常處理代碼和緩存:)並且它的測試非常徹底。

它執行您正在嘗試做的工作,將url傳遞給下游插件的二進制文件。 「