I'd strongly suspect one of the following things is happening:
- Security Violation
- Unsatisfied Link Error
- Word is not installed on the server
- Some other classloader error (edit)
I tried with a simple jsp, and invoked the LibraryLoader directly within a try-catch block:
try {
LibraryLoader.loadJacobLibrary();
ActiveXComponent oWord = new ActiveXComponent("Word.Application");
oWord.setProperty("Visible", new Variant(true));
} catch (Throwable th) {
th.printStackTrace(new java.io.PrintWriter(out));
}
and hit on a failure to initialize the JacobObject class - caused because of security violation from the static debug initializer: "true".equalsIgnoreCase(System.getProperty("com.jacob.debug"));
. Once I replaced that with a simple assignment to true, and replaced it in the jacob.jar, I ended up with a: java.lang.UnsatisfiedLinkError: no jacob-1.16-x64 in java.library.path
It's at this point things get hairy. You will probably have to replace the LibraryLoader code that replaced the method loadJacobLibrary
with something like:
public static void loadJacobLibrary() {
System.load("C:/<path to .dll as known on the server>/" + getPreferredDLLName() + ".dll");
}
Which then invoked the Word.Application
.
edit For the some other classloader error, the underlying issue is that you can only load one instance of a .dll within the server - This refers to using tomcat, but the issue is similar with all other servlet containers - you need to load the .dll only once, and in order to ensure that the code is available across all the servlets, it needs to be loaded into a classloader that doesn't get disturbed by reloading the web application. If that happens then you will become unable to make use of the .dll until the server application is reloaded.