Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » P/Users, does not match outer scope rule
P/Users, does not match outer scope rule [message #992231] Fri, 21 December 2012 06:54 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 124
Registered: November 2010
Senior Member
In a button, on execAction, I try to write a file. I get this error:

!ENTRY <none> 4 0 2012-12-21 07:49:34.976
!MESSAGE Attempted to beginRule: P/Users, does not match outer scope rule: org.eclipse.scout.rt.client.ClientRule@37a5e471
!STACK 0
java.lang.IllegalArgumentException: Attempted to beginRule: P/Users, does not match outer scope rule: org.eclipse.scout.rt.client.ClientRule@37a5e471
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
	at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:134)
	at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:333)
	at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:85)
	at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:286)
	at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:118)
	at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:2282)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:92)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:125)
	at ...


What should I do?

Re: P/Users, does not match outer scope rule [message #992821 is a reply to message #992231] Sat, 22 December 2012 18:53 Go to previous messageGo to next message
Adrian MoserFriend
Messages: 67
Registered: March 2011
Member
Sounds strange, could you post parts of the source code throwing the exception?

Adrian
Re: P/Users, does not match outer scope rule [message #993841 is a reply to message #992231] Tue, 25 December 2012 17:35 Go to previous messageGo to next message
Lukas Huser is currently offline Lukas HuserFriend
Messages: 42
Registered: March 2010
Member
Hi Jérémie

It looks like you get this error because of conflicting scheduling rules while accessing a resource (a file or folder).

Code executed in one of the Scout model classes (such as execClickAction() on a button) is typically running inside a ClientSyncJob. All ClientSyncJobs are guaranteed to run sequentially; the current implementation is using a scheduling rule (ClientRule) which is set on the job. An ISchedulingRule basically represents a semaphore, allowing for exclusive access to a given resource, or in our case, for a sequential scheduling order. However, by design of the Jobs API, any given job can only aquire a single scheduling rule at the time (unless you are using hierarchical scheduling rules...).

An IResource (a file or a folder) also represents (inherits from) ISchedulingRule. Any (modifying) access to such a resource is guarded by the respective scheduling rule. We now get a runtime exception when trying to aquire the scheduling rule for such a resource, because we are already holding an (unrelated) scheduling rule in our ClientSyncJob.

For more information on the Jobs API and scheduling rules, see the following references:
http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html
http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/runtime_jobs_rules.htm?cp=2_0_3_5_2

As a workaround, it should be possible to start another ClientAsyncJob (which does not hold any scheduling rules) from within execClickAction to perform your resource related operations. You can wait for the async job to finish using the join() method.
Re: P/Users, does not match outer scope rule [message #995829 is a reply to message #993841] Mon, 31 December 2012 08:04 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
@Adrian Moser:
I try to serialize an EObject to XMI with the ECore tools (Bundle: org.eclipse.emf.ecore.xmi).

A minimal example could be:
@Override
protected void execClickAction() throws ProcessingException {
  EPackage ePackage;
  ePackage = EcoreFactory.eINSTANCE.createEPackage()
  ePackage.setName("test");
  ePackage.setNsPrefix("t");
  ePackage.setNsURI("http://test.com/test");
  
  ResourceSetImpl resourceSet = new ResourceSetImpl(); 
  resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
  URI uri = URI.createURI(ROOT_PATH + "test.ecore"); 
  org.eclipse.emf.ecore.resource.Resource resource = resourceSet.createResource(uri); 
  
  resource.getContents().add(ePackage);
  try {
    resource.save(null);
  } catch (IOException e) {
    e.printStackTrace();
  }
}



@Lukas Huser:
Thanks for your explanation. I can imagine that the ECore XML serializer consider the Eclipse resource... I will try to schedule a new job that write my file to the disk.

[Updated on: Mon, 31 December 2012 08:05]

Report message to a moderator

Re: P/Users, does not match outer scope rule [message #996554 is a reply to message #995829] Wed, 02 January 2013 11:09 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I have isolated my code in a job (I serialize the EMF Object eForm to XMI):
Job job = new Job("Save to XMI: " + eForm.getClassName()) {
  @Override
  protected IStatus run(IProgressMonitor monitor) {
    XMIUtility.toXMI(eForm);
    return Status.OK_STATUS;
  }
};
job.schedule();


It works!


Many thanks to Lukas Huser !!!
Previous Topic:Auto refresh page
Next Topic:Trouble with images being cached
Goto Forum:
  


Current Time: Fri Apr 19 23:28:22 GMT 2024

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

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

Back to the top