Unable to use XStream in RCP [newbie]

128 views
Skip to first unread message

Mauro

unread,
Sep 14, 2009, 7:27:53 PM9/14/09
to vogella
Hi,
I'm a complete newbie to RCP and I am following Your tutorials to
learn something about it.
So far I've found the thing quite easy and clean.
Now I have the problem I want to save the model for my test app and
reload it later.
I have a quite simple model and I would like to avoid using a full-
fledged database.
A simple flat XML file would suffice (the actual data is well
represented by a tree with no loops).
It is unclear to me what is the best course of action, but I selected
XStream-1.3.1.
Unfortunately this doesn't seem to work well with RCP.

I have the following code in my command handler:

package it.condarelli.rcp.mcwriter.commands;

import it.condarelli.rcp.mcwriter.models.Model;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class SaveHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
XStream xs = new XStream(new DomDriver()); // does not require XPP3
library
Model m = Model.getModel();
String f = m.getFile();
if (f == null) {
f = "Model.xml";
m.setFile(f);
}
try {
FileOutputStream fs = new FileOutputStream(f);
xs.toXML(m, fs);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}

return null;
}

}

But Eclipse doesn't seem to find the classes in xstream-1.3.1.jar. The
IDE *does* find it, since I have no error/unresolved, but when I start
the application I et the following trace:

!SESSION 2009-09-15 01:19:57.460
-----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_15
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
Framework arguments: -product it.condarelli.rcp.mcwriter.product
Command-line arguments: -product it.condarelli.rcp.mcwriter.product -
data C:\Users\mauro\workspace/../runtime-
it.condarelli.rcp.mcwriter.product -dev file:C:/Users/mauro/
workspace/.metadata/.plugins/org.eclipse.pde.core/
it.condarelli.rcp.mcwriter.product/dev.properties -os win32 -ws win32 -
arch x86 -consoleLog

!ENTRY org.eclipse.ui 4 4 2009-09-15 01:20:01.285
!MESSAGE The proxied handler for
'it.condarelli.rcp.mcwriter.commands.SaveHandler' could not be loaded

!ENTRY org.eclipse.ui 4 0 2009-09-15 01:20:01.288
!MESSAGE The proxied handler for
'it.condarelli.rcp.mcwriter.commands.SaveHandler' could not be loaded
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in
"it.condarelli.rcp.mcwriter" was unable to instantiate class
"it.condarelli.rcp.mcwriter.commands.SaveHandler".
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException
(RegistryStrategyOSGI.java:180)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension
(RegistryStrategyOSGI.java:174)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension
(ExtensionRegistry.java:874)
at
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension
(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension
(ConfigurationElementHandle.java:51)
at org.eclipse.ui.internal.handlers.HandlerProxy.loadHandler
(HandlerProxy.java:351)
at org.eclipse.ui.internal.handlers.HandlerProxy.isEnabled
(HandlerProxy.java:320)
at org.eclipse.core.commands.Command.isEnabled(Command.java:833)
at org.eclipse.core.commands.Command.setHandler(Command.java:996)
at org.eclipse.ui.internal.handlers.HandlerAuthority.updateCommand
(HandlerAuthority.java:459)
at org.eclipse.ui.internal.handlers.HandlerAuthority.activateHandler
(HandlerAuthority.java:249)
at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
(HandlerService.java:120)
at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
(HandlerService.java:112)
at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
(HandlerService.java:107)
at
org.eclipse.ui.internal.handlers.HandlerPersistence.readDefaultHandlersFromRegistry
(HandlerPersistence.java:258)
at org.eclipse.ui.internal.handlers.HandlerPersistence.reRead
(HandlerPersistence.java:213)
at org.eclipse.ui.internal.handlers.HandlerPersistence.read
(HandlerPersistence.java:167)
at org.eclipse.ui.internal.handlers.HandlerService.readRegistry
(HandlerService.java:186)
at org.eclipse.ui.internal.handlers.HandlerServiceFactory.create
(HandlerServiceFactory.java:61)
at
org.eclipse.ui.internal.services.WorkbenchServiceRegistry.getService
(WorkbenchServiceRegistry.java:104)
at org.eclipse.ui.internal.services.ServiceLocator.getService
(ServiceLocator.java:174)
at org.eclipse.ui.internal.Workbench$44.runWithException
(Workbench.java:1698)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run
(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:
3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault
(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:
149)
at it.condarelli.rcp.mcwriter.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run
(EclipseAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication
(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start
(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/
HierarchicalStreamDriver
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension
(RegistryStrategyOSGI.java:170)
... 45 more
Caused by: java.lang.ClassNotFoundException:
com.thoughtworks.xstream.io.HierarchicalStreamDriver
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal
(BundleLoader.java:489)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass
(BundleLoader.java:405)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass
(BundleLoader.java:393)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass
(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 51 more
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2009-09-15 01:20:01.295
!MESSAGE Plug-in "it.condarelli.rcp.mcwriter" was unable to
instantiate class "it.condarelli.rcp.mcwriter.commands.SaveHandler".
!STACK 0
java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/
HierarchicalStreamDriver
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension
(RegistryStrategyOSGI.java:170)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension
(ExtensionRegistry.java:874)
at
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension
(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension
(ConfigurationElementHandle.java:51)
at org.eclipse.ui.internal.handlers.HandlerProxy.loadHandler
(HandlerProxy.java:351)
at org.eclipse.ui.internal.handlers.HandlerProxy.isEnabled
(HandlerProxy.java:320)
at org.eclipse.core.commands.Command.isEnabled(Command.java:833)
at org.eclipse.core.commands.Command.setHandler(Command.java:996)
at org.eclipse.ui.internal.handlers.HandlerAuthority.updateCommand
(HandlerAuthority.java:459)
at org.eclipse.ui.internal.handlers.HandlerAuthority.activateHandler
(HandlerAuthority.java:249)
at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
(HandlerService.java:120)
at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
(HandlerService.java:112)
at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
(HandlerService.java:107)
at
org.eclipse.ui.internal.handlers.HandlerPersistence.readDefaultHandlersFromRegistry
(HandlerPersistence.java:258)
at org.eclipse.ui.internal.handlers.HandlerPersistence.reRead
(HandlerPersistence.java:213)
at org.eclipse.ui.internal.handlers.HandlerPersistence.read
(HandlerPersistence.java:167)
at org.eclipse.ui.internal.handlers.HandlerService.readRegistry
(HandlerService.java:186)
at org.eclipse.ui.internal.handlers.HandlerServiceFactory.create
(HandlerServiceFactory.java:61)
at
org.eclipse.ui.internal.services.WorkbenchServiceRegistry.getService
(WorkbenchServiceRegistry.java:104)
at org.eclipse.ui.internal.services.ServiceLocator.getService
(ServiceLocator.java:174)
at org.eclipse.ui.internal.Workbench$44.runWithException
(Workbench.java:1698)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run
(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:
3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault
(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:
149)
at it.condarelli.rcp.mcwriter.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run
(EclipseAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication
(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start
(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.ClassNotFoundException:
com.thoughtworks.xstream.io.HierarchicalStreamDriver
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal
(BundleLoader.java:489)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass
(BundleLoader.java:405)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass
(BundleLoader.java:393)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass
(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 51 more

ANY hint would be very welcome.
I'm currently at Witt's End.

Thanks n Advance
Mauro

Lars Vogel

unread,
Sep 15, 2009, 1:21:58 AM9/15/09
to vog...@googlegroups.com
Hi Mauro,

for XML handling please see: http://www.vogella.de/articles/JavaXML/article.html

Please also see http://www.vogella.de/faq.html#ineedhelp for the kind of question I answer here.

Best regards, Lars

2009/9/15 Mauro <zio...@gmail.com>



--
Lars
http://www.vogella.de - Tutorials about Java, Eclipse and Web programming
http://www.twitter.com/vogella - Lars on Twitter

Lars Vogel

unread,
Sep 15, 2009, 1:24:49 AM9/15/09
to vog...@googlegroups.com
You may also want to check http://www.vogella.de/articles/EclipseJarToPlugin/article.html to learn how to use external libraries in Eclipse Plugin development.

2009/9/15 Lars Vogel <lars....@googlemail.com>

Mauro

unread,
Sep 15, 2009, 2:28:58 AM9/15/09
to vogella
Many thanks.

Both Your articles are very interesting.
I will try to follow Your advice.

I didn't really expect You to debug my stupid code, of course.
I just tried to send enough info to allow You to steer me unto the
Right Direction (TM).
I apparently succeeded (or You are a plain genius).
Thanks a lot again.

Mauro

On Sep 15, 7:24 am, Lars Vogel <lars.vo...@googlemail.com> wrote:
> You may also want to checkhttp://www.vogella.de/articles/EclipseJarToPlugin/article.htmlto learn how
> to use external libraries in Eclipse Plugin development.
>
> 2009/9/15 Lars Vogel <lars.vo...@googlemail.com>
>
> > Hi Mauro,
>
> > for XML handling please see:
> >http://www.vogella.de/articles/JavaXML/article.html
>
> > Please also seehttp://www.vogella.de/faq.html#ineedhelpfor the kind of
> > question I answer here.
>
> > Best regards, Lars
>
> > 2009/9/15 Mauro <ziob...@gmail.com>
> ...
>
> read more »

uwayo

unread,
Sep 16, 2009, 5:16:45 AM9/16/09
to vogella
hello Lars Vogel
I am a newbie to XML-RPC and i m using the the Apache XML-RPC and i
was following tutorial at http://www.tutorialspoint.com/xml-rpc/index.htm
and yours at http://www.vogella.de/articles/Eclipse/article.html
am getting this errors
and i have followed the correct procedure to add the .JAR files using
the eclipse

and for the server class am getting this error:
on this line :
WebServer
server = new WebServer(80);
WebServer cannot be resolved to a type
and for the Client Class am getting this error:
Description Resource Path Location Type
XmlRpcClient cannot be resolved to a type JavaClient.java /
uwayo.xmlRpc/src/uwayo/xmlRpc line 10 Java Problem

XmlRpcClient
server = new XmlRpcClient(http://localhost/RPC2);
for this line
Regards

On Sep 15, 9:28 am, Mauro <ziob...@gmail.com> wrote:
> Many thanks.
>
> Both Your articles are very interesting.
> I will try to follow Your advice.
>
> I didn't really expect You to debug my stupid code, of course.
> I just tried to send enough info to allow You to steer me unto the
> Right Direction (TM).
> I apparently succeeded  (or You are a plain genius).
> Thanks a lot again.
>
> Mauro
>
> On Sep 15, 7:24 am, Lars Vogel <lars.vo...@googlemail.com> wrote:
>
>
>
> > You may also want to checkhttp://www.vogella.de/articles/EclipseJarToPlugin/article.htmltolearn how
> > to use external libraries in Eclipse Plugin development.
>
> > 2009/9/15 Lars Vogel <lars.vo...@googlemail.com>
>
> > > Hi Mauro,
>
> > > for XML handling please see:
> > >http://www.vogella.de/articles/JavaXML/article.html
>
> > > Please also seehttp://www.vogella.de/faq.html#ineedhelpforthe kind of
> > >> org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutab­leExtension
> > >> (RegistryStrategyOSGI.java:174)
> > >>        at
>
> > >> org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtens­ion
> > >> (ExtensionRegistry.java:874)
> > >>        at
>
> > >> org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExt­ension
> > >> (ConfigurationElement.java:243)
> > >>        at
>
> > >> org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecuta­bleExtension
> > >> (ConfigurationElementHandle.java:51)
> > >>        at org.eclipse.ui.internal.handlers.HandlerProxy.loadHandler
> > >> (HandlerProxy.java:351)
> > >>        at org.eclipse.ui.internal.handlers.HandlerProxy.isEnabled
> > >> (HandlerProxy.java:320)
> > >>        at org.eclipse.core.commands.Command.isEnabled(Command.java:833)
> > >>        at org.eclipse.core.commands.Command.setHandler(Command.java:996)
> > >>        at org.eclipse.ui.internal.handlers.HandlerAuthority.updateCommand
> > >> (HandlerAuthority.java:459)
> > >>        at
> > >> org.eclipse.ui.internal.handlers.HandlerAuthority.activateHandler
> > >> (HandlerAuthority.java:249)
> > >>        at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
> > >> (HandlerService.java:120)
> > >>        at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
> > >> (HandlerService.java:112)
> > >>        at org.eclipse.ui.internal.handlers.HandlerService.activateHandler
> > >> (HandlerService.java:107)
> > >>        at
>
> > >> org.eclipse.ui.internal.handlers.HandlerPersistence.readDefaultHandlersFrom­Registry
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -

Lars Vogel

unread,
Sep 16, 2009, 5:18:47 AM9/16/09
to vog...@googlegroups.com
Hi,

please see http://www.vogella.de/faq.html#differenttutorial

Best regards, Lars

2009/9/16 uwayo <uway...@googlemail.com>
Reply all
Reply to author
Forward
0 new messages