Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Launching a module from Java
[Acceleo] Launching a module from Java [message #539481] Thu, 10 June 2010 21:59 Go to next message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Hi all, I am having some trouble launching an Acceleo module with java, I have this main file:

[comment encoding = UTF-8 /]
[module main('http://www.eclipse.org/uml2/2.1.0/UML')/]

[import org::acceleo::module::pim::uml21::gen::java::class /]
[import org::acceleo::module::pim::uml21::gen::java::enum /]
[import org::acceleo::module::pim::uml21::gen::java::interface /]
[import org::acceleo::module::pim::uml21::gen::java::validator::core /]

[template public main(m : Model)]
[comment @main /]

[comment Call the file block in 'class' /]
[m.packagedElement->filter(Class).classJava() /]

[comment Call the file block in 'enum' /]
[ m.packagedElement->filter(Enumeration).enumJava() /]

[comment Call the file block in 'interface' /]
[ m.packagedElement->filter(Interface).interfaceJava() /]

[comment Call the file block in 'core' /]
[ validator() /]

[/template]

Then I want to run it on a model using java so I do:

java Main othermodels/DosClases.uml othermodels

DosClases.uml is a uml model.

And I dont know why I got this:

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found. ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml, 2, 231)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:315)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils. java:346)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator. initialize(AbstractAcceleoGenerator.java:311)
at org.acceleo.module.pim.uml21.gen.java.migrated.files.Main.<init >(Main.java:83)
at org.acceleo.module.pim.uml21.gen.java.migrated.files.Main.ma in(Main.java:125)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found. ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml, 2, 231)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2591)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2422)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
... 5 more


Why is searching for a package with the name of the metamodel?

Thank you very much.
Re: [Acceleo] Launching a module from Java [message #539536 is a reply to message #539481] Fri, 11 June 2010 08:31 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.
--------------050808060607070402010809
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

The "package with URI '*' not found" problem indicates that you're
trying to run your generation standalone while not registering the UML
metamodel. Two possibilities :

1) You're using an Acceleo launch configuration to launch your
generation and don't need it to be standalone. In this case you just
have to open your launch configuration and change the combo box at the
bottom from "Java Application" to "Acceleo Plug-in Application".

2) You want the generation to be runnable standalone. In this case you
will need to open the generated Java class (Main.java) and change the
"registerPackage" and "registerResourceFactory" methods to properly
register the UML package and factories (there should be a commented out
line in the methods with the code needed, otherwise you'll have to
follow the explanations on :
http://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_lo ad_a_UML_.28.uml.29_resource_from_a_standalone_application.3 F
)

Laurent Goubet
Obeo

Daniel wrote:
> Hi all, I am having some trouble launching an Acceleo module with java,
> I have this main file:
>
> [comment encoding = UTF-8 /]
> [module main('http://www.eclipse.org/uml2/2.1.0/UML')/]
>
> [import org::acceleo::module::pim::uml21::gen::java::class /]
> [import org::acceleo::module::pim::uml21::gen::java::enum /]
> [import org::acceleo::module::pim::uml21::gen::java::interface /]
> [import org::acceleo::module::pim::uml21::gen::java::validator::core /]
>
> [template public main(m : Model)]
> [comment @main /]
>
> [comment Call the file block in 'class' /]
> [m.packagedElement->filter(Class).classJava() /]
>
> [comment Call the file block in 'enum' /]
> [ m.packagedElement->filter(Enumeration).enumJava() /]
>
> [comment Call the file block in 'interface' /]
> [ m.packagedElement->filter(Interface).interfaceJava() /]
>
> [comment Call the file block in 'core' /]
> [ validator() /]
>
> [/template]
>
> Then I want to run it on a model using java so I do:
>
> java Main othermodels/DosClases.uml othermodels
>
> DosClases.uml is a uml model.
>
> And I dont know why I got this:
>
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
> ticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException:
> Package with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found.
> ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml,
> 2, 231)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe
> mandLoadException(ResourceSetImpl.java:315)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:274)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou
> rce(ResourceSetImpl.java:397)
> at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.
> java:346)
> at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.
> initialize(AbstractAcceleoGenerator.java:311)
> at org.acceleo.module.pim.uml21.gen.java.migrated.files.Main.<init
> >(Main.java:83)
> at org.acceleo.module.pim.uml21.gen.java.migrated.files.Main.ma
> in(Main.java:125)
> Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
> with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found.
> ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml,
> 2, 231)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X
> MLHandler.java:2591)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi
> x(XMLHandler.java:2422)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType
> (XMLHandler.java:1299)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM
> LHandler.java:1468)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
> Handler.java:1019)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI
> Handler.java:83)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:1001)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:712)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa
> ndler.java:169)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .startElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.
> startElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanStartElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl$ContentDriver.scanRootElementHook(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl$FragmentContentDriver.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl$PrologDriver.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanDocument(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U
> nknown Source)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA
> XParser.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.
> java:181)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes
> ourceImpl.java:180)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1494)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1282)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> ad(ResourceSetImpl.java:255)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:270)
> ... 5 more
>
>
> Why is searching for a package with the name of the metamodel?
>
> Thank you very much.


