Help resolving parsers in WFS getFeatures()

10 messages Options
Embed this post
Permalink
Ferdinando Villa-4

Help resolving parsers in WFS getFeatures()

Reply Threaded More More options
Print post
Permalink
Hi all,

I've been desperate a couple days with this exception:

Can't find a response parser factory for  
net.opengis.wfs.impl.GetFeatureTypeImpl@8a88a9 (handle: GeoTools 2.5.7  
WFS DataStore, service: WFS, version:

I'm trying to read features from WFS, going pretty much by the book.  
getFeatures() works, this is thrown when I create a feature iterator.  
It's 2.5.7 and I'm working in a JPF/OSGI context, so I may not be  
including all jars properly, but I'm pretty much at the end of my wit  
now (I thought gt-gmlparsing would have fixed it but no).

Any advice? Thanks so much for any help,

ferdinando


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Gabriel Roldan

Re: Help resolving parsers in WFS getFeatures()

Reply Threaded More More options
Print post
Permalink
Hi Ferdinando,

if you're using the WFSDataStore inside an OSGI environment, it may be a
classloader problem.
uDig has the same problem with eclipse's RCP, and the solution is to
bundle all the dependencies together as a plugin
(net.refractions.udig.libs plugin).

This is so because the WFSDataStore uses a SPI (Service Provider
Interface) mechanism to dynamically find a parser for a given request
response, just as GeoTools does to find the DataStore implementations, etc.

May that be the problem? I don't know about JPF but it looks like.

Cheers,
Gabriel

Ferdinando Villa wrote:

> Hi all,
>
> I've been desperate a couple days with this exception:
>
> Can't find a response parser factory for  
> net.opengis.wfs.impl.GetFeatureTypeImpl@8a88a9 (handle: GeoTools 2.5.7  
> WFS DataStore, service: WFS, version:
>
> I'm trying to read features from WFS, going pretty much by the book.  
> getFeatures() works, this is thrown when I create a feature iterator.  
> It's 2.5.7 and I'm working in a JPF/OSGI context, so I may not be  
> including all jars properly, but I'm pretty much at the end of my wit  
> now (I thought gt-gmlparsing would have fixed it but no).
>
> Any advice? Thanks so much for any help,
>
> ferdinando
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Geotools-gt2-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users


--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Gabriel Roldan

Re: Help resolving parsers in WFS getFeatures()

Reply Threaded More More options
Print post
Permalink
Oh, as a workaround, if you can stick to WFS 1.0.0 you won't have that
problem since I never get to port the old wfs1.0 datastore to this new
architecture the 1.1 one is based on. Just append VERSION=1.0.0 to your
GetCapabilities URL and you should be gold.


Cheers,
Gabriel

Gabriel Roldan wrote:

> Hi Ferdinando,
>
> if you're using the WFSDataStore inside an OSGI environment, it may be a
> classloader problem.
> uDig has the same problem with eclipse's RCP, and the solution is to
> bundle all the dependencies together as a plugin
> (net.refractions.udig.libs plugin).
>
> This is so because the WFSDataStore uses a SPI (Service Provider
> Interface) mechanism to dynamically find a parser for a given request
> response, just as GeoTools does to find the DataStore implementations, etc.
>
> May that be the problem? I don't know about JPF but it looks like.
>
> Cheers,
> Gabriel
>
> Ferdinando Villa wrote:
>> Hi all,
>>
>> I've been desperate a couple days with this exception:
>>
>> Can't find a response parser factory for  
>> net.opengis.wfs.impl.GetFeatureTypeImpl@8a88a9 (handle: GeoTools 2.5.7  
>> WFS DataStore, service: WFS, version:
>>
>> I'm trying to read features from WFS, going pretty much by the book.  
>> getFeatures() works, this is thrown when I create a feature iterator.  
>> It's 2.5.7 and I'm working in a JPF/OSGI context, so I may not be  
>> including all jars properly, but I'm pretty much at the end of my wit  
>> now (I thought gt-gmlparsing would have fixed it but no).
>>
>> Any advice? Thanks so much for any help,
>>
>> ferdinando
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry® Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9-12, 2009. Register now!
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>


--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Ferdinando Villa-4

Re: Help resolving parsers in WFS getFeatures()

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gabriel Roldan
Thank you Gabriel,

I'm pretty sure it's a classloading problem - JPF is basically the  
precursor of OSGI and
works exactly the same. But all of geotools is in a single plugin and  
the parser is
looked up within the plugin itself, so it must be either 1) a parser  
implementation not
present in 2.5.7, or 2) me not exposing the appropriate jars in the  
plugin manifest and
exporting classes so that they can be found dynamically. I am loading  
and exporting all I
could find with no success, but it would help a lot to know which  
jars, if any, contain a
usable implementation, and whether I need to switch to 2.6...

Thanks much,
ferdinando

Quoting Gabriel Roldan <[hidden email]>:

> Hi Ferdinando,
>
> if you're using the WFSDataStore inside an OSGI environment, it may be a
> classloader problem.
> uDig has the same problem with eclipse's RCP, and the solution is to
> bundle all the dependencies together as a plugin
> (net.refractions.udig.libs plugin).
>
> This is so because the WFSDataStore uses a SPI (Service Provider
> Interface) mechanism to dynamically find a parser for a given request
> response, just as GeoTools does to find the DataStore implementations, etc.
>
> May that be the problem? I don't know about JPF but it looks like.
>
> Cheers,
> Gabriel
>
> Ferdinando Villa wrote:
>> Hi all,
>>
>> I've been desperate a couple days with this exception:
>>
>> Can't find a response parser factory for
>> net.opengis.wfs.impl.GetFeatureTypeImpl@8a88a9 (handle: GeoTools 2.5.7
>> WFS DataStore, service: WFS, version:
>>
>> I'm trying to read features from WFS, going pretty much by the book.
>> getFeatures() works, this is thrown when I create a feature iterator.
>> It's 2.5.7 and I'm working in a JPF/OSGI context, so I may not be
>> including all jars properly, but I'm pretty much at the end of my wit
>> now (I thought gt-gmlparsing would have fixed it but no).
>>
>> Any advice? Thanks so much for any help,
>>
>> ferdinando
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry® Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9-12, 2009. Register now!
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
> --
> Gabriel Roldan
> OpenGeo - http://opengeo.org
> Expert service straight from the developers.
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Geotools-gt2-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>




------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Gabriel Roldan

Re: Help resolving parsers in WFS getFeatures()

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gabriel Roldan
Ferdinando Villa wrote:

> Thank you Gabriel,
>
> I'm pretty sure it's a classloading problem - JPF is basically the
> precursor of OSGI and works exactly the same. But all of geotools is in
> a single plugin and the parser is looked up within the plugin itself, so
> it must be either 1) a parser implementation not present in 2.5.7, or 2)
> me not exposing the appropriate jars in the plugin manifest and
> exporting classes so that they can be found dynamically. I am loading
> and exporting all I could find with no success, but it would help a lot
> to know which jars, if any, contain a usable implementation, and whether
> I need to switch to 2.6...
ah ok, actually the extensibility mechanism is there but the only usable
implementation is inside the gt-wfs jar itself, class
org.geotools.data.wfs.v1_1_0.parsers.Gml31GetFeatureResponseParserFactory
which is referred by the file
META-INF/services/org.geotools.data.wfs.protocol.wfs.WFSResponseParserFactory

