[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] Eclipse + ClassLoader + LocalCatalog
|
Hi,
I believed I had the solution to solve my class loading problem. That
wasn't true :-(
I still encountered the problem when my plugin was started because of an
extension.
For example, I extend the serviceExtension and when uDig restarts and
the Catalog View is already visible, it tries to create saved services.
At this time, my plugin was not loaded, so Eclipse starts it with a
ClassLoader that does not give access to the third party librairies I
embed in my plugin. (I don't understand why, but it's like that).
This situation leads to the problem I got before.
I had a look at the Eclipse's buddy policy that seemed to be the
solution but I failed.
My final solution that works fine (for the moment and for a while, I
hope so) is to add an Eclipse bundle manifest header:
Eclipse-AutoStart: false
This disable lazy loading for my plugin so I'm sure my plugin will be
started by the framework with a valid ClassLoader.
Now, in my plugin, each time I write code that can be executed in a uDig
thread and that requires my external librairies, I change the thread
context class loader with the MyPlugin.class.getClassLoader(). This is
done in a try/finally to be sure to reset the classloader.
I hope it's my last e-mail on this topic !
Vincent
Jesse Eichar wrote:
Hmmm. Strange behaviour that. I wonder if we (on the udig side) are
doing some classloader hacking. I know there were some issues we had
to try and deal with. I'll try to find time to look into this :P
Jesse
Vincent Nouguier wrote:
Eureka !
I finally suceeded in reloading data from previous executions. I
still don't know why it did not work. There is something I did not
understand in eclipse plugin architecture and classloaders, I could
not find advanced articles on the subject.
My "solution" is not satisfying in from a design point of view but it
is the only one I found. So, if any of you have a better idea, I will
use it.
This is the following :
When the Catalog extension point is started, it tries to load my
extension and then load my plugin. The plugin is loaded in another
thread (with another classloader). On constructor I get a static
reference on the current classloader. When the extension point
"thread" loads my catalog, I start a new Thread and I set its
classloader to the one I saved on plugin startup.
Do not hesitate to suggest better approaches.
Vincent
Jesse Eichar wrote:
This is a strange error as eclipse is very strict about keeping the
classpath for different plugins separate. If the library has not
been added to the system classpath it seems very odd to me that the
catalog plugins are picking them up. Definately verify that the
castor is not somehow on the jre classpath.
Jesse
Vincent Nouguier wrote:
Dear Jesse and Jody,
my castor librairy is not added to the JRE but is already embedded
in my plugin. A xerces librairy is also embedded in my plugin. But
when my classes (ServiceExtension) are loaded through another
plugin (CatalogPlugin I suppose), the castor lib is found (the
stacktrace shows castor calls) but the xerces lib is the one from
the JRE.
I'll try to find documentation on how ClassLoaders work in Eclipse.
If you have the solution or if you have an idea to test, let me know.
As I already embed jars in my plugin, I suppose creating a plugin
that provides xerces and castor as suggested by Jody will have no
effect. Right ?
Thanks guys
Vincent
PS: my plugin.xml and manifest.mf
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
point="net.refractions.udig.catalog.ServiceExtension">
<service
class="net.eads.irgs5.oasis.tsochannels.data.TsoChannelServiceExtension"/>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="net.eads.irgs5.oasis.tsochannels.preferences.PreferenceInitializer"/>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="net.eads.irgs5.oasis.tsochannels.preferences.PreferencePage"
id="net.eads.irgs5.oasis.tsochannels.preferences.PreferencePage"
name="OASIS/TSO Channels"/>
</extension>
<extension
point="net.refractions.udig.catalog.ICatalog">
<ICatalog
class="net.eads.irgs5.oasis.tsochannels.catalog.TsoChannelsCatalog"/>
</extension>
<extension
point="org.eclipse.ui.views">
<category
id="net.eads.irgs5.oasis.tsochannels"
name="%catalog.name"/>
<view
category="net.eads.irgs5.oasis.tsochannels"
class="net.eads.irgs5.oasis.tsochannels.catalog.ui.View"
icon="icons/sample.gif"
id="net.eads.irgs5.oasis.tsochannels.views.Catalog"
name="%catalog.view.name"/>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="net.refractions.udig.ui.mapPerspective">
<view
id="net.eads.irgs5.oasis.tsochannels.views.Catalog"
relationship="stack"
relative="bottom"/>
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.startup">
</extension>
</plugin>
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tsochannels Plug-in
Bundle-SymbolicName: net.eads.irgs5.oasis.tsochannels; singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: lib/tsochannels.jar,
lib/xercesImpl.jar,
lib/xml-apis.jar,
lib/castor-1.0M1-xml.jar
Bundle-Activator: net.eads.irgs5.oasis.tsochannels.TsochannelsPlugin
Bundle-Vendor: EADS DS SAS
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
net.eads.irgs5.eclipse.logging,
net.refractions.udig.catalog,
net.refractions.udig.catalog.ui,
net.refractions.udig.libs,
net.refractions.udig.catalog.shp,
net.refractions.udig.render.feature.basic,
net.refractions.udig.catalog.wms,
net.eads.irgs5.oasis.coe
Eclipse-AutoStart: true
Jesse Eichar wrote:
This is a rather difficult issue. I would first say that the
Castor jars shouldn't be added to the JRE rather they should be
included in your jar so they don't interfere with the other
plugins. In particular the plugins that load the maps. Also make
sure you fully qualify which xml files you are using...
Other than that I'm not sure what to do off the top of my head.
Jesse
Vincent Nouguier wrote:
Dear all,
I have the following problem.
I created a new data type from XML content.
When I run uDig for the time in a clean workspace, everything
works well. I can create services that are displayed in the
localcatalog view.
When I close and try to run uDig once again, previously loaded
services are loaded through the ServiceExtension extension. It
seems that the XML parser used to load my service is the one from
the JDK, not the xerces librairy I included in my plugin, not the
xerces version included in the lib plugin.
As I use Castor for XML mapping, I get an exception when reading
XML content.
I really believe it is a problem of classloader but I don't know
what to do?
Any Idea ?
I already encountered a similar problem when embedding Jetty in
uDig, I worked very well on first run but never again. I did not
resolve this bug. This new problem let me say that it could be a
problem with xml parsers as Jetty also uses XML for its
configuration.
Thanks for your help
Vincent.
PS: I did not forget my previous questions (one week ago) to
display layers in a heriarchical manner, but I tried to diplay
them first in a flat way. Can the members method on IGeoResource
help me ?
Here is the console log (all log4j events were not present during
first clean run)
log4j:ERROR A "org.apache.log4j.PatternLayout" object is not
assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR
[org.eclipse.core.runtime.adaptor.EclipseClassLoader@1d314cc]
whereas object of type
log4j:ERROR "org.apache.log4j.PatternLayout" was loaded by
[org.eclipse.core.runtime.adaptor.EclipseClassLoader@cb754f].
log4j:ERROR No layout set for the appender named [A1].
log4j:ERROR A "org.apache.log4j.PatternLayout" object is not
assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR
[org.eclipse.core.runtime.adaptor.EclipseClassLoader@1d314cc]
whereas object of type
log4j:ERROR "org.apache.log4j.PatternLayout" was loaded by
[org.eclipse.core.runtime.adaptor.EclipseClassLoader@cb754f].
log4j:WARN No appenders could be found for logger
(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system properly.
log4j:ERROR No layout set for the appender named [A1].
action.remove: 'elcl16/remove_co.gif' found action.remove
action.remove: 'dlcl16/remove_co.gif' found action.remove
Exception in thread "TsoChannelsWatcher, OASIS_TSO_CHANNELS_1_0"
java.lang.RuntimeException: Could not instantiate parser
org.apache.xerces.parsers.SAXParser:
java.lang.ClassCastException:
org.apache.xerces.parsers.XML11Configuration
at
org.exolab.castor.util.LocalConfiguration.getParser(LocalConfiguration.java:332)
at
org.exolab.castor.util.LocalConfiguration.getParser(LocalConfiguration.java:263)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:642)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:565)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:748)
at
net.eads.irgs5.oasis.tsochannels.model.castor.TSO_Channel.unmarshalTSO_Channel(TSO_Channel.java:619)
at
net.eads.irgs5.oasis.tsochannels.catalog.TsoChannelsWatcher.run(TsoChannelsWatcher.java:157)
at java.lang.Thread.run(Unknown Source)
Here is a message I get since I updated from 1.0.5 to 1.1M2 : in
${workspace}/metadata/.log, maybe it can help. I get this message
at each uDig run.
!ENTRY org.eclipse.core.runtime 2 2 2006-02-01 20:03:21.820
!MESSAGE Job found still running after platform shutdown. Jobs
should be canceled by the plugin that scheduled them during
shutdown:
net.refractions.udig.project.ui.internal.render.displayAdapter.impl.EventJob
!SESSION Wed Feb 01 20:03:27 CET 2006
------------------------------------------
!ENTRY org.eclipse.core.launcher 4 0 2006-02-01 20:03:27.335
!MESSAGE -showsplash
!STACK
java.io.IOException: CreateProcess:
E:\udig_sdk_1.1M2-nightlybuild.26012006\eclipse -name Eclipse
-showsplash 600
D:\dev\workspaces\uDig-workspace\.metadata\.plugins\org.eclipse.pde.core\uDig\org.eclipse.osgi\nl\fr\splash.bmp
error=2
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at org.eclipse.core.launcher.Main.runCommand(Main.java:1565)
at org.eclipse.core.launcher.Main.handleSplash(Main.java:1541)
at org.eclipse.core.launcher.Main.basicRun(Main.java:276)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel