Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Acceleo Java Launcher
icon4.gif  Acceleo Java Launcher [message #642201] Tue, 30 November 2010 11:48 Go to next message
dieppi is currently offline dieppiFriend
Messages: 27
Registered: November 2010
Junior Member
Hi,

i use posted configuration for running my generator project via java launcher (Acceleo 3.0.1). But i always get the error message:

org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/uml2/2.0.0/UML' not found

I enhanced the method

public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UM LPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);

and the method

public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

But i always get the same error. If i use Acceleo plugin launcher everthing works fine. What can i do to solve these issue?

Best regards
Maik

P.S.
------------------------------------------
I also tested with

Map uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(" file:/D:/Programs/eclipse/plugins/org.eclipse.uml2.uml_3.1.1 .v201008191505.jar ");

uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
Re: Acceleo Java Launcher [message #642209 is a reply to message #642201] Tue, 30 November 2010 12:07 Go to previous messageGo to next message
Sebastien Roy is currently offline Sebastien RoyFriend
Messages: 51
Registered: November 2009
Member
Perhaps try to replace
resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UM LPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);

with the following :
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/uml2/2.0.0/UML", UMLPackage.eINSTANCE);


Sebastien
Re: Acceleo Java Launcher [message #642217 is a reply to message #642209] Tue, 30 November 2010 12:39 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Maik,

Sebastien's answer would work, but it would be better to keep your package registrations local to the resource set instead of adding to the global EPackage registry Razz.

The problem you have is that you're trying to load an UML model created with an older version of Eclipse. The URI of the UML project's metamodel has evolved from "http://www.eclipse.org/uml2/2.0.0/UML" to ""http://www.eclipse.org/uml2/3.0.0/UML" ... and thus EMF cannot find the "2.0.0" URI when you manually register the package.

in addition to the line you've already added :
resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);

Please add this one :
resourceSet.getPackageRegistry().put("http://www.eclipse.org/uml2/2.0.0/UML", org.eclipse.uml2.uml.UMLPackage.eINSTANCE);


