| Author |
how to remove exception
|
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
what is the cause of this exception.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1TaggedObject
com.itextpdf.text.pdf.PdfSignatureAppearance.getAppearance(PdfSignatureAppearance.java:409)
com.itextpdf.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:950)
com.itextpdf.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance.java:897)
com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:192)
archana.digital.doGet(digital.java:81)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.16
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
This is the line that tells you what the problem is:
java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1TaggedObject
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
Bear is correct.
You need to add the jar containing org/bouncycastle/asn1/ASN1TaggedObject to WEB-INF/lib
or the application server's CLASSPATH
WP
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
William P O'Sullivan wrote:Bear is correct.
You need to add the jar containing org/bouncycastle/asn1/ASN1TaggedObject to WEB-INF/lib
or the application server's CLASSPATH
WP
I have added jar files but when i run my program in tomcat server ,it shows blank page in the web browser...it is not giving any output.....
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
Sounds like it's not completing the path back to the view.
Is it forwarding/redirecting?
Is it a servlet designed to write back HTML, and doesn't?
Too little information to help.
debug mode is your friend.
WP
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
William P O'Sullivan wrote:Sounds like it's not completing the path back to the view.
Is it forwarding/redirecting?
Is it a servlet designed to write back HTML, and doesn't?
Too little information to help.
debug mode is your friend.
WP
I am using the following code to generate the digitally signed pdf in web browser........but neither the output is displayed nor any exception..
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
All this tells me is that you've signed an existing PDF document.
Where to you send it back to browser in here?
There is no HTTP response to be seen. Of course you will get a blank screen.
Do you think the servlet will magically decode what you are attempting to do?
WP
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
William P O'Sullivan wrote:All this tells me is that you've signed an existing PDF document.
Where to you send it back to browser in here?
There is no HTTP response to be seen. Of course you will get a blank screen.
Do you think the servlet will magically decode what you are attempting to do?
WP
I am not getting what you want to say.....please tell me in detail
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
You said that requesting that servlet results in a blank page in the browser.
And when you showed us your code, it was apparent that it didn't write anything to the response. A blank page is an accurate representation of nothing, so that is perfectly normal.
But you seem to want something to appear in the browser. So here's a detailed explanation of what you should do:
(1) Decide what you want to appear in the browser after that processing is finished.
(2) Write code which sends that data to the servlet's response.
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
Paul Clapham wrote:You said that requesting that servlet results in a blank page in the browser.
And when you showed us your code, it was apparent that it didn't write anything to the response. A blank page is an accurate representation of nothing, so that is perfectly normal.
But you seem to want something to appear in the browser. So here's a detailed explanation of what you should do:
(1) Decide what you want to appear in the browser after that processing is finished.
(2) Write code which sends that data to the servlet's response.
then what should i do for that....i want signed pdf in response in the given coding so what should i try.
|
 |
James Boswell
Ranch Hand
Joined: Nov 09, 2011
Posts: 657
|
|
|
Have you searched online for something along the lines of "servlet to serve up pdf"? Or do you want someone else to do that for you as well?
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
rakhi sinha wrote:then what should i do for that....i want signed pdf in response in the given coding so what should i try.
You wrote the signed PDF to a file in your web application. Was that because you needed the signed PDF to be a file in your web application, or because your code was based on some example code which wrote the signed PDF to a file?
At any rate what you should do is to set up the headers which say the response is a PDF (instead of HTML), and write the signed PDF to the response. You would write the signed PDF to the response either by writing it there instead of to that file, or by copying from that file to the response. That depends on the answer to my first question.
I really think you need to consider your requirements before writing code. Or at least, when asking questions here you ought to know what your requirements are so we don't have to keep asking you about them.
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
Paul Clapham wrote:
rakhi sinha wrote:then what should i do for that....i want signed pdf in response in the given coding so what should i try.
You wrote the signed PDF to a file in your web application. Was that because you needed the signed PDF to be a file in your web application, or because your code was based on some example code which wrote the signed PDF to a file?
At any rate what you should do is to set up the headers which say the response is a PDF (instead of HTML), and write the signed PDF to the response. You would write the signed PDF to the response either by writing it there instead of to that file, or by copying from that file to the response. That depends on the answer to my first question.
I really think you need to consider your requirements before writing code. Or at least, when asking questions here you ought to know what your requirements are so we don't have to keep asking you about them.
please tell me how to write in the response...actually i have generated simple pdf in the web browser.....but i want that pdf digitally signed....
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
There's your starting point ...
How did you generate the simple pdf?
Now what is different between the simple and the signed?
WP
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
rakhi sinha wrote:please tell me how to write in the response...actually i have generated simple pdf in the web browser.....but i want that pdf digitally signed....
Can I suggest that, instead of just quoting what I posted, you should read it?
I asked you some questions there. Without answers to those questions it's impossible to proceed.
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
William P O'Sullivan wrote:There's your starting point ...
How did you generate the simple pdf?
Now what is different between the simple and the signed?
WP
there is no difference but i wrote whole pdf coding to generate the simple pdf but i dont know how to add the signature field in that pdf because in mentioned coding i have used the path of unsigned pdf then generate the signed pdf and in simple pdf i have created the pdf using itext..so waht shou;d i do for that
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
rakhi sinha wrote:
William P O'Sullivan wrote:There's your starting point ...
How did you generate the simple pdf?
Now what is different between the simple and the signed?
WP
there is no difference but i wrote whole pdf coding to generate the simple pdf but i dont know how to add the signature field in that pdf because in mentioned coding i have used the path of unsigned pdf then generate the signed pdf and in simple pdf i have created the pdf using itext..so waht shou;d i do for that
I have generated the simple pdf as follow
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
We don't see these lines in your "signed" version.
How can you expect to send a pdf if you don't do this as well.
You are close, just missing some simple logical analysis of what you are doing wrong (or not doing at all)
Pat.
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
William P O'Sullivan wrote:
We don't see these lines in your "signed" version.
How can you expect to send a pdf if you don't do this as well.
You are close, just missing some simple logical analysis of what you are doing wrong (or not doing at all)
Pat.
In the following code i am giving the path of pdf on which i have to sign but i want to sign that pdf i have generated originally then what should i write in pplace of reader and os because i am using the following code in the pdf creation code .....
PdfReader reader = new PdfReader(getServletContext().getRealPath("/resources/a.pdf"));
FileOutputStream os = new FileOutputStream(getServletContext().getRealPath("/resources/signed.pdf"));
PdfStamper stamper = null;
try {
stamper = PdfStamper.createSignature(reader, os, '\0');
} catch (DocumentException e) {
e.printStackTrace();
}
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED);
appearance.setReason("It's personal.");
appearance.setLocation("Foobar");
appearance.setVisibleSignature(new Rectangle(160,732,232,780), 1, null);
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
Step back for a second ...
You can send a pdf to the browser after setting response types and assigning the outputStream for the servlet to PDFWriter.
Why not open a PDFWriter as you do for the unsigned one, use PDFReader for the signed and send it out as you do the other.
WP
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
William P O'Sullivan wrote:Step back for a second ...
You can send a pdf to the browser after setting response types and assigning the outputStream for the servlet to PDFWriter.
Why not open a PDFWriter as you do for the unsigned one, use PDFReader for the signed and send it out as you do the other.
WP
Please can you tell me in detail that where should i make changes in my code.......
what should i write in place of reader and os in (stamper = PdfStamper.createSignature(reader,os, '\0');)
|
 |
 |
|
|
subject: how to remove exception
|
|
|