java.lang.ClassCastException: com/ms/wfc/app/Timer$TimerProc from a Window.callback

Posted on 2008-10-29
Last Modified: 2013-12-16
Does anybody know what kind of windows callbacks throws the following exception (see the callstack below).
The callstack contains a ListView.wndProc call, so it's possible that it's a ListView specific question.
The application was built with Microsoft Visual J++ 6.0.

java.lang.ClassCastException: com/ms/wfc/app/Timer$TimerProc

            at com/ms/wfc/app/Window.fromHandle

            at com/ms/wfc/ui/Control.fromHandle

            at com/ms/wfc/ui/Control.reflectMessage

            at com/ms/wfc/ui/Control.wmNotify

            at com/ms/wfc/ui/Control.wndProc

            at com/ms/wfc/ui/Form.wndProc

            at com/ms/wfc/app/Application$ParkingForm.wndProc

            at com/ms/wfc/ui/Control$ControlWindow.wndProc

            at com/ms/wfc/app/Window.callback

            at com/ms/wfc/win32/Windows.CallWindowProc

            at com/ms/wfc/app/Window.defWndProc

            at com/ms/wfc/ui/Control$ControlWindow.defWndProc

            at com/ms/wfc/ui/Control.defWndProc

            at com/ms/wfc/ui/Control.wmPaint

            at com/ms/wfc/ui/Control.wndProc

            at com/ms/wfc/ui/ListView.wndProc

            at com/ms/wfc/ui/Control$ControlWindow.wndProc

            at com/ms/wfc/app/Window.callback

            at com/ms/wfc/win32/Windows.DispatchMessage

            at com/ms/wfc/app/Application$ThreadContext.runMessageLoop

            at com/ms/wfc/app/

            at Form2.main

Open in new window

Question by:tctdev
  • 5
  • 3
LVL 59

Expert Comment

by:Kevin Cross
ID: 22835789
Please show snippet of code associated to this error message if it told you or if your main() method is fairly small just paste in the whole thing.

java.lang.ClassCastException ==> Usually occurs when you are setting one object equal to another object and the explicit or implicit casting cannot be done.  Examples would be you can cast a sub class to a parent class, but not the other way around.   Things of that nature.

Usually you will see this in code as:
Type2 t2 = (Type2) t1;


Author Comment

ID: 22840994
I can't reproduce the problem, it's very ad hoc. My source is not too little (~2 MB) and the main() method is very simple (see below)

I think the conflict must be between the followings:
- Timer (I use ~30 timer, but I use these very rarely, the most is disabled)
- to make changes on the Controls requested from a thread (not from the main thread)
- ListView callback (it appears on the callstack lista)

I know the ClassCastException but it's thrown by an automatic windows callback, not by my code. I never use the
Timer.TimerProc class, and I never cast it.

I think this problem is closer to mfc than standard java programming (because of microsoft java using and windows callbacks)

I hope, that somebody met something like similar.

	public static void main(String args[])


		Form2.params = args;

		Application.OLERequired(); Form2());


Open in new window

LVL 59

Expert Comment

by:Kevin Cross
ID: 22841093
This could be a threading issue which is why it happens haphazardly as it depends on occurrence of conflict.
// this statement makes me think you are setting a static variable

// what happens if another call comes in and changes this mid stream

// is params defined as String[] like args is

Form2.params = args; 


// you then call a new form instance here

// hopefully this form uses the static params passed in above Form2());


// could this work for you

Form2 f = new Form2(); // or Form2(args); 

f.params = args;


Open in new window


Author Comment

ID: 22841379
The Form2 object is created only in the main(), has only one instance.
I don't know what another call could come in, but I'm going to give it a try.

I will inform you within few days.

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 22874914
Not work. The exception and the callstack are the same.
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 100 total points
ID: 22876200

I am not sure what is causing this right now.  Maybe you are right that you need a MFC officianado. :)

Will keep monitoring question and thinking of possible causes/solutions, though.


Author Comment

ID: 22974647
I'll remove all the timers ...  Come back soon ...

Accepted Solution

tctdev earned 0 total points
ID: 23043589
Replacing all the timers with my own timer class instances gives me the solution. My timer class is consist of a simple thread and MethodInvoker calls at all ticks.

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apps blocked by Java 9 60
Entity Framework 7 31
servlet example issue 6 30
java stored proc example 9 21
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now