Problem when using writer_pdf_Export filter in UNO LibreOffice - libreoffice

I installed LibreOffice [LibreOffice 6.1.3.2 10(Build:2)] and sdk on Ubuntu 16.03.
I used the java sample DocumentConverter in the sdk package to convert an odt in different formats.
With "MS WORD 97" or "Text" there is no problem but with "writer_pdf_Export" it ends in Exception
OK
java -jar /home/js/libreoffice6.1_sdk/LINUXexample.out/class/JavaDocumentHandlingExamples/DocumentConverter.jar "./test" "MS WORD 97" "doc" "/home/js/libreoffice6.1_sdk/LINUXexample.out/misc/JavaDocumentHandlingExamples/converted_files"
Connected to a running office ...
The converted documents will stored in "/home/js/libreoffice6.1_sdk/LINUXexample.out/misc/JavaDocumentHandlingExamples/converted_files!
[test]
test1.odt
KO
java -jar /home/js/libreoffice6.1_sdk/LINUXexample.out/class/JavaDocumentHandlingExamples/DocumentConverter.jar "./test" "writer_pdf_Export" "pdf" "/home/js/libreoffice6.1_sdk/LINUXexample.out/misc/JavaDocumentHandlingExamples/converted_files"
Connected to a running office ...
The converted documents will stored in "/home/js/libreoffice6.1_sdk/LINUXexample.out/misc/JavaDocumentHandlingExamples/converted_files!
[test]
com.sun.star.task.ErrorCodeIOException: SfxBaseModel::impl_store <file:////home/js/libreoffice6.1_sdk/LINUXexample.out/misc/JavaDocumentHandlingExamples/converted_files/test1.pdf> failed: 0x81a(Error Area:Io Class:Parameter Code:26)
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:158)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:122)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:312)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:281)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:81)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:618)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:145)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:129)
at com.sun.proxy.$Proxy5.storeAsURL(Unknown Source)
at DocumentConverter.traverse(DocumentConverter.java:137)
at DocumentConverter.main(DocumentConverter.java:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.star.lib.loader.Loader.main(Loader.java:132)
test1.odt
I need to use the UNO interface through java to convert to any format, and I really need pdf also...
Any help?

Are you doing "storeAsURL" or "storeToURL"?
"storeAsURL" is analogous to "Save As" -- for when you are saving a document in an editable format.
"storeToURL" is analogous to "Export" -- for generating an output in an uneditable format.
So I suspect that, if you switch from "storeAsURL" to "storeToURL", you'll get the PDF you wanted.

Related

Libreoffice Java API failing to export PDF

I have Java code that exports ODT file to PDF. This is working fine in Windows and MacOS but failing in Linux Mint 19.3. LibreOffice version 6.4.4.2. I can reproduce the same error using the DocumentConverter sample class. So I don't think I am doing something wrong in my code. The error is when storeAsURL() method is called. Here is the stack trace from DocumentConverter.java.
com.sun.star.task.ErrorCodeIOException: SfxBaseModel::impl_store <file:////home/leopold/Example.pdf> failed: 0x81a(Error Area:Io Class:Parameter Code:26)
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:158)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:122)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:312)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:281)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:81)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:619)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:145)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:129)
at com.sun.proxy.$Proxy5.storeAsURL(Unknown Source)
at com.example.oo.DocumentConverter.traverse(DocumentConverter.java:139)
at com.example.oo.DocumentConverter.main(DocumentConverter.java:218)
I am, however, able to successfully convert to PDF directly using soffice:
/opt/libreoffice6.4/program/soffice --nologo --invisible --headless \
--convert-to pdf Example.odt
Is there any way I can generate more information about why this error is happening?

How with tflileInputExcel in talend

I want to process multiple files one by one to merge them into one excel file(xlsx) using tfilelist so I proceeded like the screenshot but I'm getting these errors:
For input string: "N_Vol"
For input string: "N_Vol"
Exception in component tFileInputExcel_1
org.apache.poi.openxml4j.exceptions.InvalidOperationException:
Can't open the specified file: 'C:\Users\dell\Desktop\Data2 -
Copie\~$S_1.xlsx'
at org.apache.poi.openxml4j.opc.ZipPackage.<init>
(ZipPackage.java:112)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:224)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:186)
at org.apache.poi.POIXMLDocument.openPackage(POIXMLDocument.java:74)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:296)
at tunisair.lig_0_1.lig.tFileList_1Process(lig.java:913)
at tunisair.lig_0_1.lig.runJobInTOS(lig.java:2053)
at tunisair.lig_0_1.lig.main(lig.java:1910)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipFile(ZipHelper.java:174)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:110)
This is my job.
here is my tfileexcelinput parameters
[https://i.stack.imgur.com/6qOuD.jpg][1]
As said somewhere else ;) it seems there is a problem with 'C:\Users\dell\Desktop\Data2 - Copie\~$S_1.xlsx'.
Is this file in your input folder?
Are you able to open it with Excel?
Also, I saw you've selected the option to read all sheets in the Excel files. Are they all based on the same schema?
yes all files have the same schema and this file is not on my input folder and i dont know why he reads it and not reading the files in my input folder?

