-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MS Office automation example broken with 4.2.1 release #572
Comments
This test seems to be working ok for me. I tried using both master and 4.2.1 versions of JNA, with Office 16.0. Which version of Office are you using? Are you using JNA from a jar or from sources? |
The NPE is #412, actually. |
I am using Office 15 (Office 2013) Windows 7, using JNA from jar(jna.jar& jna-platform.jar) |
I receive this error as well. I'm using Excel 16 on Windows 10 with the jars. It works when I us 4.1.0, but not 4.2.1. The Excel application seems to be created, but if I try to invoke any methods, or set any properties, this error happens. |
Hi there, I had the same problem with Word 2007, Java 8 (32-Bit). When I switched to 64-Bit-Java the call of setProperty works well. |
bug? => bug |
There were several fixes that already went into the 4.3 branch, at least one segfault was fixed (callbacks). I updated the msoffice sample: https://github.com/matthiasblaesing/jna/tree/msoffice_enhancement and would appreciate further tests. With this branch I tested:
With these calls: java -cp demo-msoffice.jar com.sun.jna.platform.win32.COM.office.MSOfficeDemo
java -cp demo-msoffice.jar com.sun.jna.platform.win32.COM.util.office.Excelautomation_KB_219151_Mod
java -cp demo-msoffice.jar com.sun.jna.platform.win32.COM.util.office.Wordautomation_KB_313193_Mod
java -cp demo-msoffice.jar com.sun.jna.platform.win32.COM.util.office.MSOfficeWordDemo
java -cp demo-msoffice.jar com.sun.jna.platform.win32.COM.util.office.MSOfficeExcelDemo Please note: the head of the branch contains the version for english locales, I offer prebuild versions: DE: http://www.doppel-helix.eu/demo-msoffice.jar |
When I start the MSOfficeDemo in the actual 4.3-branch (4b7421c) I get following error:
It is with Java8, Java7, 32 Bit or 64 Bit all the same. I use Excel 2016 on Windows 7. When I use JNA to start Excel in this way, all is working fine:
and Application is:
So the application is registered properly... Is this a problem of the resolution of the progID? |
The example in HEAD is is broken, as the COM subsystem is not correctly initialized (please run with assertions enabled, than it should show). And I would bet, that: // This is line 128
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
IDispatch.IID_IDISPATCH, this.pDispatch);
}
if (COMUtils.FAILED(hr)) {
throw new COMException("COM object with ProgID '" + progId
+ "' and CLSID " + clsid.toGuidString()
+ " not registered properly!");
} fails because that precondition is not met. That was one of the things covered in the patch (correctly initialize COM). |
I doubt that the ProgId can't be resolved, as that happens around line 109 in ComBindingBaseObject: // Get CLSID for Word.Application...
CLSID.ByReference clsid = new CLSID.ByReference();
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
if (COMUtils.FAILED(hr)) {
throw new COMException("CLSIDFromProgID() failed!");
} As this is error checked, it should have failed earlier |
@matthiasblaesing ah, yes, you are right. The initialization isn't done. But the error handling in MSOfficeDemo is quite misleading. If the FAILED hr code would have been tested with COMUtils.checkRC(hr) then there is the enlightening error message: |
@SevenOf9Sleeper - both your point are correct:
I'd appreciate another testrun. |
The office samples were verified for these environments: Platform Windows 10 64Bit: * Java 1.8.0_77 64 Bit + Office 2013 64 Bit (Testversion) * Java 1.8.0_77 32 Bit + Office 2013 64 Bit (Testversion) Platform Windows 7 64Bit: * Java 1.8.0_60 64 Bit + Office 2007 32 Bit * Java 1.8.0_60 32 Bit + Office 2007 32 Bit Closes java-native-access#572
The office samples were verified for these environments: Platform Windows 10 64Bit: * Java 1.8.0_77 64 Bit + Office 2013 64 Bit (Testversion) * Java 1.8.0_77 32 Bit + Office 2013 64 Bit (Testversion) Platform Windows 7 64Bit: * Java 1.8.0_60 64 Bit + Office 2007 32 Bit * Java 1.8.0_60 32 Bit + Office 2007 32 Bit Closes java-native-access#572
…ava-native-access#572) Motivation: When caching fails during workflow execution we should still continue the build as its just an optimization. Also we should use the new fork for docker layer caching Modifications: - Update action that does the docker layer caching to the new fork - Ignore errors during caching Result: More stable builds
The JNA MS office example from: https://github.com/java-native-access/jna/tree/master/contrib/msoffice is broken.
The example code works fine with JNA 4.1.0, but when I update JNA to latest 4.2.1 release, it's broken.
I get the following exception:
The text was updated successfully, but these errors were encountered: