You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by Werner Dittmann <We...@t-online.de> on 2005/04/17 08:39:20 UTC

Re: Problem with loadClass in

Hi,

I'm puzzeld about your statment:

I didn't know how to configure Merlin jca provider libraries.

Well, Merlin is not a JCA provider. Merlin contains helper and
other mehtodes to simplify handling of certificates and other
keystore functions. Merlin in turn uses BouncyCastle to access
a keystore (BouncyCastle has the keystore primitives).

It may helpful if youn can post some mor info about how you use WSS4J
and maybe the code or code snippet so that we can better see what
happens.

Regards,
Werner

abb x schrieb:

>Hello, I am trying use WSS4J for the first time.
>However, I am stuck at loading correct key store and
>JCA implementation. I really appreciate your help.
>
>When I use following line to configure and load,
>
>Crypto crypto =
>CryptoFactory.getInstance("crypto.properties");
>
>crypto.properties file looks like:
>
>org.apache.ws.security.crypto.provider=org.bouncycastle.jce.provider.BouncyCastleProvider
>org.apache.ws.security.crypto.BouncyCastleProvider.keystore.type=JKS
>org.apache.ws.security.crypto.BouncyCastleProvider.keystore.password=password
>org.apache.ws.security.crypto.BouncyCastleProvider.keystore.alias=16c73ab6-b892-458f-abf5-2f875f74882e
>org.apache.ws.security.crypto.BouncyCastleProvider.alias.password=password
>org.apache.ws.security.crypto.BouncyCastleProvider.file=C:\security\certificate\test.jks
>
>
>Trying to find [crypto.properties] using
>sun.misc.Launcher$AppClassLoader@53ba3d class loader.
>java.lang.NoSuchMethodException:
>org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(java.util.Properties)
>Using Crypto Engine
>[org.bouncycastle.jce.provider.BouncyCastleProvider]
>	at java.lang.Class.getConstructor0(Class.java:1937)
>	at java.lang.Class.getConstructor(Class.java:1027)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:116)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>java.lang.ClassCastException
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>java.lang.RuntimeException:
>org.bouncycastle.jce.provider.BouncyCastleProvider
>cannot create instance
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:130)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)Unable
>to instantiate (1):
>org.bouncycastle.jce.provider.BouncyCastleProvider
>java.lang.NoSuchMethodException:
>org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(java.util.Properties)
>	at java.lang.Class.getConstructor0(Class.java:1937)
>	at java.lang.Class.getConstructor(Class.java:1027)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:116)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>Unable to instantiate (2):
>org.bouncycastle.jce.provider.BouncyCastleProvider
>java.lang.ClassCastException
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>
>
>
>if I use the existing configuration with following
>properties file
>
>org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
>org.apache.ws.security.crypto.merlin.keystore.type=JKS
>org.apache.ws.security.crypto.merlin.keystore.password=password
>org.apache.ws.security.crypto.merlin.keystore.alias=16c73ab6-b892-458f-abf5-2f875f74882e
>org.apache.ws.security.crypto.merlin.alias.password=password
>org.apache.ws.security.crypto.merlin.file=C:\security\certificate\test.jks
>
>
>I get the following error:
>Using Crypto Engine
>[org.apache.ws.security.components.crypto.Merlin]
>java.lang.reflect.InvocationTargetException
>	at
>sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>Method)
>	at
>sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>	at
>sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>	at
>java.lang.reflect.Constructor.newInstance(Constructor.java:274)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:117)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>Caused by: java.lang.ExceptionInInitializerError
>	at
>org.apache.ws.security.components.crypto.Merlin.<init>(Merlin.java:108)
>	... 8 more
>Caused by: java.lang.RuntimeException: Can't find
>bundle for base name
>org.apache.ws.security.components.crypto.errors,
>locale en_US
>	at
>org.apache.ws.security.components.crypto.CredentialException.<clinit>(CredentialException.java:43)
>	... 9 more
>java.lang.InstantiationException:
>org.apache.ws.security.components.crypto.Merlin
>	at java.lang.Class.newInstance0(Class.java:293)
>	at java.lang.Class.newInstance(Class.java:261)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
>Unable to instantiate (1):
>org.apache.ws.security.components.crypto.Merlin
>java.lang.reflect.InvocationTargetException
>	at
>sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>Method)
>	at
>sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>	at
>sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>	at
>java.lang.reflect.Constructor.newInstance(Constructor.java:274)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:117)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>Caused by: java.lang.ExceptionInInitializerError
>	at
>org.apache.ws.security.components.crypto.Merlin.<init>(Merlin.java:108)
>	... 8 more
>Caused by: java.lang.RuntimeException: Can't find
>bundle for base name
>org.apache.ws.security.components.crypto.errors,
>locale en_US
>	at
>org.apache.ws.security.components.crypto.CredentialException.<clinit>(CredentialException.java:43)
>	... 9 more
>Unable to instantiate (2):
>org.apache.ws.security.components.crypto.Merlin
>java.lang.InstantiationException:
>org.apache.ws.security.components.crypto.Merlin
>	at java.lang.Class.newInstance0(Class.java:293)
>	at java.lang.Class.newInstance(Class.java:261)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>java.lang.RuntimeException:
>org.apache.ws.security.components.crypto.Merlin cannot
>create instance
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:130)
>	at
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
>	at jca.WSSecurity.encrypt(WSSecurity.java:81)
>	at jca.WSSecurity.main(WSSecurity.java:201)
>
>
>Ofcourse for the latter case, I didn't know how to
>configure Merlin jca provider libraries.
>
>Any help is really appreciated.
>
>Thank you.
>
>- Abb
>
>
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Mail - 250MB free storage. Do more. Manage less. 
>http://info.mail.yahoo.com/mail_250
>
>  
>


