aspose file tools
The moose likes Java in General and the fly likes number of class loaders in a small java project Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "number of class loaders in a small java project" Watch "number of class loaders in a small java project" New topic
Author

number of class loaders in a small java project

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

While practicing with Collections , i got a ClassCastException , so when searching for the reasons of getting ClassCastException i found this one :

A class cast exception results when the following conditions exist and can be corrected by the following actions:

* The type of the source object is not an instance of the target class (type).

* The class loader that loaded the source object (class) is different from the class loader that loaded the target class.

* The application fails to perform or improperly performs a narrow operation.

(This is taken from IBM tutorials)

Please tell me something about the second point as my question is how many classloaders will be present in a Java Application (I am not using any server or not using any custom classloaders ).

Thank you .


Save India From Corruption - Anna Hazare.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12325
    
    1
Typically only one class loader - a great simplification.

I would certainly look elsewhere for the problem.

There should be details attached to the exception, what does the stack trace say?

Bill

Java Resources at www.wbrogden.com
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thanks , i solved that exception , just for the sake of knowledge transfer i posted this question .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: number of class loaders in a small java project
 
Similar Threads
SCJEA Sample questions on Sun's site (whoops)
ClassCastException
Are class objects unique?
help ---about ClassCastException
Loading same class by two different class loader (ClassCastException)