问题
I am new to Accelo.
First, I have created my DSL metamodel ( pfe.ecore) and then I generated the Java classes of this metamodel using Accelo based on the .Ecore[I got .java file for each class of my metamodel] _the name of the Accelo project is MyTransformationM2T.1st attachment shows the workplace image
Second, I have created Sirius graphical model (MyPfe.pfe)based on my DSL on Eclipse Run time that contains the diagram (VLC) that I want to generate its java codesee 2nd attachment, for that, I have created another Acceleo project in the workplace(org.eclipse.aceleo.sirius) and then I have imported in this project the file( MyPfe.pfe): see the 3rd attachment
Now I want just to make sure that I am on the right path, before going further, I wrote some text in the file generate.mtl of (org.eclipse.aceleo.sirius ) project and I launch an Accelo run configuration, see attachment 3
just after, I got a run error
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.example.org/pfe' not found. (file:/C:/Users/ABL/Desktop/PFE/ObeoDesigner-Community/workspace/org.eclipse.acceleo.sirius/MyPfe.pfe, 2, 172)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:391)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:356)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:488)
at org.eclipse.acceleo.sirius.main.Generate.<init>(Generate.java:90)
at org.eclipse.acceleo.sirius.main.Generate.main(Generate.java:144)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.example.org/pfe' not found. (file:/C:/Users/ABL/Desktop/PFE/ObeoDesigner-Community/workspace/org.eclipse.acceleo.sirius/MyPfe.pfe, 2, 172)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2643)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2476)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1353)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1522)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1044)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:78)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:720)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
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.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1342)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 6 more
I tried to fix the problem by inserting this line in the Generate.java ->registerPackages
if (!isInWorkspace(PfePackage.class)) {
resourceSet.getPackageRegistry().put(PfePackage.eNS_URI, PfePackage.eINSTANCE);
}
But it doesn't work [error: PfePachage cannot be solved to a type], I think I should install some dependencies in MANIFEST.MF but I don't know what to do that.
Kindly,
a. It is necessary to generate the java code of the metamodel (DSL) before generating the code of the graphical model ?
b. Should I work on the same accel project or as I did above 2 Accelo projects (one for the generation of the metamodel and the second for the graphical model)?
c.How can I generate the java code of the graphics diagram VLC?
d. How can I fix the error of the package and which dependencies I should add?
来源:https://stackoverflow.com/questions/62574760/how-do-i-generate-java-code-from-my-graphical-diagram-using-acceleo