You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by Zeenat Lainwala <la...@us.ibm.com> on 2008/07/10 19:24:03 UTC
Classloader problems when creating Factory and Parser objects
In my product, the abdera classes are packaged in an OSGI bundle. This is
version 0.4.0. When abdera creates a Factory, Parser, etc, it uses the
application classloader and the system class loader
(org.apache.abdera.util.ServiceUtil.java locateInstance) instead of using
the classloader from
the bundle. Since the Factory, Parser etc classes are in the bundle, the
classloading fails.
Does anyone have an idea on how I can circumvent this problem?
thanks,
Zeenat
Re: Classloader problems when creating Factory and Parser objects
Posted by Ugo Cei <ug...@apache.org>.
On Jul 10, 2008, at 7:24 PM, Zeenat Lainwala wrote:
> In my product, the abdera classes are packaged in an OSGI bundle.
> This is
> version 0.4.0. When abdera creates a Factory, Parser, etc, it uses the
> application classloader and the system class loader
> (org.apache.abdera.util.ServiceUtil.java locateInstance) instead of
> using
> the classloader from
> the bundle. Since the Factory, Parser etc classes are in the bundle,
> the
> classloading fails.
>
> Does anyone have an idea on how I can circumvent this problem?
I had the same problem, in a different context. See the following
thread:
http://www.nabble.com/Using-Abdera-in-a-Confluence-plugin-tt17207744.html
In the end I had to manually move all jars to my webapp's WEB-INF/lib
directory, which sucks, but I don't want to have to fight with too
many frameworks trying to do too many clever things with class-
loading: in my case it was Confluence, Commons Logging, Abdera and
maybe more. Good luck trying to figure out how to introduce OSGi in
the mix.
Ugo
Re: Classloader problems when creating Factory and Parser objects
Posted by Zeenat Lainwala <la...@us.ibm.com>.
Yes, this solution worked for me. I set the context classloader on the
thread to the osgi classloader and then once I am done getting the Factory
and
Parser objects, I reset it back to the original classloader.
Thank you.
Zeenat
IBM Websphere Process Server
"Sergio Bossa" <se...@gmail.com>
07/11/2008 01:34 AM
Please respond to
abdera-user@incubator.apache.org
To
abdera-user@incubator.apache.org
cc
Subject
Re: Classloader problems when creating Factory and Parser objects
On Thu, Jul 10, 2008 at 7:24 PM, Zeenat Lainwala <la...@us.ibm.com>
wrote:
> In my product, the abdera classes are packaged in an OSGI bundle. This
is
> version 0.4.0. When abdera creates a Factory, Parser, etc, it uses the
> application classloader and the system class loader
> (org.apache.abdera.util.ServiceUtil.java locateInstance) instead of
using
> the classloader from
> the bundle. Since the Factory, Parser etc classes are in the bundle, the
> classloading fails.
Hi,
you may try to overwrite the current thread classloader by calling the
following method into your code:
Thread.currentThread().setContextClassLoader(osgiClassloader).
Let us know if it works.
Cheers,
Sergio B.
--
Sergio Bossa
Software Passionate, Java Technologies Specialist and Open Source
Enthusiast.
Blog : http://sbtourist.blogspot.com
Sourcesense - making sense of Open Source : http://www.sourcesense.com
Pro-netics s.p.a. : http://www.pronetics.it
Re: Classloader problems when creating Factory and Parser objects
Posted by Sergio Bossa <se...@gmail.com>.
On Thu, Jul 10, 2008 at 7:24 PM, Zeenat Lainwala <la...@us.ibm.com> wrote:
> In my product, the abdera classes are packaged in an OSGI bundle. This is
> version 0.4.0. When abdera creates a Factory, Parser, etc, it uses the
> application classloader and the system class loader
> (org.apache.abdera.util.ServiceUtil.java locateInstance) instead of using
> the classloader from
> the bundle. Since the Factory, Parser etc classes are in the bundle, the
> classloading fails.
Hi,
you may try to overwrite the current thread classloader by calling the
following method into your code:
Thread.currentThread().setContextClassLoader(osgiClassloader).
Let us know if it works.
Cheers,
Sergio B.
--
Sergio Bossa
Software Passionate, Java Technologies Specialist and Open Source Enthusiast.
Blog : http://sbtourist.blogspot.com
Sourcesense - making sense of Open Source : http://www.sourcesense.com
Pro-netics s.p.a. : http://www.pronetics.it