Skip to main content



      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 01:54 Go to next message
Eclipse UserFriend
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 13:53 Go to previous messageGo to next message
Eclipse UserFriend
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 12:35 Go to previous messageGo to next message
Eclipse UserFriend
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 03:04 Go to previous messageGo to next message
Eclipse UserFriend
@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 03:05] by Moderator

Re: P/Users, does not match outer scope rule [message #996554 is a reply to message #995829] Wed, 02 January 2013 06:09 Go to previous message
Eclipse UserFriend
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: Tue Jul 22 18:44:35 EDT 2025

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

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

Back to the top