Reputation:
I'm trying to install the docx4j open source java library in an XPages application but so far without success. I have downloaded the docx4j-3.1.0.jar and added it to the \jvm\lib\ext folder on both the domino server and my local machine. I have also added the docx4j-3.1.0.jar to the WebContent\WEB-INF\lib folder using the Package Explorer view, after which I right clicked the .jar and choose "Build Path" -> "Add to build path" so that the .jar now appears under "Referenced Libraries".
In a Java class I'm using to test, I see the message "This element has no attached source and the Javadoc could not be found in the attached Javadoc." My code is as follows:
package TESTPackage;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
public class JavaDoc {
public void createJavaDoc() {
try {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
wordMLPackage.getMainDocumentPart().addParagraphOfText("Hello Word!");
wordMLPackage.save(new java.io.File("C:\\Temp\\HelloWord1.docx"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Any suggestions on what else I must do?
Upvotes: 0
Views: 496
Reputation: 7597
I was able to run your code in the Notes client from a button in an XPage. There are a few steps involved in getting this code to work (Domino is a painful platform to work with for running Java code reliably):
Add docx4j and its dependencies to your workstation / server's lib\ext
directory (you don't need them in the NSF as well. In fact, remove them from there).
Edit the Domino JVM java.policy
file as follows. (This file is usually found in the installation directory under \jvm\lib\security
). Note that for dev work it's OK to add this line to the top, but you can't go into production with it: you need to focus permitted operations by wild-carded package name or operation type:
grant { permission java.security.AllPermission; };
Re-start Notes / Domino Designer
Build your project. Note: if you 'clean' your project instead, bear in mind that old-style 'included' Java files (i.e. those you place directly in your NSF's local
folder when on Domino 8.5.2 or earlier) will be removed, so you'll need to re-create them.
Run the code as in your post: the file should now be generated.
The issues you've been experiencing are likely down to two things: (1) missing dependencies and; (2) security settings in Domino which prohibit required classloading and reflection operations.
Upvotes: 5
Reputation: 15739
Adding the jar to the jvm\lib\ext on the server will mean you won't need it in the database. But you'll need to add it to the relevant location for Domino Designer to see it. Once that's done, you don't need to add it to the NSF, but you will need to ensure it's on all servers you put the NSF.
The alternative to storing it on the server and other locations is to put it in WebContent\WEB-INF\lib, but then it's not going to bother looking to the server.
It sounds like you've attached the wrong jar file though. You've attached a compiled jar. The code will work, but as you're finding you can't see the Javadoc assistance.
You need to attach a jar that has source files in it. Then you'll see Javadoc content assistance
Upvotes: 3