Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Linux Tools Project » ClassCastException when running DockerBuild
ClassCastException when running DockerBuild [message #1792630] Fri, 20 July 2018 11:02 Go to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Hi all,

I am Runnning Run AS->Docker Image Build in an Eclipse RCP on a Dockerfile and seeing this strack trace:

java.lang.ClassCastException: org.eclipse.jface.viewers.TreeSelection cannot be cast to org.eclipse.core.runtime.IAdaptable
at org.eclipse.linuxtools.internal.docker.ui.launch.BaseResourceAwareLaunchShortcut.getResourceFromSelection(BaseResourceAwareLaunchShortcut.java:82)
at org.eclipse.linuxtools.internal.docker.ui.launch.BaseResourceAwareLaunchShortcut.launch(BaseResourceAwareLaunchShortcut.java:54)
at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.launch(LaunchShortcutExtension.java:431)
at org.eclipse.debug.internal.ui.actions.LaunchShortcutAction.runInternal(LaunchShortcutAction.java:85)

The related code is:

if (selectedElement instanceof IResource) {
return (IResource) selectedElement;
} else if (selectedElement instanceof IAdaptable) {
// may return null, which will be dealt with in the caller method
return ((IAdaptable) selection).getAdapter(IResource.class);
}

Two things:

* I am confused that the instanceof IResource if-statement is not being executed, since a file is an IResource, is it not?
* There actually seems to be a bug in the code, the last line should read, return ((IAdaptable) selectedElement).getAdapter(IResource.class); (selectedElement instead of selection, should it not)?

Thanks for any help

Andreas

Re: ClassCastException when running DockerBuild [message #1792642 is a reply to message #1792630] Fri, 20 July 2018 12:19 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Further information: The Dockerfile is in a PyDev Project, and the selectedElement is an instanceof org.python.pydev.navigator.elements.PythonFile, which is an IAdaptable, but not an IResource, so it is obvious, that the code reaches the buggy line.
Re: ClassCastException when running DockerBuild [message #1792655 is a reply to message #1792642] Fri, 20 July 2018 14:33 Go to previous messageGo to next message
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 215
Registered: July 2009
Senior Member
Thanks Andreas. You're right, the line should have referenced selectedElement. I will open a bug and fix. It will be in the next nightly build of Photon and subsequently part of 2018-09.

-- Jeff J.
Re: ClassCastException when running DockerBuild [message #1793145 is a reply to message #1792655] Tue, 31 July 2018 15:20 Go to previous message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Thank you!
Previous Topic:Linux Tools 7.0.0 is released for Photon
Next Topic:Linux Tools 7.0.1 is released for Eclipse 2018-09
Goto Forum:
  


Current Time: Fri Mar 29 15:29:16 GMT 2024

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

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

Back to the top