So as long as both the package and the resource under META-INF/services
are accessible it should work.

Aside, if you're looking for transaction support you'll need to stick to
  WFS 1.0 anyways, transaction support for 1.1 is not there yet. But if
read-only try going for 1.1 as it's better supported and faster.

Cheers,
Gabriel

>
> Thanks much,
> ferdinando
>
> Quoting Gabriel Roldan <[hidden email]>:
>
>> Hi Ferdinando,
>>
>> if you're using the WFSDataStore inside an OSGI environment, it may be
>> a classloader problem.
>> uDig has the same problem with eclipse's RCP, and the solution is to
>> bundle all the dependencies together as a plugin
>> (net.refractions.udig.libs plugin).
>>
>> This is so because the WFSDataStore uses a SPI (Service Provider
>> Interface) mechanism to dynamically find a parser for a given request
>> response, just as GeoTools does to find the DataStore implementations,
>> etc.
>>
>> May that be the problem? I don't know about JPF but it looks like.
>>
>> Cheers,
>> Gabriel
>>
>> Ferdinando Villa wrote:
>>> Hi all,
>>>
>>> I've been desperate a couple days with this exception:
>>>
>>> Can't find a response parser factory for  
>>> net.opengis.wfs.impl.GetFeatureTypeImpl@8a88a9 (handle: GeoTools  
>>> 2.5.7 WFS DataStore, service: WFS, version:
>>>
>>> I'm trying to read features from WFS, going pretty much by the  
>>> book.  getFeatures() works, this is thrown when I create a feature  
>>> iterator.  It's 2.5.7 and I'm working in a JPF/OSGI context, so I  
>>> may not be  including all jars properly, but I'm pretty much at the
>>>  end of my wit  now (I thought gt-gmlparsing would have fixed it but  
>>> no).
>>>
>>> Any advice? Thanks so much for any help,
>>>
>>> ferdinando
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> Come build with us! The BlackBerry® Developer Conference in SF, CA
>>> is the only developer event you need to attend this year. Jumpstart your
>>> developing skills, take BlackBerry mobile applications to market  and
>>> stay ahead of the curve. Join us from November 9-12, 2009.  
>>> Register now!
>>> http://p.sf.net/sfu/devconf
>>> _______________________________________________
>>> Geotools-gt2-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
>> --
>> Gabriel Roldan
>> OpenGeo - http://opengeo.org
>> Expert service straight from the developers.
>
>
>


--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Ferdinando Villa-4

Re: Help resolving parsers in WFS AND namespace resolution issue getFeatures()

Reply Threaded More More options
Print post
Permalink
thanks again Gabriel. As the geotools code uses  
ServiceRegistry.lookupProviders, which uses the thread classloader, I  
am giving up trying to use WFS 1.1.0 for the time being. I can get the  
classloader that would see the services from the plugin I'm using, but  
I have no way of passing it around. A call like

Iterator<WFSResponseParserFactory> providers =
                        Service.providers(WFSResponseParserFactory.class,
getClassLoader());

works for me, but it doesn't seem to cache anything. All relevant  
methods in WFSExtension are (correctly) package private, so no point  
for me to intervene. If you have any suggestion on how to preload the  
registry from a place where the classloader can be controlled, I'll  
greatly appreciate knowing it.

One more, very ignorant question? I'm now defaulting to WFS 1.0.0 as  
you suggested, but I get exceptions from the XML parser trying to  
resolve the URI associated with the namespace my data are in (using  
geoserver 1.7.6). E.g. if typename is global:wdpa, and 'global' is  
associated to http://xxxxx, geotools tries to read the contents of  
http://xxxxx as XML and dies. I don't know what the URI is supposed to  
point to, and I would not think it was supposed to point to anything.  
Even with strict=false, geotools tries to parse its contents as an XML  
file. Can you kindly shed some light on this?

Many thanks again,
ferdinando

Quoting Gabriel Roldan <[hidden email]>:

> Ferdinando Villa wrote:
>> Thank you Gabriel,
>>
>> I'm pretty sure it's a classloading problem - JPF is basically the  
>> precursor of OSGI and works exactly the same. But all of geotools  
>> is in a single plugin and the parser is looked up within the plugin  
>>  itself, so it must be either 1) a parser implementation not  
>> present  in 2.5.7, or 2) me not exposing the appropriate jars in  
>> the plugin  manifest and exporting classes so that they can be  
>> found  dynamically. I am loading and exporting all I could find  
>> with no  success, but it would help a lot to know which jars, if  
>> any,  contain a usable implementation, and whether I need to switch  
>> to  2.6...
> ah ok, actually the extensibility mechanism is there but the only
> usable implementation is inside the gt-wfs jar itself, class
> org.geotools.data.wfs.v1_1_0.parsers.Gml31GetFeatureResponseParserFactory
> which is referred by the file
> META-INF/services/org.geotools.data.wfs.protocol.wfs.WFSResponseParserFactory
>
> So as long as both the package and the resource under META-INF/services
> are accessible it should work.
>
> Aside, if you're looking for transaction support you'll need to stick
> to  WFS 1.0 anyways, transaction support for 1.1 is not there yet. But
> if read-only try going for 1.1 as it's better supported and faster.
>
> Cheers,
> Gabriel
>
>>
>> Thanks much,
>> ferdinando
>>
>> Quoting Gabriel Roldan <[hidden email]>:
>>
>>> Hi Ferdinando,
>>>
>>> if you're using the WFSDataStore inside an OSGI environment, it may be
>>> a classloader problem.
>>> uDig has the same problem with eclipse's RCP, and the solution is to
>>> bundle all the dependencies together as a plugin
>>> (net.refractions.udig.libs plugin).
>>>
>>> This is so because the WFSDataStore uses a SPI (Service Provider
>>> Interface) mechanism to dynamically find a parser for a given request
>>> response, just as GeoTools does to find the DataStore implementations,
>>> etc.
>>>
>>> May that be the problem? I don't know about JPF but it looks like.
>>>
>>> Cheers,
>>> Gabriel
>>>
>>> Ferdinando Villa wrote:
>>>> Hi all,
>>>>
>>>> I've been desperate a couple days with this exception:
>>>>
>>>> Can't find a response parser factory for    
>>>> net.opengis.wfs.impl.GetFeatureTypeImpl@8a88a9 (handle: GeoTools  
>>>>  2.5.7 WFS DataStore, service: WFS, version:
>>>>
>>>> I'm trying to read features from WFS, going pretty much by the    
>>>> book.  getFeatures() works, this is thrown when I create a  
>>>> feature  iterator.  It's 2.5.7 and I'm working in a JPF/OSGI  
>>>> context, so I  may not be  including all jars properly, but I'm  
>>>> pretty much at the  end of my wit  now (I thought gt-gmlparsing  
>>>> would have fixed it but  no).
>>>>
>>>> Any advice? Thanks so much for any help,
>>>>
>>>> ferdinando
>>>>
>>>>
>>>> ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF,  
>>>> CA
>>>> is the only developer event you need to attend this year. Jumpstart your
>>>> developing skills, take BlackBerry mobile applications to market  
>>>>  and stay ahead of the curve. Join us from November 9-12,  
>>>> 2009.  Register now!
>>>> http://p.sf.net/sfu/devconf
>>>> _______________________________________________
>>>> Geotools-gt2-users mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>>
>>>
>>> --
>>> Gabriel Roldan
>>> OpenGeo - http://opengeo.org
>>> Expert service straight from the developers.
>>
>>
>>
>
>
> --
> Gabriel Roldan
> OpenGeo - http://opengeo.org
> Expert service straight from the developers.




------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Gabriel Roldan

Re: Help resolving parsers in WFS AND namespace resolution issue getFeatures()

Reply Threaded More More options
Print post
Permalink
Hi Ferdinando,

Ferdinando Villa wrote:

> thanks again Gabriel. As the geotools code uses
> ServiceRegistry.lookupProviders, which uses the thread classloader, I am
> giving up trying to use WFS 1.1.0 for the time being. I can get the
> classloader that would see the services from the plugin I'm using, but I
> have no way of passing it around. A call like
>
> Iterator<WFSResponseParserFactory> providers =
>             Service.providers(WFSResponseParserFactory.class,
> getClassLoader());
>
If you can you may try GeoTools 2.6 instead (see bellow wrt the 1.0.0
problem), as they're out of sync and I'm really more on maintaining the
wfs on 2.6 and deprecate 2.5 as both geoserver and udig are on 2.6 and I
don't have much spare time to devote to 2.5.
As a bonus, if you can switch to 2.6 I'll be happy to figure out a way
for you to impose a classloader to the spi.

> works for me, but it doesn't seem to cache anything. All relevant
> methods in WFSExtension are (correctly) package private, so no point for
> me to intervene. If you have any suggestion on how to preload the
> registry from a place where the classloader can be controlled, I'll
> greatly appreciate knowing it.
>
> One more, very ignorant question? I'm now defaulting to WFS 1.0.0 as you
> suggested, but I get exceptions from the XML parser trying to resolve
> the URI associated with the namespace my data are in (using geoserver
> 1.7.6). E.g. if typename is global:wdpa, and 'global' is associated to
> http://xxxxx, geotools tries to read the contents of http://xxxxx as XML
> and dies.
May be what's it's trying to resolve is the schemaLocation and not the
xmlns? that would make sense as it'll try to download the schema for the
... aghh.. just remembered there was a bug with that, like the plugin
getting confused itself on those two.. let me find out... it claims to
be fixed: <http://jira.codehaus.org/browse/GEOT-2640> but on trunk, was
not backported to 2.5.x... sorry.
so... any chance you migrate to geotools trunk?

I don't know what the URI is supposed to point to, and I would
> not think it was supposed to point to anything. Even with strict=false,
> geotools tries to parse its contents as an XML file. Can you kindly shed
> some light on this?
the above bug explains it.

Cheers,
Gabriel
>
> Many thanks again,
> ferdinando


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Jody Garnett-2

Re: Help resolving parsers in WFS AND namespace resolution issue getFeatures()

Reply Threaded More More options
Print post
Permalink
We have a trick in uDig where we look up a class; find its  
classloader; switch the thread to that classloader; make the call that  
uses factory spi; and then restore the thead its previous classloader.

Jody

> don't have much spare time to devote to 2.5.
> As a bonus, if you can switch to 2.6 I'll be happy to figure out a way
> for you to impose a classloader to the spi.



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Gabriel Roldan

Re: Help resolving parsers in WFS AND namespace resolution issue getFeatures()

Reply Threaded More More options
Print post
Permalink
hey, thanks for the insight.
So, before I mess-code, let me double check. What you're saying is that
I could just do:
ClassLoader orig = Thread.currentThread().getContextClassLoader();
try{
Thread.currentThread().setContextClassLoader(<Factory class to be looked
up>.class.getClassLoader());
  ... do lookup ...
}finally{
Thread.currentThread().setContextClassLoader(orig);
}


and that would be it, it will even find META-INF/services?
I guess "<Factory class to be looked up>" might actually be any class in
the same jar?

Cheers,
Gabriel

Jody Garnett wrote:

> We have a trick in uDig where we look up a class; find its classloader;
> switch the thread to that classloader; make the call that uses factory
> spi; and then restore the thead its previous classloader.
>
> Jody
>
>> don't have much spare time to devote to 2.5.
>> As a bonus, if you can switch to 2.6 I'll be happy to figure out a way
>> for you to impose a classloader to the spi.
>
>


--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Jody Garnett-2

Re: Help resolving parsers in WFS AND namespace resolution issue getFeatures()

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
That is the trick - but I don't think it is perfect.  It should find the META_INF/services that that classloader can see - but in Eclipse 3.4 they locked it down so you could not see across different classloaders (except for specific packages that had been made visible) - since the check was at the package level there was no way to allow META-INF/services a get out of jail free card. So I think it will work for a single classloader; but not all the parent classloaders.

Specifically I think the trick get's us into the "geotools" classloader and then hopes for the best.

You will see that some of the factory FactoryRegistry.getClassLoaders() method has some similar logic; I think this is what we are abusing with the setContextClassLoader method.

Jody

On 17/09/2009, at 1:24 PM, Gabriel Roldan wrote:

hey, thanks for the insight.
So, before I mess-code, let me double check. What you're saying is that I could just do:
ClassLoader orig = Thread.currentThread().getContextClassLoader();
try{
Thread.currentThread().setContextClassLoader(<Factory class to be looked up>.class.getClassLoader());
... do lookup ...
}finally{
Thread.currentThread().setContextClassLoader(orig);
}


and that would be it, it will even find META-INF/services?
I guess "<Factory class to be looked up>" might actually be any class in the same jar?

Cheers,
Gabriel

Jody Garnett wrote:
We have a trick in uDig where we look up a class; find its classloader; switch the thread to that classloader; make the call that uses factory spi; and then restore the thead its previous classloader.
Jody
don't have much spare time to devote to 2.5.
As a bonus, if you can switch to 2.6 I'll be happy to figure out a way
for you to impose a classloader to the spi.


--
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users