--------------050808060607070402010809
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=
--------------050808060607070402010809--
Re: [Acceleo] Launching a module from Java [message #539620 is a reply to message #539536] Fri, 11 June 2010 14:12 Go to previous messageGo to next message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Hi, I have tryed to follow the steps but it seems I dont get it:

1- How do i do not to get my code overwritten?

I think it is something related to the tag @Override, but I have been looking in the documentation and I dont find how to make my added code permanent.

2- I have added to the Main.java the following imports (I think) I needed for the added lines:

import java.util.*;
import org.eclipse.uml2.uml.*;
import org.eclipse.uml2.uml.resource.*;

2- Then I added the lines, and I added them where I think they should be added, in the registerPackages and getResourceFactory methods but I dont know if it is correct. Also, instead of:

URI uri = URI.createURI(" jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_ 2.0.0.v200606221411.jar!/ ");

I put my 3.1 jar:

URI uri = URI.createURI(" jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_ 3.1.0.v201005031530.jar!/ ");

This is the result:

/**
* This can be used to update the resource set's package registry with all needed EPackages.
*
* @param resourceSet
* The resource set which registry has to be updated.
* @generated
*/
@Override
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);

// TODO If you need additional package registrations, do them here. The following line is an example for UML.
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
}

/**
* This can be used to update the resource set's resource factory registry with all needed factories.
*
* @param resourceSet
* The resource set which registry has to be updated.
* @generated
*/
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);

// TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(" jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_ 3.1.0.v201005031530.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(""));

}

}


I dont know if am I doing it right and I dont also know if I have to call this methods from anywhere, but I thought it was the program how should call them.

Doing this I keep getting:

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found. ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml, 2, 231)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:315)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils. java:346)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator. initialize(AbstractAcceleoGenerator.java:311)
at org.acceleo.module.pim.uml21.gen.java.migrated.files.Main.<init >(Main.java:89)
at org.acceleo.module.pim.uml21.gen.java.migrated.files.Main.ma in(Main.java:131)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found. ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml, 2, 231)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2591)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2422)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
... 5 more

Thank you very much.
Re: [Acceleo] Launching a module from Java [message #539734 is a reply to message #539620] Sat, 12 June 2010 09:43 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.
--------------090002060005020805070301
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

See my comments inlined below.

Laurent Goubet
Obeo

Daniel wrote:
> Hi, I have tryed to follow the steps but it seems I dont get it:
>
> 1- How do i do not to get my code overwritten?
>
> I think it is something related to the tag @Override, but I have been
> looking in the documentation and I dont find how to make my added code
> permanent.

Simply alter the javadoc tag "@generated". Remove it, change it to
"@generated NOT", change it to "@not-generated" ... As you would for any
code generated by EMF.

>
> 2- I have added to the Main.java the following imports (I think) I
> needed for the added lines:
>
> import java.util.*;
> import org.eclipse.uml2.uml.*;
> import org.eclipse.uml2.uml.resource.*;

Yup, you need these.

>
> 2- Then I added the lines, and I added them where I think they should be
> added, in the registerPackages and getResourceFactory methods but I dont
> know if it is correct. Also, instead of:
>
> URI uri = URI.createURI("
> jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_
> 2.0.0.v200606221411.jar!/ ");
>
> I put my 3.1 jar:
>
> URI uri = URI.createURI("
> jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_
> 3.1.0.v201005031530.jar!/ ");

That's how it is intended. As long as you're sure this location actually
points to an existing jar file.

>
> This is the result:
>
> /**
> * This can be used to update the resource set's package registry
> with all needed EPackages.
> * * @param resourceSet
> * The resource set which registry has to be updated.
> * @generated
> */
> @Override
> 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);

Seems like the UMLPackage was already registered...

>
> // TODO If you need additional package registrations, do them here.
> The following line is an example for UML.
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE); }
>
> /**
> * This can be used to update the resource set's resource factory
> registry with all needed factories.
> * * @param resourceSet
> * The resource set which registry has to be updated.
> * @generated
> */
> @Override
> public void registerResourceFactories(ResourceSet resourceSet) {
> super.registerResourceFactories(resourceSet);
>
> // TODO If you need additional resource factories registrations, do
> them here. The following line is an example for UML.
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto
> ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri = URI.createURI("
> jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_
> 3.1.0.v201005031530.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(""));
>
> }
>
> }
>
>
> I dont know if am I doing it right and I dont also know if I have to
> call this methods from anywhere, but I thought it was the program how
> should call them.

You don't have to call them manually, the superclass takes care of the
calling.

>
> Doing this I keep getting:
>
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
> ticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException:
> Package with uri 'http://www.eclipse.org/uml2/2.1.0/UML' not found.
> ( file:///C:/Users/Dell/workspace/org.acceleo.module.pim.uml21 .gen.java.migrated/othermodels/DosClases.uml,
> 2, 231)