Re: Problem with loadClass in

Posted by abb x <ax...@yahoo.com>.
Thanks for the quick reply.
I am trying to run the sample example given at
http://ws.apache.org/ws-fx/wss4j/api.html#Examples

This is the procedure I followed
1. Downloaded Crypto library from
http://www.bouncycastle.org for JDK1.4 i.e.
bcprov-jdk14-127.jar

2. Placed it in jre\lib\ext  folder
3. Removed the default sun library sunjce_provider.jar
4. Modified the java.security file to provide
reference to new libraries and made it the default
provider. Added following line
security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider

5. modified crypto.properties file to reflect this
changes. Used following defaults
org.apache.ws.security.crypto.provider=org.bouncycastle.jce.provider.BouncyCastleProvider
org.apache.ws.security.crypto.BouncyCastleProvider.keystore.type=JKS
org.apache.ws.security.crypto.BouncyCastleProvider.keystore.password=password
org.apache.ws.security.crypto.BouncyCastleProvider.keystore.alias=16c73ab6-b892-458f-abf5-2f875f74882e
org.apache.ws.security.crypto.BouncyCastleProvider.alias.password=password
org.apache.ws.security.crypto.BouncyCastleProvider.file=C:\security\certificate\test.jks

And I get following stack trace
Trying to find [crypto.properties] using
sun.misc.Launcher$AppClassLoader@53ba3d class loader.
java.lang.NoSuchMethodException:
org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(java.util.Properties)
Using Crypto Engine
[org.bouncycastle.jce.provider.BouncyCastleProvider]
	at java.lang.Class.getConstructor0(Class.java:1937)
	at java.lang.Class.getConstructor(Class.java:1027)
	at
org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:116)
	at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
	at jca.WSSecurity.encrypt(WSSecurity.java:81)
	at jca.WSSecurity.main(WSSecurity.java:192)
Unable to instantiate (1):
org.bouncycastle.jce.provider.BouncyCastleProvider
java.lang.NoSuchMethodException:
org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(java.util.Properties)
	at java.lang.Class.getConstructor0(Class.java:1937)
	at java.lang.Class.getConstructor(Class.java:1027)
	at
org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:116)
	at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
	at jca.WSSecurity.encrypt(WSSecurity.java:81)
	at jca.WSSecurity.main(WSSecurity.java:192)
Unable to instantiate (2):
org.bouncycastle.jce.provider.BouncyCastleProvider
java.lang.ClassCastException
	at
org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
	at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
	at jca.WSSecurity.encrypt(WSSecurity.java:81)
	at jca.WSSecurity.main(WSSecurity.java:192)
java.lang.ClassCastException
	at
org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
	at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
	at jca.WSSecurity.encrypt(WSSecurity.java:81)
	at jca.WSSecurity.main(WSSecurity.java:192)
java.lang.RuntimeException:
org.bouncycastle.jce.provider.BouncyCastleProvider
cannot create instance
	at
org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:130)
	at
org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
	at jca.WSSecurity.encrypt(WSSecurity.java:81)
	at jca.WSSecurity.main(WSSecurity.java:192)


Do you know what I might be doing wrong? 

Thanks again for your response!
Abb
--- Werner Dittmann <We...@t-online.de>
wrote:

