Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction
EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58122] Thu, 19 October 2006 11:27 Go to next message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
I'm moving my editing code from AdapterFactoryEditingDomain to
TransactionalEditingDomain. All my changes to the model were done with
editing domain and it's stack. After switching to TransEdDomain I got
such execptions:

java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:239)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:195)
at
org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(Eleme ntImpl.java:821)
at
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
at
org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
at
org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
at
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:147)
at
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:183)
....

This is piece of code that makes me mad:

PrimitiveType type = UML2ModelUtil.UML_FACTORY.createPrimitiveType();
type.setName(propertyType);
type.setVisibility(VisibilityKind.PRIVATE_LITERAL);

Property newProperty = UML2ModelUtil.UML_FACTORY.createProperty();
newProperty.setVisibility(VisibilityKind.PRIVATE_LITERAL);
newProperty.setName(propertyName);
newProperty.setType(type);


EStructuralFeature eStructuralFeature=
UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute( );
Collection commandCollection=new ArrayList();
commandCollection.add(newProperty);
CommandParameter commandParameter = new
CommandParameter(umlClass,eStructuralFeature,commandCollecti on);

TransactionalEditingDomain editingDomain =
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n(EDITING_DOMAIN_ID);

Command command =
editingDomain.createCommand(AddCommand.class,commandParamete r);

try {
commandStack.execute(command);
} catch (Exception exception) {
// Here I catch java.lang.IllegalStateException
}

What am I missing? Something specific to TransactionalEditingDomain like
"start transaction" method?

Regards,
Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58177 is a reply to message #58122] Thu, 19 October 2006 12:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Marcin,

It looks to me as though the code snippet below is using the wrong command
stack to execute this command. I cannot see how the 'commandStack'
variable is initialized, but I don't think it's coming from the
'editingDomain' that was initialized just a few lines previous to the
execution of the command.

Use editingDomain.getCommandStack().execute(command) and all should be well.
It is the transactional editing domain's stack that creates the
transactions for you.

HTH,

Christian


ciukes wrote:

> I'm moving my editing code from AdapterFactoryEditingDomain to
> TransactionalEditingDomain. All my changes to the model were done with
> editing domain and it's stack. After switching to TransEdDomain I got
> such execptions:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:239)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:195)
> at
>
org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(Eleme ntImpl.java:821)
> at
>
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
> at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
> at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
> at
>
org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
> at
>
org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
> at
>
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)
> at
>
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:147)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:183)
> ...
>
> This is piece of code that makes me mad:
>
> PrimitiveType type = UML2ModelUtil.UML_FACTORY.createPrimitiveType();
> type.setName(propertyType);
> type.setVisibility(VisibilityKind.PRIVATE_LITERAL);
>
> Property newProperty = UML2ModelUtil.UML_FACTORY.createProperty();
> newProperty.setVisibility(VisibilityKind.PRIVATE_LITERAL);
> newProperty.setName(propertyName);
> newProperty.setType(type);
>
>
> EStructuralFeature eStructuralFeature=
> UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute( );
> Collection commandCollection=new ArrayList();
> commandCollection.add(newProperty);
> CommandParameter commandParameter = new
> CommandParameter(umlClass,eStructuralFeature,commandCollecti on);
>
> TransactionalEditingDomain editingDomain =
>
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n(EDITING_DOMAIN_ID);
>
> Command command =
> editingDomain.createCommand(AddCommand.class,commandParamete r);
>
> try {
> commandStack.execute(command);
> } catch (Exception exception) {
> // Here I catch java.lang.IllegalStateException
> }
>
> What am I missing? Something specific to TransactionalEditingDomain like
> "start transaction" method?
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58250 is a reply to message #58177] Thu, 19 October 2006 14:06 Go to previous messageGo to next message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
Christian W. Damus wrote:
> Hi, Marcin,
>
> It looks to me as though the code snippet below is using the wrong command
> stack to execute this command. I cannot see how the 'commandStack'
> variable is initialized, but I don't think it's coming from the
> 'editingDomain' that was initialized just a few lines previous to the
> execution of the command.
>
> Use editingDomain.getCommandStack().execute(command) and all should be well.
> It is the transactional editing domain's stack that creates the
> transactions for you.
This is extacly how I get command stack.

editingDomain is
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain
which extends TransactionalEditingDomainImpl

editingDomain.getCommandStack() is
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl which
implements InternalTransactionalCommandStack
and InternalTransactionalCommandStack extends TransactionalCommandStack

