- Posts: 1
- Thank you received: 0
Modelio 4.0.0 released (07 Nov 2019)
Modelio 4.0.0 has been released ( www.modelio.org/forum/4-announcements/45...-4-0-0-released.html )
Calling a module service : ClassCastException to the same object
I create my own plugin in Modelio 2.2. This plugin have to use an internal plugin "SVN Teamwork manager" to upgrade the local model.
So, I have a class called SubVersionUtils, with a method "maj" :
public Object maj ( Collection< IElement > elements ) throws Exception
{
for ( IPeerMdac module : Modelio.getInstance ().getModuleService ().getAllPeerMdacs () )
{
System.out.println (
" - " + module.getName () + ", "
+ module.getVersion ().toString () + ","
+ module.getClass ().getSimpleName () + ","
+ ( module instanceof SubversionPeerMdac ) + ","
+ module.getClass ().getClassLoader ().getClass ().getSimpleName () + ","
+ SubversionPeerMdac.class.getClassLoader ().getClass ().getSimpleName ()
);
}
SubversionPeerMdac module = (SubversionPeerMdac) Modelio.getInstance ().getModuleService ().getPeerMdac ( "Subversion" );
// Save module parameters
String oldConfirmRamcUpdate = module.getConfiguration ().getParameterValue ( "confirmRamcUpdate" );
String oldConfirmModulesUpdate = module.getConfiguration ().getParameterValue ( "confirmModuleUpdate" );
// Set confirmations to false
module.getConfiguration ().setParameterValue ( "confirmRamcUpdate" , "False" );
module.getConfiguration ().setParameterValue ( "confirmModuleUpdate" , "False" );
//IElement rootElement = Modelio.getInstance ().getModelingSession ().getModel ().getRoot ();
UpdateParameters updateParameters = new UpdateParameters ( elements , UpdateParameters.ImportDepth.SMART );
Object results = module.update ( updateParameters , null );
// Reset module parameters
module.getConfiguration ().setParameterValue ( "confirmRamcUpdate" , oldConfirmRamcUpdate );
module.getConfiguration ().setParameterValue ( "confirmModuleUpdate" , oldConfirmModulesUpdate );
return results;
}
In the first time, I had a problem "Class not found exception". I solved it when I include the subversion-2.2.112.jar by maven in the pom.xml
Now, I have a new problem "ClassCastException" with the same object. I have this stacktrace :
java.lang.ClassCastException: com.modeliosoft.subversion.impl.SubversionPeerMdac cannot be cast to com.modeliosoft.subversion.impl.SubversionPeerMdac
at org.modelio.ImportExcel.utils.SubVersionUtils.maj(SubVersionUtils.java:41)
at org.modelio.ImportExcel.command.ReplaceCommand.actionPerformed(ReplaceCommand.java:90)
at com.modeliosoft.modelio.api.mdac.contrib.MdacActionDelegatingHandler.execute(MdacActionDelegatingHandler.java:48)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
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.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.modeliosoft.modelio.app.enterprise.intro.Application.start(Application.java:88)
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)
- 13:10:25,797 ERROR ImportExcel:com.modeliosoft.subversion.impl.SubversionPeerMdac cannot be cast to com.modeliosoft.subversion.impl.SubversionPeerMdac
java.lang.ClassCastException: com.modeliosoft.subversion.impl.SubversionPeerMdac cannot be cast to com.modeliosoft.subversion.impl.SubversionPeerMdac
at org.modelio.ImportExcel.utils.SubVersionUtils.maj(SubVersionUtils.java:41)
at org.modelio.ImportExcel.command.ReplaceCommand.actionPerformed(ReplaceCommand.java:90)
at com.modeliosoft.modelio.api.mdac.contrib.MdacActionDelegatingHandler.execute(MdacActionDelegatingHandler.java:48)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
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.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.modeliosoft.modelio.app.enterprise.intro.Application.start(Application.java:88)
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)
I found a couple of post on the web, nether solution, the problem means the classloader is not the same for Modelio and the plugin.
I don't know if you already have an issue like that, I search many times for a solution, I tried to follow the tutorial found here .
Thanks for helping
I'm French and it's my second post in english, so if a part of my post is not understandable, never mind, tell me and I will correct this.
Please Log in or Create an account to join the conversation.
When will be ClassCastException is thrown:
When you try to cast an object of Parent class to its Child class type, this exception will be thrown.
When you try to cast an object of one class into another class type that has not extended the other class or they don't have any relationship between them.
Please Log in or Create an account to join the conversation.