Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34316/#msg_34316
Originally posted by: massimiliano.ziccardi.gmail.com
Hi All.
I'm quite new to eclipse plugins.
I wrote a plugin and had no problem.
Now I need to use some BouncyCastle classes, so I added the
bouncycastle jars inside the jre/lib/ext directory and configured the
provider inside the java.security file.
In my RCP.product file, I configured the JRE Name (Launching TAB) so
that my JRE with Bouncycastle will be embedded inside my product.
I've exported the application and verified that the jre/lib/ext is ok:
it's ok.
However, when I execute some of my plugin functions, I get this:
java.lang.NoClassDefFoundError:
org/bouncycastle/jce/provider/BouncyCastleProvider
at
it.intesa.tstation.plugins.etsi.keystore.pkcs12.preferences. P12ConfigDialogContent$2.widgetSelected(P12ConfigDialogConte nt.java:101)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:228)
at
org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1158)
.....
and, the important part (I think):
Caused by: java.lang.ClassNotFoundException:
org.bouncycastle.jce.provider.BouncyCastleProvider
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl assInternal(BundleLoader.java:481)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:397)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:385)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
Do you have any idea about what I miss?
Thanks in advance,
Massimiliano Ziccardi]]>2008-11-25T12:15:24-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585802/#msg_585802
Originally posted by: ziccardi.email.it
Hi all. I made one step forward.
I tried to instantiate the BouncyCastleProvider directly inside my
plugin (i.e. new BouncyCastleProvider()).
Now I get a compile error saying:
"
The constructor BouncyCastleProvider() is not accessible due to
restriction to the require library...
"
How can I change this restrictions?
Many thanks,
Massimiliano]]>2008-11-25T15:29:52-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34386/#msg_34386
Originally posted by: ziccardi.email.it
Hi all. I made one step forward.
I tried to instantiate the BouncyCastleProvider directly inside my
plugin (i.e. new BouncyCastleProvider()).
Now I get a compile error saying:
"
The constructor BouncyCastleProvider() is not accessible due to
restriction to the require library...
"
How can I change this restrictions?
Many thanks,
Massimiliano]]>2008-11-25T15:29:52-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585812/#msg_585812
did you specify the package of BouncyCastleProvider as Export-Packages /
Import-Packages in your Manifests?
Regards,
Stefan.
ziccardi schrieb:
>
> Hi all. I made one step forward.
>
> I tried to instantiate the BouncyCastleProvider directly inside my
> plugin (i.e. new BouncyCastleProvider()).
>
> Now I get a compile error saying:
> "
> The constructor BouncyCastleProvider() is not accessible due to
> restriction to the require library...
> "
>
> How can I change this restrictions?
>
> Many thanks,
> Massimiliano]]>Stefan 2008-11-25T15:54:02-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34420/#msg_34420
did you specify the package of BouncyCastleProvider as Export-Packages /
Import-Packages in your Manifests?
Regards,
Stefan.
ziccardi schrieb:
>
> Hi all. I made one step forward.
>
> I tried to instantiate the BouncyCastleProvider directly inside my
> plugin (i.e. new BouncyCastleProvider()).
>
> Now I get a compile error saying:
> "
> The constructor BouncyCastleProvider() is not accessible due to
> restriction to the require library...
> "
>
> How can I change this restrictions?
>
> Many thanks,
> Massimiliano]]>Stefan 2008-11-25T15:54:02-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585824/#msg_585824
Originally posted by: massimiliano.ziccardi.gmail.com
Hi Stephan!
Thank you very much for your help.
I tried to export the packages as you told, but I cannot see them (when
I click on Add, the bouncycastle packages are not shown).
I even tried to add the bouncycastle's library inside the plugin, than
I've been able to export the packages.
This way it worked, except the fact that the library has been loaded by
two different classloaders (infact it is inside the jre/lib/ext and
inside the plugin): this way I got :
cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
What do I still make wrong?
Thank you!,
Massimiliano]]>2008-11-25T16:11:49-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34454/#msg_34454
Originally posted by: massimiliano.ziccardi.gmail.com
Hi Stephan!
Thank you very much for your help.
I tried to export the packages as you told, but I cannot see them (when
I click on Add, the bouncycastle packages are not shown).
I even tried to add the bouncycastle's library inside the plugin, than
I've been able to export the packages.
This way it worked, except the fact that the library has been loaded by
two different classloaders (infact it is inside the jre/lib/ext and
inside the plugin): this way I got :
cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
What do I still make wrong?
Thank you!,
Massimiliano]]>2008-11-25T16:11:49-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585833/#msg_585833
the setting should look like this:
Bundle A (containing BouncyCastleProvider)
Export-Package: org.bouncycastle.jce.provider
Bundle B (referencing BouncyCastleProvider)
Import-Package: org.bouncycastle.jce.provider
Maybe, there are additional packages which are indirectly referenced by
BouncyCastleProvider which you have to add to both lists.
Now, you should have no classloader issues any more.
Regards, Stefan.
ziccardi schrieb:
> Hi Stephan!
>
> Thank you very much for your help.
>
> I tried to export the packages as you told, but I cannot see them (when
> I click on Add, the bouncycastle packages are not shown).
>
> I even tried to add the bouncycastle's library inside the plugin, than
> I've been able to export the packages.
>
> This way it worked, except the fact that the library has been loaded by
> two different classloaders (infact it is inside the jre/lib/ext and
> inside the plugin): this way I got :
> cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
>
> What do I still make wrong?
>
> Thank you!,
> Massimiliano]]>Stefan 2008-11-25T17:16:33-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34488/#msg_34488
the setting should look like this:
Bundle A (containing BouncyCastleProvider)
Export-Package: org.bouncycastle.jce.provider
Bundle B (referencing BouncyCastleProvider)
Import-Package: org.bouncycastle.jce.provider
Maybe, there are additional packages which are indirectly referenced by
BouncyCastleProvider which you have to add to both lists.
Now, you should have no classloader issues any more.
Regards, Stefan.
ziccardi schrieb:
> Hi Stephan!
>
> Thank you very much for your help.
>
> I tried to export the packages as you told, but I cannot see them (when
> I click on Add, the bouncycastle packages are not shown).
>
> I even tried to add the bouncycastle's library inside the plugin, than
> I've been able to export the packages.
>
> This way it worked, except the fact that the library has been loaded by
> two different classloaders (infact it is inside the jre/lib/ext and
> inside the plugin): this way I got :
> cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
>
> What do I still make wrong?
>
> Thank you!,
> Massimiliano]]>Stefan 2008-11-25T17:16:33-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34625/#msg_34625
Originally posted by: massimiliano.ziccardi.gmail.com
Not sure I did it the right way.
At the moment it works, but I'm not sure my solution won't create other
problems.
The problem was the following.
The bouncycastle security provider was configured inside the
java.security file (and was placed inside jre/lib/ext directory).
The problem was about a call inside the code, where I used some security
class passing as provider 'new BouncyCastleProvider()'.
Than, I created a plugin containing only the bouncycastle classes.
This plugin exports bouncycastle packages.
The other plugins that needs bouncycastle's api, simply depends on the
bouncycastle plugin.
However, I'm not sure I wont' meet the problem again with other
bouncycastle's apis...
Do you think I did right?
Thank you very much for your help!
Regards,
Massimiliano Ziccardi
Stefan Roeck wrote:
> Hi,
>
> the setting should look like this:
>
> Bundle A (containing BouncyCastleProvider)
> Export-Package: org.bouncycastle.jce.provider
>
> Bundle B (referencing BouncyCastleProvider)
> Import-Package: org.bouncycastle.jce.provider
>
> Maybe, there are additional packages which are indirectly referenced by
> BouncyCastleProvider which you have to add to both lists.
>
> Now, you should have no classloader issues any more.
>
> Regards, Stefan.
>
> ziccardi schrieb:
>> Hi Stephan!
>>
>> Thank you very much for your help.
>>
>> I tried to export the packages as you told, but I cannot see them
>> (when I click on Add, the bouncycastle packages are not shown).
>>
>> I even tried to add the bouncycastle's library inside the plugin, than
>> I've been able to export the packages.
>>
>> This way it worked, except the fact that the library has been loaded
>> by two different classloaders (infact it is inside the jre/lib/ext and
>> inside the plugin): this way I got :
>> cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
>>
>> What do I still make wrong?
>>
>> Thank you!,
>> Massimiliano]]>2008-11-26T11:03:54-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585891/#msg_585891
At the moment it works, but I'm not sure my solution won't create other
problems.
The problem was the following.
The bouncycastle security provider was configured inside the
java.security file (and was placed inside jre/lib/ext directory).
The problem was about a call inside the code, where I used some security
class passing as provider 'new BouncyCastleProvider()'.
Than, I created a plugin containing only the bouncycastle classes.
This plugin exports bouncycastle packages.
The other plugins that needs bouncycastle's api, simply depends on the
bouncycastle plugin.
However, I'm not sure I wont' meet the problem again with other
bouncycastle's apis...
Do you think I did right?
Thank you very much for your help!
Regards,
Massimiliano Ziccardi
Stefan Roeck wrote:
> Hi,
>
> the setting should look like this:
>
> Bundle A (containing BouncyCastleProvider)
> Export-Package: org.bouncycastle.jce.provider
>
> Bundle B (referencing BouncyCastleProvider)
> Import-Package: org.bouncycastle.jce.provider
>
> Maybe, there are additional packages which are indirectly referenced by
> BouncyCastleProvider which you have to add to both lists.
>
> Now, you should have no classloader issues any more.
>
> Regards, Stefan.
>
> ziccardi schrieb:
>> Hi Stephan!
>>
>> Thank you very much for your help.
>>
>> I tried to export the packages as you told, but I cannot see them
>> (when I click on Add, the bouncycastle packages are not shown).
>>
>> I even tried to add the bouncycastle's library inside the plugin, than
>> I've been able to export the packages.
>>
>> This way it worked, except the fact that the library has been loaded
>> by two different classloaders (infact it is inside the jre/lib/ext and
>> inside the plugin): this way I got :
>> cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
>>
>> What do I still make wrong?
>>
>> Thank you!,
>> Massimiliano]]>Massimiliano Ziccardi2008-11-26T11:03:54-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34693/#msg_34693
Putting the Bouncy Castle classes in their own plugin is the best solution.
I think the problems you had before when they were in jre/lib/ext are to
do with boot delegation [1] and execution environments [2].
The short explanation being that by default you can only see the
packages from the vm that are exported by the system bundle
(org.eclipse.osgi). This list of packages is determined by an execution
environment profile, which of course does not include the Bouncy Castle
packages.
To use Bouncy Castle packages from the jre/lib/ext directory, you would
either need to change org.osgi.framework.bootdelegation, or use a custom
execution environment (I'm not sure of the details for that).
-Andrew
Massimiliano Ziccardi wrote:
> Not sure I did it the right way.
> At the moment it works, but I'm not sure my solution won't create other
> problems.
>
> The problem was the following.
>
> The bouncycastle security provider was configured inside the
> java.security file (and was placed inside jre/lib/ext directory).
>
> The problem was about a call inside the code, where I used some security
> class passing as provider 'new BouncyCastleProvider()'.
>
> The exact code was (one of the many):
>
> KeyStore ks = KeyStore.getInstance("PKCS12",new BouncyCastleProvider());
>
> I solved it changing the code to:
>
> KeyStore ks = KeyStore.getInstance("PKCS12",Security.getProvider("BC"));
>
> Than, I created a plugin containing only the bouncycastle classes.
> This plugin exports bouncycastle packages.
>
> The other plugins that needs bouncycastle's api, simply depends on the
> bouncycastle plugin.
>
> However, I'm not sure I wont' meet the problem again with other
> bouncycastle's apis...
>
> Do you think I did right?
>
> Thank you very much for your help!
>
> Regards,
> Massimiliano Ziccardi
>
> Stefan Roeck wrote:
>> Hi,
>>
>> the setting should look like this:
>>
>> Bundle A (containing BouncyCastleProvider)
>> Export-Package: org.bouncycastle.jce.provider
>>
>> Bundle B (referencing BouncyCastleProvider)
>> Import-Package: org.bouncycastle.jce.provider
>>
>> Maybe, there are additional packages which are indirectly referenced
>> by BouncyCastleProvider which you have to add to both lists.
>>
>> Now, you should have no classloader issues any more.
>>
>> Regards, Stefan.
>>
>> ziccardi schrieb:
>>> Hi Stephan!
>>>
>>> Thank you very much for your help.
>>>
>>> I tried to export the packages as you told, but I cannot see them
>>> (when I click on Add, the bouncycastle packages are not shown).
>>>
>>> I even tried to add the bouncycastle's library inside the plugin, than
>>> I've been able to export the packages.
>>>
>>> This way it worked, except the fact that the library has been loaded
>>> by two different classloaders (infact it is inside the jre/lib/ext
>>> and inside the plugin): this way I got :
>>> cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
>>>
>>> What do I still make wrong?
>>>
>>> Thank you!,
>>> Massimiliano]]>Andrew Niefer2008-11-26T16:22:02-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585914/#msg_585914
Putting the Bouncy Castle classes in their own plugin is the best solution.
I think the problems you had before when they were in jre/lib/ext are to
do with boot delegation [1] and execution environments [2].
The short explanation being that by default you can only see the
packages from the vm that are exported by the system bundle
(org.eclipse.osgi). This list of packages is determined by an execution
environment profile, which of course does not include the Bouncy Castle
packages.
To use Bouncy Castle packages from the jre/lib/ext directory, you would
either need to change org.osgi.framework.bootdelegation, or use a custom
execution environment (I'm not sure of the details for that).
-Andrew
Massimiliano Ziccardi wrote:
> Not sure I did it the right way.
> At the moment it works, but I'm not sure my solution won't create other
> problems.
>
> The problem was the following.
>
> The bouncycastle security provider was configured inside the
> java.security file (and was placed inside jre/lib/ext directory).
>
> The problem was about a call inside the code, where I used some security
> class passing as provider 'new BouncyCastleProvider()'.
>
> The exact code was (one of the many):
>
> KeyStore ks = KeyStore.getInstance("PKCS12",new BouncyCastleProvider());
>
> I solved it changing the code to:
>
> KeyStore ks = KeyStore.getInstance("PKCS12",Security.getProvider("BC"));
>
> Than, I created a plugin containing only the bouncycastle classes.
> This plugin exports bouncycastle packages.
>
> The other plugins that needs bouncycastle's api, simply depends on the
> bouncycastle plugin.
>
> However, I'm not sure I wont' meet the problem again with other
> bouncycastle's apis...
>
> Do you think I did right?
>
> Thank you very much for your help!
>
> Regards,
> Massimiliano Ziccardi
>
> Stefan Roeck wrote:
>> Hi,
>>
>> the setting should look like this:
>>
>> Bundle A (containing BouncyCastleProvider)
>> Export-Package: org.bouncycastle.jce.provider
>>
>> Bundle B (referencing BouncyCastleProvider)
>> Import-Package: org.bouncycastle.jce.provider
>>
>> Maybe, there are additional packages which are indirectly referenced
>> by BouncyCastleProvider which you have to add to both lists.
>>
>> Now, you should have no classloader issues any more.
>>
>> Regards, Stefan.
>>
>> ziccardi schrieb:
>>> Hi Stephan!
>>>
>>> Thank you very much for your help.
>>>
>>> I tried to export the packages as you told, but I cannot see them
>>> (when I click on Add, the bouncycastle packages are not shown).
>>>
>>> I even tried to add the bouncycastle's library inside the plugin, than
>>> I've been able to export the packages.
>>>
>>> This way it worked, except the fact that the library has been loaded
>>> by two different classloaders (infact it is inside the jre/lib/ext
>>> and inside the plugin): this way I got :
>>> cannot cast class PBEKey to class PBEKey (an obvious classloader issue).
>>>
>>> What do I still make wrong?
>>>
>>> Thank you!,
>>> Massimiliano]]>Andrew Niefer2008-11-26T16:22:02-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/585960/#msg_585960
I read the documentation at the links you provider.
That was exactly what I needed!
Thank you very much!
One last question: to change the org.osgi.framework.bootdelegation do I
have to change some configuration file? Or the only way is to put an
-Dorg.osgi.framework.bootdelegation=org.bouncycastle.* as VM parameter?
(sorry for the newbie question: this is my first RCP application)
Thank you again,
Massimiliano Ziccardi]]>Massimiliano Ziccardi2008-11-27T09:19:02-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34797/#msg_34797
Originally posted by: massimiliano.ziccardi.gmail.com
Hi Andrew.
I read the documentation at the links you provider.
That was exactly what I needed!
Thank you very much!
One last question: to change the org.osgi.framework.bootdelegation do I
have to change some configuration file? Or the only way is to put an
-Dorg.osgi.framework.bootdelegation=org.bouncycastle.* as VM parameter?
(sorry for the newbie question: this is my first RCP application)
Thank you again,
Massimiliano Ziccardi]]>2008-11-27T09:19:02-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/586064/#msg_586064
I think that setting it as a vm property will work as well.
-Andrew
Massimiliano Ziccardi wrote:
> Hi Andrew.
>
> I read the documentation at the links you provider.
> That was exactly what I needed!
>
> Thank you very much!
>
> One last question: to change the org.osgi.framework.bootdelegation do I
> have to change some configuration file? Or the only way is to put an
> -Dorg.osgi.framework.bootdelegation=org.bouncycastle.* as VM parameter?
> (sorry for the newbie question: this is my first RCP application)
>
> Thank you again,
> Massimiliano Ziccardi]]>Andrew Niefer2008-11-27T22:41:16-00:00Re: ClassNotFoundException with classes inside jre/lib/ext
https://www.eclipse.org/forums/index.php/mv/msg/11057/34993/#msg_34993
I think that setting it as a vm property will work as well.
-Andrew
Massimiliano Ziccardi wrote:
> Hi Andrew.
>
> I read the documentation at the links you provider.
> That was exactly what I needed!
>
> Thank you very much!
>
> One last question: to change the org.osgi.framework.bootdelegation do I
> have to change some configuration file? Or the only way is to put an
> -Dorg.osgi.framework.bootdelegation=org.bouncycastle.* as VM parameter?
> (sorry for the newbie question: this is my first RCP application)
>
> Thank you again,
> Massimiliano Ziccardi]]>Andrew Niefer2008-11-27T22:41:16-00:00