[Acceleo] Problem starting Acceleo from within Magicdraw Plugin [message #1747398] |
Mon, 14 November 2016 05:11  |
Eclipse User |
|
|
|
Hello,
i am using Acceleo to generate Java Code out of a Model created with Magicdraw.
If i save the Model to a file and load this file into a resource in a java program running in eclipse everything works fine.
Here is my code:
ResourceSet resSet = new ResourceSetImpl();
resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new UMLResourceFactoryImpl());
Resource metaResource = resSet.createResource(URI.createFileURI(new File("E:/eclipse32/XMIFiles/Traffic_Lights(1).uml").getAbsolutePath()));
EPackage.Registry.INSTANCE.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
try {
metaResource.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
Generate codeGenerator = new Generate(metaResource.getContents().get(0), new File("E:/CPSModeler/workspace/[...]/genSrc"),Collections.emptyList());
codeGenerator.registerPackages(resSet);
codeGenerator.registerResourceFactories(resSet);
codeGenerator.doGenerate(null);
If i call the same program from within a magicdraw plugin (which is started in debug mode in eclipse) i get the following error message:
2016-11-14 11:04:41,966 [AWT-EventQueue-0] ERROR GENERAL -
java.lang.NullPointerException
at org.eclipse.acceleo.common.internal.utils.workspace.AcceleoWorkspaceUtil.getResourceURL(AcceleoWorkspaceUtil.java:278)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.findModuleURL(AbstractAcceleoGenerator.java:746)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:408)
at cpsModeler.logic.interceptor.codeGenerator.main.Generate.<init>(Generate.java:111)
at cpsModeler.logic.interceptor.codeGenerator.resourceLoadTest.generate(resourceLoadTest.java:41)
at cpsModeler.userInterface.gui.InterceptorAction.actionPerformed(InterceptorAction.java:95)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.doClick(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI$MouseInputHandler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.nomagic.utils.EventTracker.dispatchEvent(EventTracker.java:33)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Do you have any suggestions where this error may come from and what to do about it?
Best regards
|
|
|
|
Re: [Acceleo] Problem starting Acceleo from within Magicdraw Plugin [message #1748084 is a reply to message #1748067] |
Fri, 18 November 2016 06:31  |
Eclipse User |
|
|
|
Hi,
thanks for your reply.
First of all, i found a workaround today to avoid this problem, i just send the model via activemq to a standalone application, which works fine.
As the problem might be of interest for the future let me explain better what i do:
I develop a plugin for magicdraw. Therefor i have a project in eclipse to start the magicdraw application (which is a java application running in osgi framework) from within eclipse so i do not need to deploy the plugin but have it as dependency in the magicdraw project so magicdraw loads it from the workspace.
If there should be no solution, as it might be that MagicDraw has no workspace support, than this can be closed as i now use a workaround. I was just wondering what the problem might be.
|
|
|
Powered by
FUDForum. Page generated in 0.04232 seconds