Yup, I misunderstood the issue. You're in Eclipse 3.6, not in Eclipse
3.5; thus the UML NsURI you get through
"UMLPackage.eINSTANCE.getNsURI()" is
"http://www.eclipse.org/uml2/3.0.0/UML" (3.0.0) and not
"http://www.eclipse.org/uml2/2.1.0/UML" (2.1.0). You need to add this
last one manually, with an hard-coded String (well, there might be a
constant for it somewhere, but I don't know where that would be). You
need to add this line to the "registerPackages" method :

resourceSet.getPackageRegistry().put("http://www.eclipse.org/uml2/2.1.0/UML",
UMLPackage.eINSTANCE);

There might be a better way to do this ... but you'll have to ask on the
UML newsgroup as I don't know of any.

> Thank you very much.


--------------090002060005020805070301
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=
--------------090002060005020805070301--
Re: [Acceleo] Launching a module from Java [message #539814 is a reply to message #539481] Sun, 13 June 2010 16:19 Go to previous messageGo to next message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Ok thank you very much!

One thing I didnt understand was:

"Seems like the UMLPackage was already registered..."

How do I see that? and also, registering it again like I do could cause any problem?

Anyway I do the changes you told me:

/**
* This can be used to update the resource set's package registry with all needed EPackages.
*
* @param resourceSet
* The resource set which registry has to be updated.
* @not-generated
*/
@Override
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);
// NASGUN
// TODO If you need additional package registrations, do them here. The following line is an example for UML.
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put("http://www.eclipse.org/uml2/2.1.0/UML", UMLPackage.eINSTANCE);
}

/**
* This can be used to update the resource set's resource factory registry with all needed factories.
*
* @param resourceSet
* The resource set which registry has to be updated.
* @not-generated
*/
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);
// NASGUN
// TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(" jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_ 3.1.0.v201005031530.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(""));

}

And now I dont get any exception Smile

The problem is that it only terminates and anything else, but I think the problem here is in the module, because when I tried to launch it with Acceleo I didnt get anything:

http://www.eclipse.org/forums/index.php?t=msg&goto=53962 5&#msg_539625

And I dont know why is that.

Also one more question, if I modify the Main.java like I have done, can I have any problem to launch it from Acceleo, I mean, not standalone?

Thank you very much for your help!
Re: [Acceleo] Launching a module from Java [message #540808 is a reply to message #539814] Thu, 17 June 2010 12:13 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.
--------------090607070307080202070206
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

See comments inlined below.

Laurent Goubet
Obeo

Daniel wrote:
> Ok thank you very much!
>
> One thing I didnt understand was:
>
> "Seems like the UMLPackage was already registered..."
>
> How do I see that? and also, registering it again like I do could cause
> any problem?

The line just above my comment :
resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UM
LPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);

is the same as what you did just below :
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);

Adding it again doesn't pose any issue.

>
> Anyway I do the changes you told me:
>
> /**
> * This can be used to update the resource set's package registry
> with all needed EPackages.
> * * @param resourceSet
> * The resource set which registry has to be updated.
> * @not-generated
> */
> @Override
> 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);
> // NASGUN
> // TODO If you need additional package registrations, do them here.
> The following line is an example for UML.
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put("http://www.eclipse.org/uml2/2.1.0/UML",
> UMLPackage.eINSTANCE);
> }
>
> /**
> * This can be used to update the resource set's resource factory
> registry with all needed factories.
> * * @param resourceSet
> * The resource set which registry has to be updated.
> * @not-generated
> */
> @Override
> public void registerResourceFactories(ResourceSet resourceSet) {
> super.registerResourceFactories(resourceSet);
> // NASGUN
> // TODO If you need additional resource factories registrations, do
> them here. The following line is an example for UML.
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto
> ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri = URI.createURI("
> jar:file:/C:/eclipse/plugins/org.eclipse.uml2.uml.resources_
> 3.1.0.v201005031530.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(""));
>
> }
>
> And now I dont get any exception :)
>
> The problem is that it only terminates and anything else, but I think
> the problem here is in the module, because when I tried to launch it
> with Acceleo I didnt get anything:
>
> http://www.eclipse.org/forums/index.php?t=msg&goto=53962 5&#msg_539625
>
> And I dont know why is that.

i'll try and answer this in your other message.

>
> Also one more question, if I modify the Main.java like I have done, can
> I have any problem to launch it from Acceleo, I mean, not standalone?

Nope, except if you add things in the java launcher that aren't
standalone themselves (if you have to add an import line for
"org.eclipse.core.*" or "org.osgi.*" ... you're prolly doing a "non
standalone" thing :p)

>
> Thank you very much for your help!


--------------090607070307080202070206
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=
--------------090607070307080202070206--
Re: [Acceleo] Launching a module from Java [message #540921 is a reply to message #540808] Thu, 17 June 2010 15:53 Go to previous message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Ok, I got it!

Thank you.
Previous Topic:In my model, Class not found or is abstract
Next Topic:[Xpand] Optimize succeeding workflow calls
Goto Forum:
  


Current Time: Fri Mar 29 11:02:36 GMT 2024

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

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

Back to the top