Hi Everyone,

Recently, I've made a few posts recounting my travails in trying to get GeoTools working as an Eclipse plug-in. Specifically, I was having problems with the Java Image extensions (JAI). Thanks to help from Andrea and Jody, I now have a working system.

While I am not yet to the point where I feel that I can write on the subject with any authority, I feel that I should at least tell you all what worked for me (so far) and share the information with the community. I wasted so much time on this nonsense that I'd hate to see somebody else have to go through the same thing. So I will write down what I've discovered so far. If anyone has corrections or clarifications, I encourage you to post them.

Basically, some of the GeoTiff related rendering in GeoTools depends on the Java Image extensions. These extensions permit Java to speed up certain image processing functions, but they need to be downloaded and installed from Sun or an other source. There has been plenty of debate about this use, and while I fall squarely on the side that thinks the JAI extensions are a good idea (software can never be too fast), they do present special problems. In the case of a standard AWT/Swing based implementation, it's merely a matter of ensuring that they are properly installed on your system. This is easy enough once you know how it's done. And the subject has been discussed elsewhere on this mailing list, so I won't go into it here.

Other the other hand, Eclipse plug-ins present their own problem. This happens because the Eclipse framework depends on its own, custom classloaders (actually, the OSGi classloader). Unless you make special provision when building an eclipse plug-in project (which are essentially the same things as OSGi bundles), the classloader can't find the resources defined in the JAI extensions jar files.

In my earlier posts I mentioned two kinds of exceptions. First, there were "NoClassDefFoundError" exceptions. These were thrown in the case where the classloader could not find the JAI classes it needed. I attempted to solve this problem by including the JAI jar files in my plug-in... (Yes, it felt wrong at the time, but it was all I could think of) . This approach got rid of the not-found exception, but led to another, the "ClassCastException". I believe that the exception occurred because Java attempted to load the same JAI classes from two separate places due to the way I'd configured the plug-in. So it turned out that the fix was to not include the JAI jar files in the plug in. Since I posted an email a couple of weeks ago where I described this incorrect approach, I thought I should clarify this point.

It turns out that the solution that was suggested to me was to include the following line

Eclipse-BuddyPolicy: ext

In the manifest.mf file associated with the plug-in I built to hold the GeoTools jars. This seems to have solved the problem. I know that there is more to it than I've described here, but I have not yet sorted out all the details. Perhaps somebody else can add the missing information.

Over the last couple of weeks, I've done a lot of looking into the OSGi classloaders trying to understand this issue. And I have concluded that the whole situation related to understanding how to use OSGi/Eclipse bundles was best described by a line in a certain well-known pirate movie: "it is an isle of the dead which cannot be reached, except by those who already know where it is." Web articles on the subject assume a certain amount of background knowledge on the readers part, but completely ignores the fact that if the reader had that background knowledge he wouldn't need to be reading the web article. And, while I know that I haven't done a lot better than that myself in writing this posting, I do hope it helps a little.


Again, my thanks for the help I've received on this mailing list.

Gary





Gary W. Lucas
Sonalysts, Inc.
215 Parkway North
Waterford CT 06320, USA
(860) 326-3682 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to