You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by "Jozef Aerts - Comp.Chem.Cons. - XML4Pharma" <co...@hotmail.com> on 2002/10/06 16:55:46 UTC

nullpointer exception in sig.sign(privateKey) of CreateSignature example

Hi, I am currently learning about XML-signatures.

I successfully could do the CreateSignature example.
When I then try to implement the code into my own Java software as a 
JavaBean, I had to add a good number try-catch constructs.
No problem, it also gave me a very good opportunity for debugging.

When running (using a real XML document), everything runs fines, but just at 
one of the last statements: sig.sign(privateKey) I get a 
nullpointerexception.
However, neither sig, nor privateKey are null at that moment.
So something else is wrong.

Can someone explain what the reason for the nullpointerexception might be ?

Many thanks in advance

Jozef Aerts
XML4Pharma

code snippet:

try {
          System.out.println("Signing in progres ...");
          System.out.println("sig = " + sig);
          System.out.println("private key = " + privateKey);
          sig.sign(privateKey);
          System.out.println("Signed ...");
         } catch (XMLSignatureException XSige) {
          System.out.println("XMLSignatureException" + XSige);
         } catch (Exception e) {
          System.out.println("other signing exception = " + e);
         }

and its output:

Signing in progres ...

sig = org.apache.xml.security.signature.XMLSignature@19a8416

private key = Sun DSA Private Key
parameters:DSA
	p:     fd7f5381 1d751229 52df4a9c 2eece4e7 f611b752 3cef4400 c31e3f80 
b6512669
    455d4022 51fb593d 8d58fabf c5f5ba30 f6cb9b55 6cd7813b 801d346f f26660b7
    6b9950a5 a49f9fe8 047b1022 c24fbba9 d7feb7c6 1bf83b57 e7c6a8a6 150f04fb
    83f6d3c5 1ec30235 54135a16 9132f675 f3ae2b61 d72aeff2 2203199d d14801c7
	q:     9760508f 15230bcc b292b982 a2eb840b f0581cf5
	g:     f7e1a085 d69b3dde cbbcab5c 36b857b9 7994afbb fa3aea82 f9574c0b 
3d078267
    5159578e bad4594f e6710710 8180b449 167123e8 4c281613 b7cf0932 8cc8a6e1
    3c167a8b 547c8d28 e0a3ae1e 2bb3a675 916ea37f 0bfa2135 62f1fb62 7a01243b
    cca4f1be a8519089 a883dfe1 5ae59f06 928b665e 807b5525 64014c3b fecf492a

x:     4002af60 b9de0b7b f831974d 3107a471 57a386af


other signing exception = java.lang.NullPointerException



_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


Re: nullpointer exception in sig.sign(privateKey) of CreateSignature example

Posted by Tom Oehser <to...@toms.net>.
You should be able to get a stack trace or line number, just knowing
that it is an NPE is not very useful, that is about the most common
error in all of Java... -Tom

On Sun, 6 Oct 2002, Jozef Aerts - Comp.Chem.Cons. - XML4Pharma wrote:

> Date: Sun, 06 Oct 2002 14:55:46 +0000
> From: Jozef Aerts - Comp.Chem.Cons. - XML4Pharma
>     <co...@hotmail.com>
> To: security-dev@xml.apache.org
> Subject: nullpointer exception in sig.sign(privateKey) of CreateSignature
>     example
>
>
> Hi, I am currently learning about XML-signatures.
>
> I successfully could do the CreateSignature example.
> When I then try to implement the code into my own Java software as a
> JavaBean, I had to add a good number try-catch constructs.
> No problem, it also gave me a very good opportunity for debugging.
>
> When running (using a real XML document), everything runs fines, but just at
> one of the last statements: sig.sign(privateKey) I get a
> nullpointerexception.
> However, neither sig, nor privateKey are null at that moment.
> So something else is wrong.
>
> Can someone explain what the reason for the nullpointerexception might be ?
>
> Many thanks in advance
>
> Jozef Aerts
> XML4Pharma
>
> code snippet:
>
> try {
>           System.out.println("Signing in progres ...");
>           System.out.println("sig = " + sig);
>           System.out.println("private key = " + privateKey);
>           sig.sign(privateKey);
>           System.out.println("Signed ...");
>          } catch (XMLSignatureException XSige) {
>           System.out.println("XMLSignatureException" + XSige);
>          } catch (Exception e) {
>           System.out.println("other signing exception = " + e);
>          }
>
> and its output:
>
> Signing in progres ...
>
> sig = org.apache.xml.security.signature.XMLSignature@19a8416
>
> private key = Sun DSA Private Key
> parameters:DSA
> 	p:     fd7f5381 1d751229 52df4a9c 2eece4e7 f611b752 3cef4400 c31e3f80
> b6512669
>     455d4022 51fb593d 8d58fabf c5f5ba30 f6cb9b55 6cd7813b 801d346f f26660b7
>     6b9950a5 a49f9fe8 047b1022 c24fbba9 d7feb7c6 1bf83b57 e7c6a8a6 150f04fb
>     83f6d3c5 1ec30235 54135a16 9132f675 f3ae2b61 d72aeff2 2203199d d14801c7
> 	q:     9760508f 15230bcc b292b982 a2eb840b f0581cf5
> 	g:     f7e1a085 d69b3dde cbbcab5c 36b857b9 7994afbb fa3aea82 f9574c0b
> 3d078267
>     5159578e bad4594f e6710710 8180b449 167123e8 4c281613 b7cf0932 8cc8a6e1
>     3c167a8b 547c8d28 e0a3ae1e 2bb3a675 916ea37f 0bfa2135 62f1fb62 7a01243b
>     cca4f1be a8519089 a883dfe1 5ae59f06 928b665e 807b5525 64014c3b fecf492a
>
> x:     4002af60 b9de0b7b f831974d 3107a471 57a386af
>
>
> other signing exception = java.lang.NullPointerException
>
>
>
> _________________________________________________________________
> Join the world�s largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
>