From 57cb548b97d55017381743ae11848a90830d519e Mon Sep 17 00:00:00 2001 From: Holger Voormann Date: Mon, 5 Aug 2024 16:32:14 +0200 Subject: [PATCH] Fix ClassCastException Fix ClassCastException (not tested!). See Stack Overflow question 78834435: https://stackoverflow.com/q/78834435/6505250 Stack trace (`eclipse.buildId=4.32.0.20240606-1231`): ``` java.lang.ClassCastException: class org.eclipse.jdt.internal.core.JavaNature cannot be cast to class org.eclipse.jdt.core.IJavaProject (org.eclipse.jdt.internal.core.JavaNature and org.eclipse.jdt.core.IJavaProject are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @529500a7) at org.hibernate.eclipse.console.wizards.NewConfigurationWizard.init(NewConfigurationWizard.java:325) at ... ``` Signed-off-by: Holger Voormann --- .../eclipse/console/wizards/NewConfigurationWizard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orm/plugin/core/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java b/orm/plugin/core/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java index ae4273f1cf..fafe459f52 100755 --- a/orm/plugin/core/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java +++ b/orm/plugin/core/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewConfigurationWizard.java @@ -322,7 +322,7 @@ public void init(IWorkbench workbench, IStructuredSelection selection) { if (selection.getFirstElement() instanceof IProject){ try { if (((IProject)selection.getFirstElement()).getNature(JavaCore.NATURE_ID) != null) { - jproj = (IJavaProject)((IProject)selection.getFirstElement()).getNature(JavaCore.NATURE_ID); + jproj = JavaCore.create((IProject)selection.getFirstElement()); } } catch (CoreException e) { HibernateConsolePlugin.getDefault().log(e); @@ -362,4 +362,4 @@ public boolean canFinish() { return super.canFinish(); } -} \ No newline at end of file +}