on 07-12-2011 4:45 PM
Hello,
We have a report to produce using IText API
Everything is fine in test phase but few days ago we tryied to test the report using the server name ALIAS and we get error 😕
Server returned HTTP error code 503, I search in the net and I found that it's due to a temporary inavailability of the server but It still not working so we tried to find another solution :
I used the code below :
//url is the dynamically generated url of the image.
java.awt.Image awtImg = java.awt.Toolkit.getDefaultToolkit().createImage(url);
//I get error here
com.lowagie.text.Image image2 = com.lowagie.text.Image.getInstance(awtImg, null);
document.add(image2);
but I get the following error : java.awt.Image fetch aborted or errored
I search in the internet, too many people asking the same question but no one seems to have the answer
(people facing the same problem say that the problem is due to the fact that we have an url in parameter).
When I try to access the image on the server using the generated url (copy paste to the browser), it works, I can see the image.
Any ideas? Any suggestions?
It's really important.
Thanks in advance for your help.
Edited by: ImaneA on Jul 12, 2011 5:46 PM
Hi ImaneA,
I think the problem is due to load balancer, the server might have mutiple server nodes(instances).
When you are trying to access the image on the server using URL, the request might have gone and hit the server which is not avialable(inactive) so you are getting the error message "HTTP error code 503".
Its not advised to read the image through URL, if the server has mutileple server instances.
Instead of this you can read the image from a KM repository, which is very effective in performance wise and cache problem will not be there.
Otherwise you have to store the image in the database as a BLOB oject and read the image from Databse
Just check wether this 2 options will be a feasible solution or not.
Regards,
Saleem Mohammad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Saleem Mohammed,
Thanks a lot for your reply.
For the storage of image in database, I'm not sure that we can do that but for using the image from KM, I'll try it on a server which have a unique node.
When you say "read image from KM", you mean hardcode the KM image url, is that right?
For the http code error 503, I got it when using the code below :
com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(url);
document.add(image);
The code I've mentionned in my previous post returned the error : java.awt.Image fetch aborted or errored
Again, thanks a lot for your help.
PS : I've assigned points
Edited by: ImaneA on Jul 13, 2011 9:48 AM
hi ImaneA,
While reading the file from KM repository means, you have to keep the image in root directory and its not a hardcoded URL.
I don't think you will face any problems with this approach.
//Reading the image from root directory
RID pathRID = RID.getRID("/documents/SDN"); //Root Directory
Go through this link if you want to read the image from KM...
Hope this helps you.
Regards,
Saleem Mohammad
Hello Saleem Mohammed,
Our problem is solved thanks to you
For the example you give me in your last post, I'm not using WDJ, I'm using a portal component, it's full java.
You were right about the instances, I added a condition in my method ( the one which build the url path) to change the name of the server alias with the servername.
The names are hardcoded, this is the best solution we could get and it's working.
Thanks a lot for your valuable help
Best regards,
Imane.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.