Solved

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

Posted on 2008-10-29
9
605 Views
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/Application.run
            at Form2.main

Open in new window

0
Comment
Question by:tctdev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 60

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;

Kev
0
 

Author Comment

by:tctdev
ID: 22840994
mwvisa1:
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)
- com.ms.wfc.app.MethodInvoker: 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.

jkr:
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.
Thanks!

	public static void main(String args[])
	{
		Form2.params = args;
		Application.OLERequired();
		Application.run(new Form2());
	}

Open in new window

0
 
LVL 60

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; 
 
Application.OLERequired();
 
// you then call a new form instance here
// hopefully this form uses the static params passed in above
Application.run(new Form2());
 
 
/********************/
// could this work for you
Form2 f = new Form2(); // or Form2(args); 
f.params = args;
Application.OLERequired();
Application.run(f);

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tctdev
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.

Thanx.
0
 

Author Comment

by:tctdev
ID: 22874914
Not work. The exception and the callstack are the same.
0
 
LVL 60

Assisted Solution

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

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.

Kev
0
 

Author Comment

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

Accepted Solution

by:
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.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

751 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