• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to remove exception

 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the line that tells you what the problem is:
java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1TaggedObject
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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');)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic