Closed GoogleCodeExporter closed 8 years ago
I have seen this same issues many times... are you under a proxy?
Original comment by leonardo...@gmail.com
on 12 Oct 2011 at 12:27
Even on removing the proxy, I am getting the same error.
Also on using "Image.from_FULL_LOCAL_PATHL(Utils.getAppRoot()", I am getting
the error.
Please help me in getting the solution.
Waiting for reply.
Regards
Original comment by ankur881...@gmail.com
on 12 Oct 2011 at 4:02
In order to prove that works, try some image inside your intranet network, or
some image in your local tomcat "localhost:8080/myimage.png"
Btw "java.net.ConnectException: Connection refused: connect" has nothing to do
with java2word. It could be firewall, proxy...
Image works fine except under proxy but this is environment issue. Can you do
the first thing just to prove that works?
Original comment by leonardo...@gmail.com
on 12 Oct 2011 at 4:26
After implementing your change, I have this piece of code:
import java.io.File;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import word.api.interfaces.IDocument;
import word.w2004.Document2004;
import word.w2004.Document2004.Encoding;
import word.w2004.elements.BreakLine;
import word.w2004.elements.Heading1;
import word.w2004.elements.Image;
import com.nated.framework.exception.NatEdException;
public class InsertImage {
static Logger logger = Logger.getLogger(InsertImage.class.getName());
public static void main (String[] args){
IDocument myDoc = null;
File newDocument = new File("C:\\Insert_Image.doc");
PrintWriter writer = null;
try {
logger.log(Level.INFO, "main() starts");
writer = new PrintWriter(newDocument);
myDoc = new Document2004();
myDoc.encoding(Encoding.UTF_8);
myDoc.addEle(BreakLine.times(1).create());
myDoc.addEle(Heading1.with("Insert Image Details").create());
//myDoc.getBody().addEle(Utils.getAppRoot() + "\\wss.jpg");
myDoc.addEle(Image.from_WEB_URL("http://localhost/apache_pb.png").setHeight("40").setWidth("80").create());
String text = myDoc.getContent();
writer.println(text);
writer.close();
}catch (Exception exception) {
if (!(exception instanceof NatEdException)) {
exception.printStackTrace();
}
} finally {
logger.log(Level.INFO, "main() ends");
}
}
}
------------------------------------------------------------------------------
But Now I have this error:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/thoughtworks/xstream/core/util/Base64Encoder
at word.utils.ImageUtils.getImageHexaBase64(ImageUtils.java:26)
at word.w2004.elements.Image.getContent(Image.java:89)
at word.w2004.Body2004.addEle(Body2004.java:16)
at word.w2004.Document2004.addEle(Document2004.java:110)
at InsertImage.main(InsertImage.java:37)
---------------------------------------------------------------------
Please let me know where I am wrong. This error is also getting generated on
using Image from local path.
Original comment by ankur881...@gmail.com
on 12 Oct 2011 at 4:43
[deleted comment]
this one is easy: http://code.google.com/p/java2word/#WITHOUT_Maven?
You need xstream in your classpath.
See if now you can see the image on the doc
cheers
Leonardo
Original comment by leonardo...@gmail.com
on 12 Oct 2011 at 6:05
Thanks for the solution, now its working fine with images in the range of
localhost.
But still the connection error persist with outside localhost images, even on
removing the proxy.
Please help me in this as it is very necessary to get images outside the
localhost.
Also specify your way of removing proxy, may be I am wrong in that too.
Waiting for reply.
Regards
Original comment by ankur881...@gmail.com
on 12 Oct 2011 at 7:20
maybe try this at the beginning of the method:
System.setProperty("http.proxyHost", "your proxy here")
System.setProperty("http.proxyHost", "8080")
I never tried but this is how you set up proxies in Java.
It definitely works when you are directly connected in the internet.
If you find out how to set up proxy, I can add to the library... something like:
myDocument.setProxyHost();
then everything inside the document that does network will use the proxy
settings...
give it a try.
Leonardo
Original comment by leonardo...@gmail.com
on 12 Oct 2011 at 10:37
Original comment by leonardo...@gmail.com
on 2 Feb 2012 at 12:25
HI
bellow is the code i am trying to execute. but iam getting
Exception in thread "Main Thread" java.lang.NoClassDefFoundError:
com/thoughtworks/xstream/core/util/Base64Encoder
at word.utils.ImageUtils.getImageHexaBase64(ImageUtils.java:26)
at word.w2004.elements.Image.getContent(Image.java:88)
at WordImage.main(WordImage.java:37)
Kindly help me in sorting out the problem
Original comment by sirisha....@gmail.com
on 27 Jul 2012 at 12:39
Attachments:
Original issue reported on code.google.com by
ankur881...@gmail.com
on 11 Oct 2011 at 12:24Attachments: