It's all about the answers!

Ask a question

[closed] Getting ImmutablePropertyException while modifying project a


Hung Lam (2911915) | asked Jul 30 '08, 5:09 p.m.
JAZZ DEVELOPER
closed Nov 13 '16, 6:14 a.m. by Ralph Schoon (63.7k33648)
Hello,
I am trying to programatically modify the process configurations of the
project area, I got this exception when trying to save the working copy
after the modifications.

Here is the my code to save the project area. Any ideas what I am doing
wrong? Thanks.

IProjectArea workingCopy = (IProjectArea)
itemService.getMutableCopy(projArea);

workingCopy.getProcessData().put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY,cnt);



com.ibm.team.repository.common.internal.ImmutablePropertyException
at
com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2047)
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
com.ibm.team.process.internal.common.impl.ProcessDataEntryImpl.setTypedValue(ProcessDataEntryImpl.java:214)
at
com.ibm.team.process.internal.common.impl.ProcessDataEntryImpl.setValue(ProcessDataEntryImpl.java:450)
at org.eclipse.emf.common.util.BasicEMap.putEntry(BasicEMap.java:303)
at org.eclipse.emf.common.util.BasicEMap.put(BasicEMap.java:584)
at
org.eclipse.emf.common.util.BasicEMap$DelegatingMap.put(BasicEMap.java:799)
at
com.ibm.teami.client.feature.scm.UpdateProcessAction.debug(UpdateProcessAction.java:120)

The question has been closed for the following reason: "The question is answered, right answer was accepted" by rschoon Nov 13 '16, 6:14 a.m.

Accepted answer


permanent link
Hung Lam (2911915) | answered Jul 30 '08, 9:56 p.m.
JAZZ DEVELOPER
Thanks Kai,
I modified my code a bit and was able to get the changes saved in the
project area. Here is what I did:

Before:
IProjectArea projArea = ......;
IContent cnt = projArea.getProcessData().get(....);
.........
IProjectArea workingCopy = (IProjectArea) service.getMutableCopy(projArea);
workingCopy.getProcessData().put(...);

After:
IProjectArea projArea = ......;
IProjectArea workingCopy = service.getMutableCopy(projArea);
IContent cnt = workingCopy.getProcessData().get(...);
......
workingCopy.getProcessData().put(....);


Kai-Uwe Maetzel wrote:
IPE usually means that the item you try to modify is not a working copy.
So given your code snippet and assuming it is complete, things should
work. Our code follows the same pattern.

Kai
Jazz Process team

hvlam wrote:
Hello,
I am trying to programatically modify the process configurations of
the project area, I got this exception when trying to save the working
copy after the modifications.

Here is the my code to save the project area. Any ideas what I am
doing wrong? Thanks.

IProjectArea workingCopy = (IProjectArea)
itemService.getMutableCopy(projArea);

workingCopy.getProcessData().put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY,cnt);




com.ibm.team.repository.common.internal.ImmutablePropertyException
at
com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2047)

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
com.ibm.team.process.internal.common.impl.ProcessDataEntryImpl.setTypedValue(ProcessDataEntryImpl.java:214)

at
com.ibm.team.process.internal.common.impl.ProcessDataEntryImpl.setValue(ProcessDataEntryImpl.java:450)

at org.eclipse.emf.common.util.BasicEMap.putEntry(BasicEMap.java:303)
at org.eclipse.emf.common.util.BasicEMap.put(BasicEMap.java:584)
at
org.eclipse.emf.common.util.BasicEMap$DelegatingMap.put(BasicEMap.java:799)

at
com.ibm.teami.client.feature.scm.UpdateProcessAction.debug(UpdateProcessAction.java:120)
Ralph Schoon selected this answer as the correct answer

6 other answers



permanent link
Dibyandu Roy (111) | answered Nov 11 '16, 5:55 p.m.

Hung Lam i am trying to automate the archival of a project area. When I execute this command, I am getting this error.


projectArea.setArchived(true)

Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2134)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
at com.ibm.team.process.internal.common.impl.ProcessAreaImpl.setArchived(ProcessAreaImpl.java:563)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:619)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at com.sun.proxy.$Proxy16.setArchived(Unknown Source)
at com.intel.ArchiveProject.ArchiveProject.analyzeProjectArea(ArchiveProject.java:250)
at com.intel.ArchiveProject.ArchiveProject.run(ArchiveProject.java:183)
at com.intel.ArchiveProject.ArchiveProject.main(ArchiveProject.java:96)
Any help is appreciated :)

permanent link
Hung Lam (2911915) | answered Aug 01 '08, 10:09 a.m.
JAZZ DEVELOPER
Hi Christof,
Thanks. I am using the same keys for the content, so I wouldn't have
tihs problem. Again, thank you.

Christof Marti wrote:
It depends, if you use different keys with the same content, like:

IContent cnt= workingCopy.getProcessData().get("keyA");
workingCopy.getProcessData().put("keyB", cnt);

I'd expect workingCopy.getProcessData().get("keyA") to be null because
the content moved over to "keyB", which might not be what you intended.
One way around this would be to create a copy of the content using
EcoreUtil.copy(cnt) and use that with put(...).

Christof
Jazz Work Item team


hvlam wrote:
Hi Christof, thank you for your reply.
You mentioned that EMF will do the automatic updates of the
containment references. I am not quite sure what this means. Would
this cause any problem with the new code?

Christof Marti wrote:
The IPE occurred because you took the IContent from the *immutable
item* and since EMF updates containment references behind the scenes
adding that IContent to the *working copy* also removed it from the
immutable item, which triggered the IPE. In the new code you take the
IContent from the working copy, EMF will still do its automatic
updates of the containment references.

Regards,

Christof
Jazz Work Item team


hvlam wrote:
Thanks Kai,
I modified my code a bit and was able to get the changes saved in
the project area. Here is what I did:

Before:
IProjectArea projArea = ......;
IContent cnt = projArea.getProcessData().get(....);
........
IProjectArea workingCopy = (IProjectArea)
service.getMutableCopy(projArea);
workingCopy.getProcessData().put(...);

After:
IProjectArea projArea = ......;
IProjectArea workingCopy = service.getMutableCopy(projArea);
IContent cnt = workingCopy.getProcessData().get(...);
.....
workingCopy.getProcessData().put(....);


permanent link
Christof Marti (681) | answered Jul 31 '08, 11:47 a.m.
It depends, if you use different keys with the same content, like:

IContent cnt= workingCopy.getProcessData().get("keyA");
workingCopy.getProcessData().put("keyB", cnt);

I'd expect workingCopy.getProcessData().get("keyA") to be null because the content moved over to "keyB", which might not be what you intended. One way around this would be to create a copy of the content using EcoreUtil.copy(cnt) and use that with put(...).

Christof
Jazz Work Item team


hvlam wrote:
Hi Christof, thank you for your reply.
You mentioned that EMF will do the automatic updates of the containment
references. I am not quite sure what this means. Would this cause any
problem with the new code?

Christof Marti wrote:
The IPE occurred because you took the IContent from the *immutable
item* and since EMF updates containment references behind the scenes
adding that IContent to the *working copy* also removed it from the
immutable item, which triggered the IPE. In the new code you take the
IContent from the working copy, EMF will still do its automatic
updates of the containment references.

Regards,

Christof
Jazz Work Item team


hvlam wrote:
Thanks Kai,
I modified my code a bit and was able to get the changes saved in the
project area. Here is what I did:

Before:
IProjectArea projArea = ......;
IContent cnt = projArea.getProcessData().get(....);
........
IProjectArea workingCopy = (IProjectArea)
service.getMutableCopy(projArea);
workingCopy.getProcessData().put(...);

After:
IProjectArea projArea = ......;
IProjectArea workingCopy = service.getMutableCopy(projArea);
IContent cnt = workingCopy.getProcessData().get(...);
.....
workingCopy.getProcessData().put(....);


permanent link
Hung Lam (2911915) | answered Jul 31 '08, 9:41 a.m.
JAZZ DEVELOPER
Hi Christof, thank you for your reply.
You mentioned that EMF will do the automatic updates of the containment
references. I am not quite sure what this means. Would this cause any
problem with the new code?

Christof Marti wrote:
The IPE occurred because you took the IContent from the *immutable item*
and since EMF updates containment references behind the scenes adding
that IContent to the *working copy* also removed it from the immutable
item, which triggered the IPE. In the new code you take the IContent
from the working copy, EMF will still do its automatic updates of the
containment references.

Regards,

Christof
Jazz Work Item team


hvlam wrote:
Thanks Kai,
I modified my code a bit and was able to get the changes saved in the
project area. Here is what I did:

Before:
IProjectArea projArea = ......;
IContent cnt = projArea.getProcessData().get(....);
........
IProjectArea workingCopy = (IProjectArea)
service.getMutableCopy(projArea);
workingCopy.getProcessData().put(...);

After:
IProjectArea projArea = ......;
IProjectArea workingCopy = service.getMutableCopy(projArea);
IContent cnt = workingCopy.getProcessData().get(...);
.....
workingCopy.getProcessData().put(....);


permanent link
Christof Marti (681) | answered Jul 31 '08, 3:14 a.m.
The IPE occurred because you took the IContent from the *immutable item* and since EMF updates containment references behind the scenes adding that IContent to the *working copy* also removed it from the immutable item, which triggered the IPE. In the new code you take the IContent from the working copy, EMF will still do its automatic updates of the containment references.

Regards,

Christof
Jazz Work Item team


hvlam wrote:
Thanks Kai,
I modified my code a bit and was able to get the changes saved in the
project area. Here is what I did:

Before:
IProjectArea projArea = ......;
IContent cnt = projArea.getProcessData().get(....);
........
IProjectArea workingCopy = (IProjectArea) service.getMutableCopy(projArea);
workingCopy.getProcessData().put(...);

After:
IProjectArea projArea = ......;
IProjectArea workingCopy = service.getMutableCopy(projArea);
IContent cnt = workingCopy.getProcessData().get(...);
.....
workingCopy.getProcessData().put(....);


permanent link
Kai-Uwe Maetzel (85611) | answered Jul 30 '08, 5:50 p.m.
JAZZ DEVELOPER
IPE usually means that the item you try to modify is not a working copy.
So given your code snippet and assuming it is complete, things should
work. Our code follows the same pattern.

Kai
Jazz Process team

hvlam wrote:
Hello,
I am trying to programatically modify the process configurations of the
project area, I got this exception when trying to save the working copy
after the modifications.

Here is the my code to save the project area. Any ideas what I am doing
wrong? Thanks.

IProjectArea workingCopy = (IProjectArea)
itemService.getMutableCopy(projArea);

workingCopy.getProcessData().put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY,cnt);




com.ibm.team.repository.common.internal.ImmutablePropertyException
at
com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2047)

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
com.ibm.team.process.internal.common.impl.ProcessDataEntryImpl.setTypedValue(ProcessDataEntryImpl.java:214)

at
com.ibm.team.process.internal.common.impl.ProcessDataEntryImpl.setValue(ProcessDataEntryImpl.java:450)

at org.eclipse.emf.common.util.BasicEMap.putEntry(BasicEMap.java:303)
at org.eclipse.emf.common.util.BasicEMap.put(BasicEMap.java:584)
at
org.eclipse.emf.common.util.BasicEMap$DelegatingMap.put(BasicEMap.java:799)
at
com.ibm.teami.client.feature.scm.UpdateProcessAction.debug(UpdateProcessAction.java:120)