Problems with classloading when running JUnit plug-in tests in Eclipse

I have a problem when running JUnit Plug-in tests in Eclipse 4.3 and 4.2 and possible other versions. This worked in version 3.6 so I do not know what has changed.
The test are written using JUnit 4 and using parameterized tests (though I have tested with normal tests and the problem is the same). The test cases are written in YAML format and inflated at runtime using SnakeYAML.
When running the test as a normal JUnit test everything works fine, but when running the test as a JUnit Plug-in tests the test fails since it can no longer inflate objects from Yaml using SnakeYAML.
This is the code that reads test cases from YAML
public static ArrayList<StartsWithCommentTestCase> readTests(String filename) {
// set up how Java types match to the YAML file
Constructor testCaseConstructor = new Constructor(StartsWithCommentTestCase.class);
TypeDescription testCaseDesc = new TypeDescription(StartsWithCommentTestCase.class);
testCaseConstructor.addTypeDescription(testCaseDesc);
Yaml yamlParser = new Yaml(testCaseConstructor);
// read all the documents in the test file
String tests = TestUtils.readFile(filename);
ArrayList<StartsWithCommentTestCase> testCases = new ArrayList<StartsWithCommentTestCase>();
for (Object testCase : yamlParser.loadAll(new StringReader(tests))) {
testCases.add((StartsWithCommentTestCase) testCase);
}
return testCases;
}
#Test
public void bla(){
List<StartsWithCommentTestCase> tests = readTests(TEST_FILES_DIR + "starts-with-comment.yaml");
for(StartsWithCommentTestCase test : tests){
boolean actual = ToggleCommentHandler.startsWithComment( test.getLine() );
assertEquals( test.getName(), test.getExpected(), actual );
}
}
And this is the stacktrace that is received when running as a JUnit Plug-in test
Can't construct a java object for tag:yaml.org,2002:pde.test.tests.StartsWithCommentTestCase;exception=Class not found: pde.test.tests.StartsWithCommentTestCase
in "<reader>", line 4, column 1:
name: Empty line
^
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:325)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:181)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:140)
at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:109)
at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:317)
at pde.test.tests.StartsWithCommentTest.readTests(StartsWithCommentTest.java:86)
at pde.test.tests.StartsWithCommentTest.bla(StartsWithCommentTest.java:47)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
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.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
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:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
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: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: org.yaml.snakeyaml.error.YAMLException: Class not found: pde.test.tests.StartsWithCommentTestCase
at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:625)
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:313)
at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:323)
... 49 more
The strange thing (for me at least) is that I can make a StartsWithCommentTestCase object with
new StartsWithCommentTestCase()
without any problem also when running as a plugin test. In otherwords the class is avaiable at runtime, but for some reason not available to SnakeYAML.
Any pointers on this would be very helpful :)
Edit 1
The first lines of the YAML file:
#all the lines must have newlines in them since newlines are returned
#by Document.get()
---
name: Empty line
line:
expected: false
---
name: "Line where first character is #"
line: "#
"
expected: true
Edit 2
Added more code to the sample.
It looks like the Junit plugin don't know how to read the SnakeYAML code. Are you sure the class-loader of SnakeYAML is correctly initialized when you run the tests through the plug in?
And how does the mentioned line 4 look in your YAML code? Is it empty?
Maybe the junit plugin uses another jar dependency than your ordinary setup. Which maven binary/path does the junit plugin use? Is this the same as your ordinary one? If you have different m2-configurations or even different repos there will be strange issues.
I found out that this is because I had moved the SnakeYAML dependency to another plugin. SnakeYAML was then part of another plugin with a different class loader than the test plugin.
The solution was to add the following to the META-INF/MANIFEST.MF file in the dependeny plugin
Eclipse-BuddyPolicy: registered
And the following to the META-INF/MANIFEST.MF file in the test plugin
Eclipse-RegisterBuddy: <symbolic name of the dependency plugin>
Now on to see if I can move the SnakeYAML dependency back into a lib/ folder or similar.

