file Invalid modeling session

7 years 8 months ago - 7 years 8 months ago #831 by mersa
Hey,

i couldn`t hold myself off from modelio for a long time and i have to pick up the modelingSession(ms) concept again.
In the environemnt of a plugin, requesting ms returns null if no project is open and a (valid?)session when a project is open.
So the scenario is as follows:

1.open a project
2.execute plugin command via contextmenu
	IModelingSession session = Modelio.getInstance().getModelingSession();
	//session is not null within a project
	App.getInstance().closeProject();
	IWorkspace workspace = App.getInstance().getWorkspace();
	IProjectSpace proSpace = workspace.getProjectSpace("Project1");
	
	App.getInstance().openProject(proSpace);

	//Refresh workspace
	

3. "Project1" opens everything works fine (apparently)

BUT: sometimes after this code, the folowing exception is thrown

com.modeliosoft.modelio.api.utils.exceptions.ObElementNotFoundException: 1 modeling session is invalid
at com.modeliosoft.modelio.api.model.ObModelElement._getName(Native Method)
at com.modeliosoft.modelio.api.model.ObModelElement.getName(Unknown Source)
..



So my question is, whether a modelingsession is always valid or null, or whether there is also a state invalid.
Does this exception lead to a serious problem? Because i don`t recognize any "user-related" problems at all.
How can i avoid this exception?

Unfortunately, i can not debug the moment where the exception is thrown.
I have read
forge.modelio.org/projects/modelio-api-d...n/wiki/core_concepts
but can`t find a solution for my problem.

Please Log in or Create an account to join the conversation.

7 years 8 months ago #834 by chm
Hello Mersa,

basically, a modeling session is an opened project, with an ID of its own. Multi project isn't supported, meaning only one could be opened at a time. When calling "App.getInstance().closeProject()", your session is closed and should not be used any longer.

Each accessed model element is loaded into the current modeling session. Keeping a reference on one of them before closing a project and opening another one triggers an ObElementNotFoundException exception when using this element.

I suppose a reference is kept somewhere, trying to access an old element and causing this error to pop...

Hope this helps!

Please Log in or Create an account to join the conversation.

7 years 8 months ago #835 by mersa
Thank you for your explanation. Sounds comprehensible to me.

But i hoped that closing a project would discard my current session and opening a new project would give me a whole new session. I have no intend to open more than one project at a time.

I wonder what is the missing step so that my code works as it does in modelio:

File -> close project_a, Open project_b

Are there any "clean-up efforts" that i could do before opening a new project

Please Log in or Create an account to join the conversation.

7 years 8 months ago #836 by chm
After opening your project, you should again use:
IModelingSession session = Modelio.getInstance().getModelingSession();

The only error to avoid is keeping the old session (or model elements from it) after calling close on it.

Please Log in or Create an account to join the conversation.

7 years 8 months ago #837 by mersa
I changed the code to
public Object execute(ExecutionEvent event) throws ExecutionException {
	IModelingSession session = 
		Modelio.getInstance().getModelingSession();
	//session is not null within a project
	App.getInstance().closeProject();
	IWorkspace workspace = App.getInstance().getWorkspace();
	IProjectSpace proSpace = workspace.getProjectSpace("Project1");
	
	App.getInstance().openProject(proSpace);
	session = Modelio.getInstance().getModelingSession();

	//Refresh workspace
	
	System.out.println("execute end");
	}

I'm not aware of doing anything with the session. The exception is thrown somewhere after the system.out

For compelteness, here is the hole errormessage

!ENTRY org.eclipse.ui 4 0 2012-05-02 11:13:50.515
!MESSAGE Unhandled event loop exception
!STACK 0
com.modeliosoft.modelio.api.utils.exceptions.ObElementNotFoundException: 4 modeling session is invalid
at com.modeliosoft.modelio.api.model.ObModelElement._getName(Native Method)
at com.modeliosoft.modelio.api.model.ObModelElement.getName(Unknown Source)
at com.modeliosoft.modelio.edition.annotations.view.data.standard.model.uml.PackagePropertyModel.getValueAt(PackagePropertyModel.java:155)
at com.modeliosoft.modelio.core.ui.ktable.KeyValueModel.doGetContentAt(KeyValueModel.java:295)
at de.kupzog.ktable.KTableDefaultModel.getContentAt(KTableDefaultModel.java:160)
at de.kupzog.ktable.KTable.drawCell(KTable.java:1426)
at de.kupzog.ktable.KTable.drawCells(KTable.java:1336)
at de.kupzog.ktable.KTable.onPaint(KTable.java:1043)
at de.kupzog.ktable.KTable$3.paintControl(KTable.java:281)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:229)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1564)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4585)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4985)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2531)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.modeliosoft.modelio.app.intro.Application.start(Application.java:75)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Please Log in or Create an account to join the conversation.

7 years 8 months ago #838 by fpo
Quick reply:
1) your first call to "IModelingSession session =
Modelio.getInstance().getModelingSession();" is pretty much useless, since you never actually use that session and you close the project right after it, making it invalid anyway.

2) from the stack you provided, the exception you get is caused by a view (the "Element" view I think) trying to refresh its content using a pointer on an element from the original session (so indeed not found in the newly opened project). It is a bug on our side, and the effects should be minimal. Once the application send at least one selection event, the view will get that new selection and refresh its content based on it.

Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.040 seconds
^ Back to Top