Same class different class-loader

Hi guys,
How should I properly Cast AbstractWindow to Class which it represents.


MyCustomWindow customWindow =
    (MyCustomWindow) openWindow(
       "custom-window",
       WindowManager.OpenType.DIALOG,
       ParamsMap.of("value",origin, "split", true));

And getting error


Caused by: java.lang.ClassCastException: com.company.test.web.screens.MyCustomWindow
cannot be cast to com.company.test.web.screens.MyCustomWindow

Can someone help how to avoid this error ?
I came accross same approach as I am doing in here: cuba/UserBrowser.java at a5d7e58d0e883650c0fe2312fc7c9778e6f672ad · cuba-platform/cuba · GitHub
at changePasswordAtLogon()

Any help appriciated :slight_smile:
Or should I just stick with:


AbstractWindow customWindow =
               openWindow(...);
...
((MyCustomWindow) customWindow).getInfo()
((MyCustomWindow) customWindow).getInfo2()
((MyCustomWindow) customWindow).getInfo3()

Hello,

usually, this issue is reproduced when you use the hot-deploy feature. Did you use it manually via the CUBA.platform plugin for the Intellij IDEA? Or maybe CUBA Studio was run in this time?

If it’s true, please try to clean tomcat/conf/app/ directory.

Best regards,
Daniil.

1 Like