Error - trying to load MD project using openAPI from eclipse

Starting point for “ask and learn more about MagicDraw”

Moderator: Moderators

Re: Error - trying to load MD project using openAPI from eclipse

Postby sasii4u@gmail.com » Fri Nov 09, 2018 8:35 am

Hi,

Thanks.

Trying to launch My Commandline configuration file from com.nomagic.magicdraw.integration.demo.application application.

Code snipped as below:

ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject mdProject = workspace.getRoot().getProject("My Commandline");
IPath location = new Path("My Commandline.launch");
IFile file = mdProject.getFile(location.lastSegment());
ILaunchConfiguration launchConfiguration = launchManager.getLaunchConfiguration(file);
DebugUITools.launch(config, ILaunchManager.RUN_MODE);


Getting the following error

Launching failed. Bootstrap code cannot be found.


1. Please let me know whether the approach is correct to launch a osgi launch configuration file from eclipse rcp application , is it possible ?
2. RCP application com.nomagic.magicdraw.integration.demo.application does not start the magic draw ?


Thanks and Regards,

Sasi Kiran
sasii4u@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Thu Oct 18, 2018 3:34 am

Re: Error - trying to load MD project using openAPI from eclipse

Postby vaidas.nargelas@nomagic.com » Fri Nov 09, 2018 8:50 am

Hello,

1) The code snippet you presented seems to use API that is part of Eclipse IDE. I'm not sure if it could be successful if used outside of IDE as part of RCP application.

2) The RCP application com.nomagic.magicdraw.integration.demo.application runs MagicDraw in process. In other words it does not launch it as a standalone application.
Sincerely,

Vaidas Nargėlas
No Magic Customer Support
vaidas.nargelas@nomagic.com
Forum Beginner
Forum Beginner
 
Posts: 38
Posts Rating:4
Joined: Thu Aug 06, 2015 12:28 am

Re: Error - trying to load MD project using openAPI from eclipse

Postby pgirase@gmail.com » Tue Jul 28, 2020 6:08 am

Is this issue resolved?

I am also getting similar error. This is what I am trying to achieve.

I am writing a java application which will load the project file (testProject.mdzip) and print the details of the project. I am using the sample code provided in the cameo programmers guide.
Here is the code I am trying. I am getting the same error

Exception in thread "main" java.lang.NullPointerException
at com.nomagic.runtime.Bridge.GUIUtilitiesconfigureButton(Bridge.java:47)
at com.nomagic.ui.ButtonsPanel.addButton(ButtonsPanel.java:187)
at com.nomagic.ui.ButtonsPanel.<init>(ButtonsPanel.java:119)
at com.nomagic.ui.SimpleBaseDialog.__init(SimpleBaseDialog.java:454)
at com.nomagic.ui.SimpleBaseDialog.<init>(SimpleBaseDialog.java:410)
at com.nomagic.ui.SimpleBaseDialog.<init>(SimpleBaseDialog.java:422)
at com.nomagic.magicdraw.ui.dialogs.aw.<init>(aw.java:86)
at com.nomagic.magicdraw.ui.dialogs.aw.<init>(aw.java:80)
at com.nomagic.magicdraw.core.GUILog.showError(GUILog.java:155)
at com.nomagic.magicdraw.core.GUILog.showError(GUILog.java:196)
at com.nomagic.magicdraw.persistence.ProjectLoadService.handleLoadException(ProjectLoadService.java:131)
at com.nomagic.magicdraw.persistence.ProjectLoadService.loadAndHandleErrors(ProjectLoadService.java:101)
at com.nomagic.magicdraw.persistence.ProjectLoadService.loadAndHandleErrors(ProjectLoadService.java:80)
at com.nomagic.magicdraw.persistence.xmi.load.model.utils.ProjectLoader.lambda$loadProject$1(ProjectLoader.java:115)
at com.nomagic.magicdraw.persistence.xmi.load.model.utils.ProjectLoader.loadProject(ProjectLoader.java:153)
at com.nomagic.magicdraw.persistence.xmi.load.model.utils.ProjectLoader.loadProject(ProjectLoader.java:115)
at com.nomagic.magicdraw.core.project.c.a(c.java:152)
at com.nomagic.magicdraw.core.project.ProjectsManager.loadProject(ProjectsManager.java:623)
at com.nomagic.magicdraw.core.project.ProjectsManager.loadProject(ProjectsManager.java:639)
at com.hcl.magicdraw.LoadMagicDrawProject.main(LoadMagicDrawProject.java:21)




