Skip to content

Commit 007f472

Browse files
committed
FISH-6932 Fixes ClassCastException: class org.eclipse.wst.server.core.internal.Runtime cannot be cast to class org.eclipse.wst.server.core.IRuntimeWorkingCopy
1 parent ffe1cfb commit 007f472

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/ui/wizards/NewPayaraRuntimeWizardFragment.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected void updateJREs(JdkFilter jdkFilter) {
252252
int size2 = vmInstalls.length;
253253
for (int j = 0; j < size2; j++) {
254254
// if (jdkFilter == null || jdkFilter.allows(vmInstalls[j])) {
255-
installedJREs.add(vmInstalls[j]);
255+
installedJREs.add(vmInstalls[j]);
256256
// }
257257
}
258258
}
@@ -341,14 +341,15 @@ protected String getDescription() {
341341
@Override
342342
public void setTaskModel(TaskModel taskModel) {
343343
super.setTaskModel(taskModel);
344-
345-
IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TASK_RUNTIME);
346-
if (runtime.getOriginal() == null) {
347-
try {
348-
runtime.setName(createUniqueRuntimeName(runtime.getRuntimeType().getName()));
349-
} catch (UniqueNameNotFound e) {
350-
// Set the type name and let the user handle validation error
351-
runtime.setName(runtime.getRuntimeType().getName());
344+
if (getTaskModel().getObject(TASK_RUNTIME) instanceof RuntimeWorkingCopy) {
345+
IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TASK_RUNTIME);
346+
if (runtime.getOriginal() == null) {
347+
try {
348+
runtime.setName(createUniqueRuntimeName(runtime.getRuntimeType().getName()));
349+
} catch (UniqueNameNotFound e) {
350+
// Set the type name and let the user handle validation error
351+
runtime.setName(runtime.getRuntimeType().getName());
352+
}
352353
}
353354
}
354355
}

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/ui/wizards/NewPayaraServerWizardFragment.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.eclipse.swt.widgets.Spinner;
5252
import org.eclipse.swt.widgets.Text;
5353
import org.eclipse.ui.PlatformUI;
54+
import org.eclipse.wst.server.core.IRuntime;
5455
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
5556
import org.eclipse.wst.server.core.IServerWorkingCopy;
5657
import org.eclipse.wst.server.core.TaskModel;
@@ -63,6 +64,7 @@
6364
import fish.payara.eclipse.tools.server.PayaraServerPlugin;
6465
import fish.payara.eclipse.tools.server.exceptions.UniqueNameNotFound;
6566
import fish.payara.eclipse.tools.server.utils.WtpUtil;
67+
import org.eclipse.wst.server.core.internal.Runtime;
6668

6769
/**
6870
* This wizard fragment plugs-in the wizard flow when
@@ -411,8 +413,8 @@ private IServerWorkingCopy getServer() {
411413
return (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
412414
}
413415

414-
private IRuntimeWorkingCopy getServerRuntime() {
415-
return (IRuntimeWorkingCopy) getTaskModel().getObject(TASK_RUNTIME);
416+
private IRuntime getServerRuntime() {
417+
return (IRuntime) getTaskModel().getObject(TASK_RUNTIME);
416418
}
417419

418420
private void updateServerName() {
@@ -460,14 +462,15 @@ protected String getDescription() {
460462
@Override
461463
public void setTaskModel(TaskModel taskModel) {
462464
super.setTaskModel(taskModel);
463-
464-
IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TASK_RUNTIME);
465-
if (runtime.getOriginal() == null) {
466-
try {
467-
runtime.setName(createUniqueRuntimeName(runtime.getRuntimeType().getName()));
468-
} catch (UniqueNameNotFound e) {
469-
// Set the type name and let the user handle validation error
470-
runtime.setName(runtime.getRuntimeType().getName());
465+
if (getTaskModel().getObject(TASK_RUNTIME) instanceof RuntimeWorkingCopy) {
466+
IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TASK_RUNTIME);
467+
if (runtime.getOriginal() == null) {
468+
try {
469+
runtime.setName(createUniqueRuntimeName(runtime.getRuntimeType().getName()));
470+
} catch (UniqueNameNotFound e) {
471+
// Set the type name and let the user handle validation error
472+
runtime.setName(runtime.getRuntimeType().getName());
473+
}
471474
}
472475
}
473476
}

0 commit comments

Comments
 (0)