I've found that EMF command is wrapped by
WorkspaceCommandStackImpl.execute(Command)
in EMFCommandOperation

according to EMFCommandOperation's javadoc:
/**
* An operation that wraps an EMF {@link Command} to execute it in a
read/write
* transaction on an {@link IOperationHistory}. This class may be created
* explicitly by a client of the operation history, or it may be used
implicitly
* by executing a command on the {@link TransactionalCommandStack}.
*
* @author Christian W. Damus (cdamus)
*/
I'm almost sure I should use
TransactionalCommandStack.execute(Command,Map) and pass transaction options.

What do you think? Do I follow right path?

Regards,
Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58328 is a reply to message #58250] Thu, 19 October 2006 14:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Marcin,

Perhaps, then, what is happening is that the umlClass object is in a
different resource set than the one associated with your editing domain?
It seems clear that the TransactionalEditingDomain in which the command
execution is starting a transaction is different from the one that is
throwing the IllegalStateException, because it has no active transaction.

With a breakpoint on the throwing of the IllegalStateException, can you
confirm whether the TransactionalEditingDomain associated with the change
recorder is the same as or different from the one associated with the
WorkspaceCommandStackImpl farther down the execution stack?

Christian


ciukes wrote:

> Christian W. Damus wrote:
>> Hi, Marcin,
>>
>> It looks to me as though the code snippet below is using the wrong
>> command
>> stack to execute this command. I cannot see how the 'commandStack'
>> variable is initialized, but I don't think it's coming from the
>> 'editingDomain' that was initialized just a few lines previous to the
>> execution of the command.
>>
>> Use editingDomain.getCommandStack().execute(command) and all should be
>> well. It is the transactional editing domain's stack that creates the
>> transactions for you.
> This is extacly how I get command stack.
>
> editingDomain is
>
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain
> which extends TransactionalEditingDomainImpl
>
> editingDomain.getCommandStack() is
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl which
> implements InternalTransactionalCommandStack
> and InternalTransactionalCommandStack extends TransactionalCommandStack
>
> I've found that EMF command is wrapped by
> WorkspaceCommandStackImpl.execute(Command)
> in EMFCommandOperation
>
> according to EMFCommandOperation's javadoc:
> /**
> * An operation that wraps an EMF {@link Command} to execute it in a
> read/write
> * transaction on an {@link IOperationHistory}. This class may be
> created * explicitly by a client of the operation history, or it may be
> used
> implicitly
> * by executing a command on the {@link TransactionalCommandStack}.
> *
> * @author Christian W. Damus (cdamus)
> */
> I'm almost sure I should use
> TransactionalCommandStack.execute(Command,Map) and pass transaction
> options.
>
> What do you think? Do I follow right path?
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58351 is a reply to message #58122] Thu, 19 October 2006 15:45 Go to previous messageGo to next message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
Silly me:) Mystery is revealed.

I used different Editing Domain instance when reading resource. At that
moment Editing Domain is attached to the model and consumes
notifications. When command was executed with different Editing Domain
instance I got this problem. Different instance was executing command
from that one consuming notification. Obviously they don't share
transaction informations. So when it comes to TransactionChangeRecorder
it has no knowledge about transaction used to execute command (see
stacktrace). Simple change in one line fixed problem.

Solution is: Make sure you are using same Editing Domain for everything
not only for execution:)

Thanks for all of you for supporting me!:)

Regards,
Marcin.

ciukes wrote:
> I'm moving my editing code from AdapterFactoryEditingDomain to
> TransactionalEditingDomain. All my changes to the model were done with
> editing domain and it's stack. After switching to TransEdDomain I got
> such execptions:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:239)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:195)
>
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(Eleme ntImpl.java:821)
>
> at
> org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
>
> at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
> at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
> at
> org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
>
> at
> org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
>
> at
> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)
>
> at
> org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
>
> at
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:147)
>
> at
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:183)
>
> ...
>
> This is piece of code that makes me mad:
>
> PrimitiveType type = UML2ModelUtil.UML_FACTORY.createPrimitiveType();
> type.setName(propertyType);
> type.setVisibility(VisibilityKind.PRIVATE_LITERAL);
>
> Property newProperty = UML2ModelUtil.UML_FACTORY.createProperty();
> newProperty.setVisibility(VisibilityKind.PRIVATE_LITERAL);
> newProperty.setName(propertyName);
> newProperty.setType(type);
>
>
> EStructuralFeature eStructuralFeature=
> UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute( );
> Collection commandCollection=new ArrayList();
> commandCollection.add(newProperty);
> CommandParameter commandParameter = new
> CommandParameter(umlClass,eStructuralFeature,commandCollecti on);
>
> TransactionalEditingDomain editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n(EDITING_DOMAIN_ID);
>
>
> Command command =
> editingDomain.createCommand(AddCommand.class,commandParamete r);
>
> try {
> commandStack.execute(command);
> } catch (Exception exception) {
> // Here I catch java.lang.IllegalStateException
> }
>
> What am I missing? Something specific to TransactionalEditingDomain like
> "start transaction" method?
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58374 is a reply to message #58351] Thu, 19 October 2006 19:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Marcin,

I'm glad it's working for you, now!

What you have observed is that a TransactionalEditingDomain, once a resource
or object enters into its sphere of influence, "owns" that resource or
object and will not share it with other editing domains. The EMFT
Transaction world-view of editing domains is that they are closed universes
and that they do not communicate, as is commonly accepted (though not
proven) in cosmology.

That said, there is supposed to be a way to dispose of a
TransactionalEditingDomain that would "free" the resources and objects
within it. There are limitations to this that are tracked by
https://bugs.eclipse.org/bugs/show_bug.cgi?id=161169.

Cheers,

Christian


ciukes wrote:

> Silly me:) Mystery is revealed.
>
> I used different Editing Domain instance when reading resource. At that
> moment Editing Domain is attached to the model and consumes
> notifications. When command was executed with different Editing Domain
> instance I got this problem. Different instance was executing command
> from that one consuming notification. Obviously they don't share
> transaction informations. So when it comes to TransactionChangeRecorder
> it has no knowledge about transaction used to execute command (see
> stacktrace). Simple change in one line fixed problem.
>
> Solution is: Make sure you are using same Editing Domain for everything
> not only for execution:)
>
> Thanks for all of you for supporting me!:)
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #58417 is a reply to message #58374] Fri, 20 October 2006 10:09 Go to previous message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
Christian W. Damus wrote:
> Hi, Marcin,
>
> I'm glad it's working for you, now!
>
> What you have observed is that a TransactionalEditingDomain, once a resource
> or object enters into its sphere of influence, "owns" that resource or
> object and will not share it with other editing domains. The EMFT
> Transaction world-view of editing domains is that they are closed universes
> and that they do not communicate, as is commonly accepted (though not
> proven) in cosmology.
>
> That said, there is supposed to be a way to dispose of a
> TransactionalEditingDomain that would "free" the resources and objects
> within it. There are limitations to this that are tracked by
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=161169.
>
> Cheers,
>
> Christian
That helps me with my first steps in EMFT Trans world.

Thanks,
Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #594342 is a reply to message #58122] Thu, 19 October 2006 12:41 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Marcin,

It looks to me as though the code snippet below is using the wrong command
stack to execute this command. I cannot see how the 'commandStack'
variable is initialized, but I don't think it's coming from the
'editingDomain' that was initialized just a few lines previous to the
execution of the command.

Use editingDomain.getCommandStack().execute(command) and all should be well.
It is the transactional editing domain's stack that creates the
transactions for you.

HTH,

Christian


ciukes wrote:

> I'm moving my editing code from AdapterFactoryEditingDomain to
> TransactionalEditingDomain. All my changes to the model were done with
> editing domain and it's stack. After switching to TransEdDomain I got
> such execptions:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:239)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:195)
> at
>
org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(Eleme ntImpl.java:821)
> at
>
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
> at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
> at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
> at
>
org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
> at
>
org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
> at
>
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)
> at
>
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:147)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:183)
> ...
>
> This is piece of code that makes me mad:
>
> PrimitiveType type = UML2ModelUtil.UML_FACTORY.createPrimitiveType();
> type.setName(propertyType);
> type.setVisibility(VisibilityKind.PRIVATE_LITERAL);
>
> Property newProperty = UML2ModelUtil.UML_FACTORY.createProperty();
> newProperty.setVisibility(VisibilityKind.PRIVATE_LITERAL);
> newProperty.setName(propertyName);
> newProperty.setType(type);
>
>
> EStructuralFeature eStructuralFeature=
> UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute( );
> Collection commandCollection=new ArrayList();
> commandCollection.add(newProperty);
> CommandParameter commandParameter = new
> CommandParameter(umlClass,eStructuralFeature,commandCollecti on);
>
> TransactionalEditingDomain editingDomain =
>
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n(EDITING_DOMAIN_ID);
>
> Command command =
> editingDomain.createCommand(AddCommand.class,commandParamete r);
>
> try {
> commandStack.execute(command);
> } catch (Exception exception) {
> // Here I catch java.lang.IllegalStateException
> }
>
> What am I missing? Something specific to TransactionalEditingDomain like
> "start transaction" method?
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #594376 is a reply to message #58177] Thu, 19 October 2006 14:06 Go to previous message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
Christian W. Damus wrote:
> Hi, Marcin,
>
> It looks to me as though the code snippet below is using the wrong command
> stack to execute this command. I cannot see how the 'commandStack'
> variable is initialized, but I don't think it's coming from the
> 'editingDomain' that was initialized just a few lines previous to the
> execution of the command.
>
> Use editingDomain.getCommandStack().execute(command) and all should be well.
> It is the transactional editing domain's stack that creates the
> transactions for you.
This is extacly how I get command stack.

