file Invalid modeling session

10 years 6 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.

10 years 6 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.

10 years 6 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.

10 years 6 months ago #837 by mersa
I changed the code to
public Object execute(ExecutionEvent event) throws ExecutionException {
	IModelingSession session = 
	//session is not null within a project
	IWorkspace workspace = App.getInstance().getWorkspace();
	IProjectSpace proSpace = workspace.getProjectSpace("Project1");
	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
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.core.ui.ktable.KeyValueModel.doGetContentAt(
at de.kupzog.ktable.KTableDefaultModel.getContentAt(
at de.kupzog.ktable.KTable.drawCell(
at de.kupzog.ktable.KTable.drawCells(
at de.kupzog.ktable.KTable.onPaint(
at de.kupzog.ktable.KTable$3.paintControl(
at org.eclipse.swt.widgets.TypedListener.handleEvent(
at org.eclipse.swt.widgets.EventTable.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Composite.WM_PAINT(
at org.eclipse.swt.widgets.Control.windowProc(
at org.eclipse.swt.widgets.Canvas.windowProc(
at org.eclipse.swt.widgets.Display.windowProc(
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(
at org.eclipse.swt.widgets.Display.readAndDispatch(
at org.eclipse.ui.internal.Workbench.runEventLoop(
at org.eclipse.ui.internal.Workbench.runUI(
at org.eclipse.ui.internal.Workbench.access$4(
at org.eclipse.ui.internal.Workbench$
at org.eclipse.core.databinding.observable.Realm.runWithDefault(
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.eclipse.equinox.launcher.Main.invokeFramework(
at org.eclipse.equinox.launcher.Main.basicRun(
at org.eclipse.equinox.launcher.Main.main(

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

10 years 6 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.

10 years 6 months ago #840 by mersa
Right, i only called a session to see it's value.

It's good to hear, that this error (probably) has minimal effect an effect. I'll ignore it for now.

Thanks :)

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

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