Laurent Goubet
Obeo
Re: Acceleo Java Launcher [message #642227 is a reply to message #642209] Tue, 30 November 2010 13:22 Go to previous messageGo to next message
dieppi is currently offline dieppiFriend
Messages: 27
Registered: November 2010
Junior Member
Hi Sebastien and Laurent,

no i got another exception:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'StringLiteralExp' is not found or is abstract. (file:/com/test/bin/generate.emtl 13, 856)

Do i need an additional package to register?

[Updated on: Tue, 30 November 2010 16:13]

Report message to a moderator

Re: Acceleo Java Launcher [message #642402 is a reply to message #642227] Wed, 01 December 2010 07:57 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040301020509010705090607
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Maik,

This last one would indicate that you're missing the OCL package
registration ... but that registration should be handled by the
generated java launcher by default ... Have your removed any of the
lines from "registerPackages" when adding the registration of the UML
package? (Specifically, you need to call
super.registerPackages(resourceSet) from this method.)

Laurent Goubet
Obeo

On 30/11/2010 14:22, dieppi@gmx.de wrote:
> Hi Sebastien and Laurent,
>
> it works now as java application running in eclipse. Many thanks for that.
> Now i created a ant task. After running ant task i get the following
> error message
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
> ticWrappedException: org.eclipse.emf.ecore.xmi.ClassNotFoundException:
> Class 'StringLiteralExp' is not found or is abstract.
> (file:/com/test/generate.emtl 13, 856)
>
> Do i need an additional package to register?


--------------040301020509010705090607
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040301020509010705090607--
Re: Acceleo Java Launcher [message #642440 is a reply to message #642402] Wed, 01 December 2010 10:59 Go to previous messageGo to next message
dieppi is currently offline dieppiFriend
Messages: 27
Registered: November 2010
Junior Member
Hi Laurent,

thanks for your answer. But i have a strange behavior here. I think it depends on eclipse and how i finds the nesessary packages and profile.

My model is an uml file with additionally profile files. After adding the UML namespace http://www.eclipse.org/uml2/2.0.0/UML to method registerPackages i as able to run java launcher in eclipse as java application.

So i created a ant task. After starting the ant task i got the message class viewstate from my viewprofile cannot be found. So i added the viewprofile namespace to method registerPackages. After starting the ant task again i got the error message EClass cannot be found. So i added ecore namespace. After starting ant task again i got the error message StringLetralExp not found. So what can in do?

My model file has the following namespace

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:MagicDrawProfile="http:///schemas/MagicDrawProfile/_CAA84HhZEd-ijZRcwHp7Mw/0" xmlns:ViewProfile="http:///schemas/ViewProfile/_B_3y8HhZEd-ijZRcwHp7Mw/0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xsi:schemaLocation="http:///schemas/MagicDrawProfile/_CAA84HhZEd-ijZRcwHp7Mw/0 UML_Standard_Profile.MagicDraw_Profile.profile.uml#_CYqG33hZ Ed-ijZRcwHp7Mw http:///schemas/ViewProfile/_B_3y8HhZEd-ijZRcwHp7Mw/0 ViewProfile.profile.uml#_CYsi9nhZEd-ijZRcwHp7Mw">
<uml:Model xmi:id="eee_1045467100313_135436_1" name="test_model" viewpoint="">
<ownedComment xmi:id="_12_5_41801a3_1265618805392_492566_98" body="Author: Team&#xA;Created: 08.02.10 09:46Uhr&#xA;Title: Test&#xA;Comment: " annotatedElement="eee_1045467100313_135436_1"/>
<packageImport xmi:id="_0primitiveTypestest_model">
<importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packageImport xmi:id="_0javaPrimitiveTypestest_model">
<importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
</packageImport>

One of my profile file has to following namspace

<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xmi:id="_12_1_1_41801a3_1180279591484_435565_108" name="ViewProfile" metamodelReference="_0metamodelReferenceViewProfile">
<eAnnotations xmi:id="_CYsi9XhZEd-ijZRcwHp7Mw" source="http://www.eclipse.org/uml2/2.0.0/UML">
<contents xmi:type="ecore:EPackage" xmi:id="_CYsi9nhZEd-ijZRcwHp7Mw" name="ViewProfile" nsURI="http:///schemas/ViewProfile/_B_3y8HhZEd-ijZRcwHp7Mw/0" nsPrefix="ViewProfile">
<eClassifiers xmi:type="ecore:EClass" xmi:id="_CYsi93hZEd-ijZRcwHp7Mw" name="ViewState">

Is that the right way to register profiles in these method?

Best regards
Maik



Re: Acceleo Java Launcher [message #642450 is a reply to message #642440] Wed, 01 December 2010 11:57 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030605080701030407020604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Maik,

I must admit I don't know how to register profiles, but I do know
metamodel (your namespaces) registrations should be done through the
java launcher and its "registerPackage" method. The fact that your ant
task doesn't seem to find the Ecore metamodel even though it is
registered seems ... wrong.

In any case, "StringLiteralExp" is part of the OCL metamodel, and this
is the namespace you're missing. The Java launcher _should_ take care of
registering it properly. I don't remember the package hierarchy in which
StringLiteralExp is located, you can look at the org.eclipse.ocl plugin
and its "model/ocl.ecore" model, as it it the metamodel you're searching
for.

Laurent Goubet
Obeo

On 01/12/2010 11:59, Maik wrote:
> Hi Laurent,
>
> thanks for your answer. But i have a strange behavior here. I think it
> depends on eclipse and how i finds the nesessary packages and profile.
>
> My model is an uml file with additionally profile files. After adding
> the UML namespace http://www.eclipse.org/uml2/2.0.0/UML to method
> registerPackages i as able to run java launcher in eclipse as java
> application.
>
> So i created a ant task. After starting the ant task i got the message
> class viewstate from my viewprofile cannot be found. So i added the
> viewprofile namespace to method registerPackages. After starting the ant
> task again i got the error message EClass cannot be found. So i added
> ecore namespace. After starting ant task again i got the error message
> StringLetralExp not found. So what can in do?
>
> My model file has the following namespace
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:MagicDrawProfile="http:///schemas/MagicDrawProfile/_CAA84HhZEd-ijZRcwHp7Mw/0"
> xmlns:ViewProfile="http:///schemas/ViewProfile/_B_3y8HhZEd-ijZRcwHp7Mw/0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xsi:schemaLocation="http:///schemas/MagicDrawProfile/_CAA84HhZEd-ijZRcwHp7Mw/0
> UML_Standard_Profile.MagicDraw_Profile.profile.uml#_CYqG33hZ
> Ed-ijZRcwHp7Mw http:///schemas/ViewProfile/_B_3y8HhZEd-ijZRcwHp7Mw/0
> ViewProfile.profile.uml#_CYsi9nhZEd-ijZRcwHp7Mw">
> <uml:Model xmi:id="eee_1045467100313_135436_1" name="test_model"
> viewpoint="">
> <ownedComment xmi:id="_12_5_41801a3_1265618805392_492566_98"
> body="Author: Team
> Created: 08.02.10 09:46Uhr
> Title: Test
> Comment: " annotatedElement="eee_1045467100313_135436_1"/>
> <packageImport xmi:id="_0primitiveTypestest_model">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
> </packageImport>
> <packageImport xmi:id="_0javaPrimitiveTypestest_model">
> <importedPackage xmi:type="uml:Model"
> href="pathmap://UML_LIBRARIES/JavaPrimitiveTypes.library.uml#_0"/>
> </packageImport>
>
> One of my profile file has to following namspace
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_12_1_1_41801a3_1180279591484_435565_108" name="ViewProfile"
> metamodelReference="_0metamodelReferenceViewProfile">
> <eAnnotations xmi:id="_CYsi9XhZEd-ijZRcwHp7Mw"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <contents xmi:type="ecore:EPackage" xmi:id="_CYsi9nhZEd-ijZRcwHp7Mw"
> name="ViewProfile"
> nsURI="http:///schemas/ViewProfile/_B_3y8HhZEd-ijZRcwHp7Mw/0"
> nsPrefix="ViewProfile">
> <eClassifiers xmi:type="ecore:EClass" xmi:id="_CYsi93hZEd-ijZRcwHp7Mw"
> name="ViewState">
>
> Is that the right way to register profiles in these method?
>
> Best regards
> Maik
>
>
>
>


--------------030605080701030407020604
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------030605080701030407020604--
Re: Acceleo Java Launcher [message #643349 is a reply to message #642450] Mon, 06 December 2010 15:34 Go to previous message
dieppi is currently offline dieppiFriend
Messages: 27
Registered: November 2010
Junior Member
Hi Laurent,

i solved the problem. It was a additional entry in method registerResourceFactories

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "uml", UMLResource.Factory.INSTANCE);

After adding these entry the ant task works fine....


Maik
Previous Topic:[Acceleo] How to test for empty/null reference?
Next Topic:[Xpand] Root element not found
Goto Forum:
  


Current Time: Tue Oct 08 22:51:12 GMT 2024

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

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

Back to the top