Question

I have a java web-application which uses the jacob library (running both in 32bit and in 64bit) to create/open word files. It correctly runs on my machine (32bit), it means that the word application is launched and the word file is opened. The problem arise when the java project is loaded on the server machine (64bit): the word application will be launched (I see "WINWORD.EXE * 32" on Task Manager window), but the file is not opened.

I don't understand what am I missing.

May you help me? Thanks in advance.

Was it helpful?

Solution

I'd strongly suspect one of the following things is happening:

  1. Security Violation
  2. Unsatisfied Link Error
  3. Word is not installed on the server
  4. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top