How to set environmental variable from Scala?

I need to set environmental variable (PATH) from Scala.
I tried this:
val cmd = Seq("export", "PATH='bla'")
cmd.lines
but I got error:
java.io.IOException: Cannot run program "export": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:68)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.lines(ProcessBuilderImpl.scala:140)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.lines(ProcessBuilderImpl.scala:106)
at .<init>(<console>:12)
at .<clinit>(<console>)
at .<init>(<console>:11)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:914)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:546)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:577)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:543)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:694)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:651)
at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:542)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:550)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:851)
at xsbt.ConsoleInterface.run(ConsoleInterface.scala:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:73)
at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:64)
at sbt.Console.console0$1(Console.scala:23)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
at sbt.TrapExit$.executeMain$1(TrapExit.scala:33)
at sbt.TrapExit$$anon$1.run(TrapExit.scala:42)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 35 more
Is there some other way to do that?
Example from doc for sys.process.Process:
apply("java", new java.ioFile("/opt/app"), "CLASSPATH" -> "library.jar")
Edit for more helpful verbiage:
That is, you specify the env when you spawn a child process.
The environment of the current process is read-only; see System.getenv, or compare the abstractions sys.props and sys.env.
The fact that a shell augments the environment it bestows on subshells with exported variables is a shell convention. See 3.7.4 in the bash reference, for example:
On invocation, the shell scans its own environment and creates a
parameter for each name found, automatically marking it for export to
child processes. Executed commands inherit the environment. The export
and ‘declare -x’ commands allow parameters and functions to be added
to and deleted from the environment. If the value of a parameter in
the environment is modified, the new value becomes part of the
environment, replacing the old. The environment inherited by any
executed command consists of the shell's initial environment, whose
values may be modified in the shell, less any pairs removed by the
unset and ‘export -n’ commands, plus any additions via the export and
‘declare -x’ commands.
This is the first time my answer was longer than the Daniel Sobral answer it duplicates.
'export' isn't an executable, it's a shell built-in command. If you're trying to set the path in the parent shell, well, you can't. You can set it for a new shell that you execute. This is really more of a unix FAQ.

Eclipse RCP/ Plug-in Question

I have an RCP application (referred to as RCP-APP). I have created a new plug-in (referred to as plug-in A) that wraps a media player api (.jar file) and a folder of C libraries (dlls) that the media player api accesses via JNA. I then created another plugin (referred to as plug-in B) that contains a media player application that depends on Plug-in A.
When plug-in B is activated I get the following error messages informing me that Plug-in B cannot find the media player .dlls it is looking for:
!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)
How do I inform Plug-in B (or the RCP-APP) that the .dlls are in a specific folder in Plug-in A?
It appears that the api expects to find the .dlls via it's environment PATH variable.
How can I essentially communicate "plug-in A/Folder-Name"?
Thanks for your assistance.
To get access to the .DLL files in plugin-a/folder you need access to the Bundle instance of plug-in A. One way is to implement an Activator for plug-in A which extends at least the class Plugin ("PluginA").
The call PluginA.getDefault().getBundle().getEntry("folder/some.dll") will return an URL to the .DLL file.
IMHO it is better to put all code that directly accesses the .DLL files into plug-in A. This way you don't need to expose the internal file structure of your plug-in to its users.
You will probably want to look at plugin fragments; this provides a mechanism to keep the public facing Java API apart from the (platform specific) dll/so files.
The packaging of SWT would be a good place to start looking at this sort of problem.
You could build a "binaries" plugin, put the dll in a subfolder bin/ of it, then make sure in the manifest
* you add an activator + singleton property.
* you check bin/ in the "Build", "Runtime Build" section
In the feature that includes your binaries plug-in, make sure to check "Unpack the plugin archive after installation"
In the activator of your binaries plugin, add something like this :
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()];
}
I copy pasted from some code of mine, so sorry it doesn't perfectly match your DLL example, I was getting executable paths from a restricted list (see enum Tool). The last step (setting the +x flag on the file) is probably useless in your case. On the other hand you get some exception handling code and a cache for free :) And its tested pretty thoroughly.
It does the job you are trying to do, pass the url to the binary to the downstream plugin.