| Summary: | URI of the resource ... does not match the nsURI ... of the top-level package | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Erdal Karaca <erdal.karaca.de> | ||||||||
| Component: | cdo.core | Assignee: | Eike Stepper <stepper> | ||||||||
| Status: | CLOSED WONTFIX | QA Contact: | Eike Stepper <stepper> | ||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | caspar_d, Michal.Tkacz, seifermann, stepper | ||||||||
| Version: | 4.2 | Flags: | caspar_d:
review+
|
||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Windows XP | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Erdal Karaca
Note: Each package is located in its own ecore file. Caspar, since the exception comes from CDOModelUtil.checkCrossResourceURIs(), can you please have a look at this? This isn't a bug. The check correctly identifies a problem. A dynamic package must be contained in a resource that is designated by a URI that matches the package's nsURI. (Or if the package is not a top-level package, by a URI that matches the URI of the package's containing top-level package.) By default, if you load up a resource from a file, the URI of the resource will be the file's location URI. Before you can use the package loaded in the resource with CDO, you need to set the resource's URI correctly (as specified in the preceding paragraph) by calling Resource.setURI(URI). In case you actually want to know WHY this is necessary: it is because the packages are serialized to XML using EMF's default serialization mechanism, which uses the URI of the containing resource for any cross-resource reference. But fileURI's are meaningless on the server side; only namespace URI's are meaningful. Therefore, before transmitting the packages, CDO ensures that the resource URI's match the nsURI's. Reopening to improve exception message Improved error message that describes the solution: URI of the resource (%s) does not match the nsURI (%s) of the top-level package; this can be fixed by calling Resource.setURI(URI) after loading the packages, or by configuring a URI mapping from nsURI's to location URI's before loading the packages, and then loading them with their nsURI's. Committed to HEAD Does the CDO UI provides that step, i.e. setting the URI on the resource? Though, if I use the CDO UI to create a new object, then why should I care to set the correct nsURI for that object? I.e. the CDO UI knows what nsURI to use, why does it not do it itself? (In reply to comment #7) > Though, if I use the CDO UI to create a new object, then why should I care to > set the correct nsURI for that object? I.e. the CDO UI knows what nsURI to use, > why does it not do it itself? I tend to agree with you but want to discuss that with Caspar tomorrow... I suppose if you use the CDO UI to load those packages, then the UI should set the URI's as needed, yes. But I never use nor develop the UI, so I'm not sure I'm the right guy to address that.. After some more internal discussion we decided to automatically adjust the resource URIs of new packages upon registration time in the core... Created attachment 186473 [details]
Patch v1
This seems to fix it. I must say I was a little surprised because I tested this with two related ecore files. I'm not yet sure how CDO has found the referenced ecore file after I replaced the resource URI of the referencing file. I guess all the resolution happens already when loading the first file, which would be okay...
Caspar can you review it?
Created attachment 186474 [details]
Patch v2 - adjustment at serialization time
All attempts to adjust the resource URIs lead to issues elsewhere. Note for me: see bug 303466. Erdal, are you happy for now with generated models or is it urgent to address this dynamic model issue immediately? Created attachment 186612 [details]
Patch v3
I guess I will have to redeploy the generated model each time I want to test it. This is not convenient, but OK as a workaround. Anyways, thanks for your support! Moving all open bug reports to 4.1 because the release is very near and it's hghly unlikely that there will be spare time to address 4.0 problems. Please make sure that your patches can be applied against the master branch and that your problem is not already fixed there!!! Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master. Nothing in patch v3 applies to master anymore. Please reopen this bug if you feel a need. The issue is still relevant. I tried to create a model and add an OCL expression element to the created model. The OCL expression elements are contained in a subpackage of the OCL package. Even when doing this via the UI, I get the exception mentioned by Erdal. I tried to apply the patch v3 but that leads to a stack overflow. Are there any plans to fix this? |