![Smile :)](https://www.docx4java.org/forums/images/smilies/icon_e_smile.gif)
My application is running on Ubuntu 8 and when i try to create a file with images, i got an error about X11: "No X11 DISPLAY variable was set, but this program performed an operation which requires it.".
After this, i've tried to set:
DISPLAY=:0.0
export DISPLAY
And it still doesn't work ... i've tried set a parameter for JAVA_OPTS on Jboss:
-Djava.awt.headless=true
It still doesn't work but now i have a different exception:
javax.ejb.EJBException: Unexpected Error
java.lang.ExceptionInInitializerError
at com.mycompany.ourproject.util.CreateDocx.newImage(CreateDocx.java:179)
at com.mycompany.ourproject.util.CreateDocx.createImage(CreateDocx.java:168)
...
Caused by: java.awt.HeadlessException
at sun.awt.HeadlessToolkit.getScreenResolution(HeadlessToolkit.java:203)
at org.apache.xmlgraphics.image.loader.impl.DefaultImageContext.<init>(DefaultImageContext.java:37)
at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.<clinit>(BinaryPartAbstractImage.java:139)
... 97 more
And here is my code at line 179:
- Code: Select all
public static org.docx4j.wml.P newImage( WordprocessingMLPackage wordMLPackage,
byte[] bytes,
String filenameHint, String altText,
int id1, int id2) throws Exception {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes); // LINE 179
Inline inline = imagePart.createImageInline( filenameHint, altText,
id1, id2);
// Now add the inline in w:p/w:r/w:drawing
org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory();
org.docx4j.wml.P p = factory.createP();
org.docx4j.wml.R run = factory.createR();
p.getParagraphContent().add(run);
org.docx4j.wml.Drawing drawing = factory.createDrawing();
run.getRunContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
return p;
}
Any ideas?
Thanks.
David