> Hi,
> 
> I'm puzzeld about your statment:
> 
> I didn't know how to configure Merlin jca provider
> libraries.
> 
> Well, Merlin is not a JCA provider. Merlin contains
> helper and
> other mehtodes to simplify handling of certificates
> and other
> keystore functions. Merlin in turn uses BouncyCastle
> to access
> a keystore (BouncyCastle has the keystore
> primitives).
> 
> It may helpful if youn can post some mor info about
> how you use WSS4J
> and maybe the code or code snippet so that we can
> better see what
> happens.
> 
> Regards,
> Werner
> 
> abb x schrieb:
> 
> >Hello, I am trying use WSS4J for the first time.
> >However, I am stuck at loading correct key store
> and
> >JCA implementation. I really appreciate your help.
> >
> >When I use following line to configure and load,
> >
> >Crypto crypto =
> >CryptoFactory.getInstance("crypto.properties");
> >
> >crypto.properties file looks like:
> >
>
>org.apache.ws.security.crypto.provider=org.bouncycastle.jce.provider.BouncyCastleProvider
>
>org.apache.ws.security.crypto.BouncyCastleProvider.keystore.type=JKS
>
>org.apache.ws.security.crypto.BouncyCastleProvider.keystore.password=password
>
>org.apache.ws.security.crypto.BouncyCastleProvider.keystore.alias=16c73ab6-b892-458f-abf5-2f875f74882e
>
>org.apache.ws.security.crypto.BouncyCastleProvider.alias.password=password
>
>org.apache.ws.security.crypto.BouncyCastleProvider.file=C:\security\certificate\test.jks
> >
> >
> >Trying to find [crypto.properties] using
> >sun.misc.Launcher$AppClassLoader@53ba3d class
> loader.
> >java.lang.NoSuchMethodException:
>
>org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(java.util.Properties)
> >Using Crypto Engine
>
>[org.bouncycastle.jce.provider.BouncyCastleProvider]
> >	at
> java.lang.Class.getConstructor0(Class.java:1937)
> >	at java.lang.Class.getConstructor(Class.java:1027)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:116)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >java.lang.ClassCastException
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >java.lang.RuntimeException:
> >org.bouncycastle.jce.provider.BouncyCastleProvider
> >cannot create instance
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:130)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)Unable
> >to instantiate (1):
> >org.bouncycastle.jce.provider.BouncyCastleProvider
> >java.lang.NoSuchMethodException:
>
>org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(java.util.Properties)
> >	at
> java.lang.Class.getConstructor0(Class.java:1937)
> >	at java.lang.Class.getConstructor(Class.java:1027)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:116)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >Unable to instantiate (2):
> >org.bouncycastle.jce.provider.BouncyCastleProvider
> >java.lang.ClassCastException
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >
> >
> >
> >if I use the existing configuration with following
> >properties file
> >
>
>org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
>
>org.apache.ws.security.crypto.merlin.keystore.type=JKS
>
>org.apache.ws.security.crypto.merlin.keystore.password=password
>
>org.apache.ws.security.crypto.merlin.keystore.alias=16c73ab6-b892-458f-abf5-2f875f74882e
>
>org.apache.ws.security.crypto.merlin.alias.password=password
>
>org.apache.ws.security.crypto.merlin.file=C:\security\certificate\test.jks
> >
> >
> >I get the following error:
> >Using Crypto Engine
> >[org.apache.ws.security.components.crypto.Merlin]
> >java.lang.reflect.InvocationTargetException
> >	at
>
>sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >Method)
> >	at
>
>sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> >	at
>
>sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> >	at
>
>java.lang.reflect.Constructor.newInstance(Constructor.java:274)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:117)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >Caused by: java.lang.ExceptionInInitializerError
> >	at
>
>org.apache.ws.security.components.crypto.Merlin.<init>(Merlin.java:108)
> >	... 8 more
> >Caused by: java.lang.RuntimeException: Can't find
> >bundle for base name
> >org.apache.ws.security.components.crypto.errors,
> >locale en_US
> >	at
>
>org.apache.ws.security.components.crypto.CredentialException.<clinit>(CredentialException.java:43)
> >	... 9 more
> >java.lang.InstantiationException:
> >org.apache.ws.security.components.crypto.Merlin
> >	at java.lang.Class.newInstance0(Class.java:293)
> >	at java.lang.Class.newInstance(Class.java:261)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
> >Unable to instantiate (1):
> >org.apache.ws.security.components.crypto.Merlin
> >java.lang.reflect.InvocationTargetException
> >	at
>
>sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >Method)
> >	at
>
>sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> >	at
>
>sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> >	at
>
>java.lang.reflect.Constructor.newInstance(Constructor.java:274)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:117)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >Caused by: java.lang.ExceptionInInitializerError
> >	at
>
>org.apache.ws.security.components.crypto.Merlin.<init>(Merlin.java:108)
> >	... 8 more
> >Caused by: java.lang.RuntimeException: Can't find
> >bundle for base name
> >org.apache.ws.security.components.crypto.errors,
> >locale en_US
> >	at
>
>org.apache.ws.security.components.crypto.CredentialException.<clinit>(CredentialException.java:43)
> >	... 9 more
> >Unable to instantiate (2):
> >org.apache.ws.security.components.crypto.Merlin
> >java.lang.InstantiationException:
> >org.apache.ws.security.components.crypto.Merlin
> >	at java.lang.Class.newInstance0(Class.java:293)
> >	at java.lang.Class.newInstance(Class.java:261)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.loadClass(CryptoFactory.java:125)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >	at
>
>org.apache.ws.security.components.crypto.CryptoFactory.getInstance(CryptoFactory.java:101)
> >	at jca.WSSecurity.encrypt(WSSecurity.java:81)
> >	at jca.WSSecurity.main(WSSecurity.java:201)
> >java.lang.RuntimeException:
> >org.apache.ws.security.components.crypto.Merlin
> cannot
> >create instance
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs