Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » another "Cannot modify resource set without a write transaction"
another "Cannot modify resource set without a write transaction" [message #155525] Tue, 16 October 2007 03:55 Go to next message
Eclipse UserFriend
Originally posted by: r.c.ladan.tue.nl

This is a multi-part message in MIME format.
--------------020709070809070004050305
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi,

does anybody know what causes the attached exception?
It gets thrown in doParse() (MetaEditor.java:139), but not
always:

(100) doParse(((NodeImpl)((EObject)((GraphicalEditPart)((IStructur edSelection)this.sel).getFirstElement()).getModel())).getEle ment());
where this.sel is an ISelection set in the IActionDelegate.selectionChanged() listener

public void doParse(EObject eobj) {
ResourceSet rs = new ResourceSetImpl();
Resource eRes = rs.createResource(URI.createURI("http://com.tue.scenario"));
Resource res = eobj.eResource();
(139) eRes.getContents().add(eobj);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
eRes.save(baos, null);
} catch (IOException ioe) {
ioe.printStackTrace();
return;
}
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
// call a method having bais as parameter
res.getContents().addAll(eRes.getContents()); // put eobj back in

The same code works ok in an EMF editor.
It looks a bit cumbersome, but this seems to be the shortest
way to pass the XMI serialization of an EObject to a method.

Versions:
* GMF 1.0.100 20070921-0000, build id 2.0.1
* Eclipse 3.4.0 I20070921-0919
* EMF 2.3.0 I20070925-2135
* GEF 3.4.0 20070919

Thanks,
Rene

--------------020709070809070004050305
Content-Type: text/plain;
name="unhandled event loop exception.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="unhandled event loop exception.txt"

java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:322)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:284)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:266)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:222)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:319)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 26)
at call_custom.MetaEditor.doParse(MetaEditor.java:139)
at call_custom.MetaEditor.run(MetaEditor.java:97)
at org.eclipse.ui.internal.handlers.ActionDelegateHandlerProxy. execute(ActionDelegateHandlerProxy.java:289)
at org.eclipse.core.commands.Command.executeWithChecks(Command. java:475)
at org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:429)
at org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:165)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeComman d(WorkbenchKeyboard.java:470)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Workben chKeyboard.java:821)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEve nt(WorkbenchKeyboard.java:879)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequ enceBindings(WorkbenchKeyboard.java:568)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Work benchKeyboard.java:510)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter .handleEvent(WorkbenchKeyboard.java:126)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:115 0)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:975)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:971)
at org.eclipse.swt.widgets.Widget.wmKeyDown(Widget.java:1571)
at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:4002 )
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3703 )
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:370)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4422 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:23 19)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3351)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
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: 515)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:455)
at org.eclipse.equinox.launcher.Main.run(Main.java:1193)
at org.eclipse.equinox.launcher.Main.main(Main.java:1169)

--------------020709070809070004050305--
Re: another "Cannot modify resource set without a write transaction" [message #155538 is a reply to message #155525] Tue, 16 October 2007 04:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi Rene,

I guess in such situation please use a AbstractTransactionalCommand it
goes like this -

AbstractTransactionalCommand command = new
AbstractTransactionalCommand(editingDomain,"SOME STRING", null)
{
protected CommandResult doExecuteWithResult(IProgressMonitor
monitor,Adaptable info)throws ExecutionException {
try {
\\ code you wish to execute
\\ doParse(((NodeImpl)((EObj etc etc in your case
}
return CommandResult.newOKCommandResult();
}
};
try {
OperationHistoryFactory.getOperationHistory().execute(comman d,
new NullProgressMonitor(), null);
}

Hope this removes your exception :-)
cheers,
Arpit
Re: another "Cannot modify resource set without a write transaction" [message #155798 is a reply to message #155538] Tue, 16 October 2007 09:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: r.c.ladan.tue.nl

Arpit wrote:
> I guess in such situation please use a AbstractTransactionalCommand it
> goes like this -

> AbstractTransactionalCommand command = new
> AbstractTransactionalCommand(editingDomain,"SOME STRING", null) {
> protected CommandResult doExecuteWithResult(IProgressMonitor
> monitor,Adaptable info)throws ExecutionException {
> try {
> \\ code you wish to execute \\
> doParse(((NodeImpl)((EObj etc etc in your case
> }
> return CommandResult.newOKCommandResult();
> }
> };
> try {
> OperationHistoryFactory.getOperationHistory().execute(comman d,
> new NullProgressMonitor(), null);
> }

> Hope this removes your exception :-)

It doesn't :( , it just moved from the Error view in the generated
editor to the Console view in the main Eclipse.

I added the above code to the run() handler since the doParse() method
was originally called from there. I defined the
editingDomain variable as

TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE.createEditingDomain();

I also tried declaring it as
TransactionalEditingDomain editingDomain =
((IGraphicalEditPart) getHost()).getEditingDomain();
and let the class extend SemanticEditPolicy, but that gave an
unexplained null pointer exception.

Any idea what's wrong?

Thanks,
Rene
Re: another "Cannot modify resource set without a write transaction" [message #156121 is a reply to message #155798] Wed, 17 October 2007 12:54 Go to previous message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Rene,

Can you debug to the point where you are about to create the Transaction as
Arpit suggested
and see if a transaction is already active ?
You can check this by checking your editing domain variable - active
transaction.

If there is one already active you may need to share the transaction.
This can occurs when you are trying to change resource1 when there is
already a transaction open for resource2
You can search the EMFT help for transaction sharing info.

If this is the case and you have are having problems let me know as I have
done this recently


"Rene Ladan" <r.c.ladan@tue.nl> wrote in message
news:ff2cnd$seh$1@build.eclipse.org...
> Arpit wrote:
>> I guess in such situation please use a AbstractTransactionalCommand it
>> goes like this -
>
>> AbstractTransactionalCommand command = new
>> AbstractTransactionalCommand(editingDomain,"SOME STRING", null) {
>> protected CommandResult doExecuteWithResult(IProgressMonitor
>> monitor,Adaptable info)throws ExecutionException {
>> try {
>> \\ code you wish to execute \\
>> doParse(((NodeImpl)((EObj etc etc in your case
>> }
>> return CommandResult.newOKCommandResult();
>> }
>> };
>> try {
>> OperationHistoryFactory.getOperationHistory().execute(comman d,
>> new NullProgressMonitor(), null);
>> }
>
>> Hope this removes your exception :-)
>
> It doesn't :( , it just moved from the Error view in the generated
> editor to the Console view in the main Eclipse.
>
> I added the above code to the run() handler since the doParse() method
> was originally called from there. I defined the
> editingDomain variable as
>
> TransactionalEditingDomain editingDomain =
> GMFEditingDomainFactory.INSTANCE.createEditingDomain();
>
> I also tried declaring it as
> TransactionalEditingDomain editingDomain =
> ((IGraphicalEditPart) getHost()).getEditingDomain();
> and let the class extend SemanticEditPolicy, but that gave an
> unexplained null pointer exception.
>
> Any idea what's wrong?
>
> Thanks,
> Rene
Previous Topic:GraphicalEditPart.isSelectable() throws NullPointerException
Next Topic:Graphical modeler testing
Goto Forum:
  


Current Time: Sat May 10 08:29:49 EDT 2025

Powered by FUDForum. Page generated in 0.03207 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top