editingDomain is
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain
which extends TransactionalEditingDomainImpl

editingDomain.getCommandStack() is
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl which
implements InternalTransactionalCommandStack
and InternalTransactionalCommandStack extends TransactionalCommandStack

I've found that EMF command is wrapped by
WorkspaceCommandStackImpl.execute(Command)
in EMFCommandOperation

according to EMFCommandOperation's javadoc:
/**
* An operation that wraps an EMF {@link Command} to execute it in a
read/write
* transaction on an {@link IOperationHistory}. This class may be created
* explicitly by a client of the operation history, or it may be used
implicitly
* by executing a command on the {@link TransactionalCommandStack}.
*
* @author Christian W. Damus (cdamus)
*/
I'm almost sure I should use
TransactionalCommandStack.execute(Command,Map) and pass transaction options.

What do you think? Do I follow right path?

Regards,
Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #594403 is a reply to message #58250] Thu, 19 October 2006 14:17 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Marcin,

Perhaps, then, what is happening is that the umlClass object is in a
different resource set than the one associated with your editing domain?
It seems clear that the TransactionalEditingDomain in which the command
execution is starting a transaction is different from the one that is
throwing the IllegalStateException, because it has no active transaction.

With a breakpoint on the throwing of the IllegalStateException, can you
confirm whether the TransactionalEditingDomain associated with the change
recorder is the same as or different from the one associated with the
WorkspaceCommandStackImpl farther down the execution stack?

Christian


ciukes wrote:

> Christian W. Damus wrote:
>> Hi, Marcin,
>>
>> It looks to me as though the code snippet below is using the wrong
>> command
>> stack to execute this command. I cannot see how the 'commandStack'
>> variable is initialized, but I don't think it's coming from the
>> 'editingDomain' that was initialized just a few lines previous to the
>> execution of the command.
>>
>> Use editingDomain.getCommandStack().execute(command) and all should be
>> well. It is the transactional editing domain's stack that creates the
>> transactions for you.
> This is extacly how I get command stack.
>
> editingDomain is
>
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain
> which extends TransactionalEditingDomainImpl
>
> editingDomain.getCommandStack() is
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl which
> implements InternalTransactionalCommandStack
> and InternalTransactionalCommandStack extends TransactionalCommandStack
>
> I've found that EMF command is wrapped by
> WorkspaceCommandStackImpl.execute(Command)
> in EMFCommandOperation
>
> according to EMFCommandOperation's javadoc:
> /**
> * An operation that wraps an EMF {@link Command} to execute it in a
> read/write
> * transaction on an {@link IOperationHistory}. This class may be
> created * explicitly by a client of the operation history, or it may be
> used
> implicitly
> * by executing a command on the {@link TransactionalCommandStack}.
> *
> * @author Christian W. Damus (cdamus)
> */
> I'm almost sure I should use
> TransactionalCommandStack.execute(Command,Map) and pass transaction
> options.
>
> What do you think? Do I follow right path?
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #594412 is a reply to message #58122] Thu, 19 October 2006 15:45 Go to previous message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
Silly me:) Mystery is revealed.

I used different Editing Domain instance when reading resource. At that
moment Editing Domain is attached to the model and consumes
notifications. When command was executed with different Editing Domain
instance I got this problem. Different instance was executing command
from that one consuming notification. Obviously they don't share
transaction informations. So when it comes to TransactionChangeRecorder
it has no knowledge about transaction used to execute command (see
stacktrace). Simple change in one line fixed problem.

