Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Problem starting Acceleo from within Magicdraw Plugin
[Acceleo] Problem starting Acceleo from within Magicdraw Plugin [message #1747398] Mon, 14 November 2016 10:11 Go to next message
Benno Kallweit is currently offline Benno KallweitFriend
Messages: 7
Registered: November 2016
Junior Member
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 #1748067 is a reply to message #1747398] Fri, 18 November 2016 10:17 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1857
Registered: July 2009
Senior Member
Hi,

I have no idea what you mean by "within a magicdraw plugin (which is started in debug mode in eclipse)" but given the stack trace, the most likely reason is that you're trying to run this code from within an rcp application that doesn't have workspace support. I can't really help on this without more information on how you're trying to run this or a means for me to reproduce though.

Laurent Goubet
Obeo
Re: [Acceleo] Problem starting Acceleo from within Magicdraw Plugin [message #1748084 is a reply to message #1748067] Fri, 18 November 2016 11:31 Go to previous message
Benno Kallweit is currently offline Benno KallweitFriend
Messages: 7
Registered: November 2016
Junior Member
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.
Previous Topic:Acceleo (Run configuration)
Next Topic:M2T transformation (UML2XML)
Goto Forum:
  


Current Time: Wed Jul 18 18:11:06 GMT 2018

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

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

Back to the top