public class LoadMagicDrawProject {

public static void main(String[] args) {
// TODO Auto-generated method stub
String projectFilePath = "C:/Temp/magicdraw/TestProject_01.mdzip";
ProjectsManager projectsManager = Application.getInstance().getProjectsManager();

File file = new File(projectFilePath);
// Create a project descriptor
ProjectDescriptor projectDescriptor = ProjectDescriptorsFactory.createProjectDescriptor(file.toURI());
projectsManager.loadProject(projectDescriptor, true);
System.out.println("Loaded project successfully");
Project project = projectsManager.getActiveProject();
System.out.println("Active Project is " + project);
}
}
pgirase@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Tue Jul 28, 2020 5:37 am

Re: Error - trying to load MD project using openAPI from eclipse

Postby marlel » Tue Jul 28, 2020 6:56 am

Hello,

I am not sure what exactly you want to do, but to access the OpenApi the application must be launched.
Please check the documentation https://docs.nomagic.com/display/MD190S ... batch+mode
Best regards,
Martynas
marlel
No Magic
No Magic
 
Posts: 388
Posts Rating:26
Joined: Wed Jul 11, 2012 2:31 am

Re: Error - trying to load MD project using openAPI from eclipse

Postby pgirase@gmail.com » Tue Jul 28, 2020 10:05 pm

I am trying to rebuild the OSLC Adapter which is built on MagicDraw. I am trying to rebuild it to use Cameo System Modeller. In that project also I am getting the same error while loading project. This project tries to expose the OSLC services on top of Cameo project files to query the data (like requirements, use cases etc.)

Here is the github project url : https://github.com/ld4mbse/oslc-adapter ... nager.java

If you see the method loadSysMLProject. It tries to do the same thing. First get the instance of the application, then start the application and try to load project.

if (project == null) {
// if (magicdrawApplication == null) { this does not support
// reloading of models
// launch MagicDraw in batch mode
magicdrawApplication = Application.getInstance();
try {
magicdrawApplication.start(false, true, false, new String[0], null);
} catch (ApplicationExitedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println(e.toString());
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.toString());
}
}

projectsManager = magicdrawApplication.getProjectsManager();
if (!loadedProjects.keySet().contains(projectId)) {

final File sysmlfile;
if (OSLC4JMagicDrawApplication.useIndividualSubversionFiles) {
String[] filePathSegments = projectId.split("\\\\");
String fileDirName = filePathSegments[filePathSegments.length - 1];
String[] fileDirNameSegments = fileDirName.split("---");
String fileName = fileDirNameSegments[1];
String dirName = fileDirNameSegments[0];
sysmlfile = new File(magicdrawModelsDirectory + dirName + "/" + fileName + ".mdzip");
} else {
sysmlfile = new File(magicdrawModelsDirectory + projectId + ".mdzip");
}

// final File sysmlfile = new File(magicdrawModelsDirectory +
// projectId + ".mdzip");
ProjectDescriptor projectDescriptor = ProjectDescriptorsFactory.createProjectDescriptor(sysmlfile.toURI());
projectsManager.loadProject(projectDescriptor, true);

And the code fails with same error on projectsManager.loadProject(projectDescriptor, true)
pgirase@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Tue Jul 28, 2020 5:37 am

Re: Error - trying to load MD project using openAPI from eclipse

Postby pgirase@gmail.com » Thu Jul 30, 2020 7:41 am

Martynas,

Thanks for sharing the link to the example of running Cameo in batch programs. I am trying to run the example program imagegenerator. With respect to this example I have following 2 questions.

1. I tried to run this example using the "Core batch program command line for Windows" which looks as below:

java -cp lib/com.nomagic.osgi.launcher-17.0.5-SNAPSHOT.jar;lib/bundles/org.eclipse.osgi_3.10.1.v20140909-1633.jar;lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.201512211944.jar;lib/md_api.jar;lib/md_common_api.jar;lib/md.jar;lib/md_common.jar;lib/jna.jar -Dmd.class.path=file:C:/Apps/Cameo-SM-19sp4/openapi/examples/imagegenerator/imagegenerator.properties#CLASSPATH -Dcom.nomagic.osgi.config.dir=configuration -Desi.system.config=data/application.conf -Dlogback.configurationFile=data/logback.xml -Dmd.additional.class.path=openapi/examples/imagegenerator/imagegenerator.jar -Dcom.nomagic.magicdraw.launcher=com.nomagic.magicdraw.examples.imagegenerator.ExportDiagramImages com.nomagic.osgi.launcher.ProductionFrameworkLauncher project_file="C:\Apps\Cameo-SM-19sp4\samples\SysML\climate control system.mdzip" destination_dir=C:\temp\magicdraw

But while running this I get following error:Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter. Looks I am making some mistke in providing the system property -Dmd.class.path. I used the same properties_file#CLASSPATH but looks like something is not right.

2. In that example I see an exe to run the program. How to generate this exe for my own program is not clear in the documentation.

Any help in this regard will be highly appreciated.

Pravin
pgirase@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Tue Jul 28, 2020 5:37 am

Previous

Return to New to MagicDraw

Who is online

Users browsing this forum: No registered users and 2 guests

cron