Solution is: Make sure you are using same Editing Domain for everything
not only for execution:)

Thanks for all of you for supporting me!:)

Regards,
Marcin.

ciukes wrote:
> I'm moving my editing code from AdapterFactoryEditingDomain to
> TransactionalEditingDomain. All my changes to the model were done with
> editing domain and it's stack. After switching to TransEdDomain I got
> such execptions:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:295)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:257)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:239)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:195)
>
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.eNotify(Eleme ntImpl.java:821)
>
> at
> org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
>
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
>
> at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
> at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
> at
> org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
>
> at
> org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
>
> at
> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)
>
> at
> org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
>
> at
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:147)
>
> at
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:183)
>
> ...
>
> This is piece of code that makes me mad:
>
> PrimitiveType type = UML2ModelUtil.UML_FACTORY.createPrimitiveType();
> type.setName(propertyType);
> type.setVisibility(VisibilityKind.PRIVATE_LITERAL);
>
> Property newProperty = UML2ModelUtil.UML_FACTORY.createProperty();
> newProperty.setVisibility(VisibilityKind.PRIVATE_LITERAL);
> newProperty.setName(propertyName);
> newProperty.setType(type);
>
>
> EStructuralFeature eStructuralFeature=
> UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute( );
> Collection commandCollection=new ArrayList();
> commandCollection.add(newProperty);
> CommandParameter commandParameter = new
> CommandParameter(umlClass,eStructuralFeature,commandCollecti on);
>
> TransactionalEditingDomain editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n(EDITING_DOMAIN_ID);
>
>
> Command command =
> editingDomain.createCommand(AddCommand.class,commandParamete r);
>
> try {
> commandStack.execute(command);
> } catch (Exception exception) {
> // Here I catch java.lang.IllegalStateException
> }
>
> What am I missing? Something specific to TransactionalEditingDomain like
> "start transaction" method?
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #594422 is a reply to message #58351] Thu, 19 October 2006 19:47 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Marcin,

I'm glad it's working for you, now!

What you have observed is that a TransactionalEditingDomain, once a resource
or object enters into its sphere of influence, "owns" that resource or
object and will not share it with other editing domains. The EMFT
Transaction world-view of editing domains is that they are closed universes
and that they do not communicate, as is commonly accepted (though not
proven) in cosmology.

That said, there is supposed to be a way to dispose of a
TransactionalEditingDomain that would "free" the resources and objects
within it. There are limitations to this that are tracked by
https://bugs.eclipse.org/bugs/show_bug.cgi?id=161169

Cheers,

Christian


ciukes wrote:

> Silly me:) Mystery is revealed.
>
> I used different Editing Domain instance when reading resource. At that
> moment Editing Domain is attached to the model and consumes
> notifications. When command was executed with different Editing Domain
> instance I got this problem. Different instance was executing command
> from that one consuming notification. Obviously they don't share
> transaction informations. So when it comes to TransactionChangeRecorder
> it has no knowledge about transaction used to execute command (see
> stacktrace). Simple change in one line fixed problem.
>
> Solution is: Make sure you are using same Editing Domain for everything
> not only for execution:)
>
> Thanks for all of you for supporting me!:)
>
> Regards,
> Marcin.
Re: EMFT Transaction 1.0.1: Cannot modify resource set without a write transaction [message #594441 is a reply to message #58374] Fri, 20 October 2006 10:09 Go to previous message
ciukes is currently offline ciukesFriend
Messages: 19
Registered: July 2009
Junior Member
Christian W. Damus wrote:
> Hi, Marcin,
>
> I'm glad it's working for you, now!
>
> What you have observed is that a TransactionalEditingDomain, once a resource
> or object enters into its sphere of influence, "owns" that resource or
> object and will not share it with other editing domains. The EMFT
> Transaction world-view of editing domains is that they are closed universes
> and that they do not communicate, as is commonly accepted (though not
> proven) in cosmology.
>
> That said, there is supposed to be a way to dispose of a
> TransactionalEditingDomain that would "free" the resources and objects
> within it. There are limitations to this that are tracked by
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=161169
>
> Cheers,
>
> Christian
That helps me with my first steps in EMFT Trans world.

Thanks,
Marcin.
Previous Topic:Teneo : persistence of objects URI
Next Topic:teneo - annotations in Rational Rose model - anyone?
Goto Forum:
  


Current Time: Fri Apr 19 12:01:31 GMT 2024

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

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

Back to the top