You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "maneesh (JIRA)" <ji...@apache.org> on 2010/06/01 13:41:39 UTC

[jira] Commented: (COLLECTIONS-355) class cast exception in common collection-3.2 jar

    [ https://issues.apache.org/jira/browse/COLLECTIONS-355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12873960#action_12873960 ] 

maneesh commented on COLLECTIONS-355:
-------------------------------------


Hi Julien, 
Thanks for your support...... When i changed HashMap to Map it is working.
Still I am confused about the listOrderedMap

In the following code snippet :

List<HashMap> objList =null;       //Create a list and it is  using the Data Access layer to fetch the data .
objList = XDA.getInfo(threadId);     //in XDA,we fetch the data using the hibernate jdbc templete: 

list = YDAO.getListByQuery(sqlStr.toString(), arr); 
return list; // So the return list will be  a List of Maps. This value will be stored in the objList  variable.

//set the list objList  in a model object called psgrModel
   psgrModel.setPassengers(objList); 
//pass the model into another method in the same class and fetch the same data processXInfo(psgrModel);

//in processXInfo(psgrModel) method we are delclaring a list called lstQueuedPsgrs and stored the queued passengers
    List lstQueuedPsgrs = psgrModel.getQueuedPassengers(); 
Int startIndex=0; 
//get the data from the list into the HashMap and then get the value from it using the key XYZ as set DA layer while 
//fetching from the database 
     String xyz = (String)(((HashMap)lstQueuedPsgrs.get(startIndex)).get("XYZ"));

It was working fine in the appache common-collection version 1.1 but as we upgraded it to 3.2 version, its giving the following exception. 
java.lang.ClassCastException: org.apache.commons.collections.map.ListOrderedMap 

And in this particular class we are importing the java.util package. not common collection.
Although it is working fine with Map, but can anyone please tell us the reason why is it getting ListOrderedMap instead of HaspMap???


> class cast exception in common collection-3.2  jar
> --------------------------------------------------
>
>                 Key: COLLECTIONS-355
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-355
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 3.2
>         Environment: Unix, jdk 1.5.0.06
>            Reporter: maneesh
>
> Recently I have upgraded common collection jar to 3.2 version. After that I got a class cast exception in the following code java code 
> String checkedInStation = (String)(((HashMap)lstQueuedPsgrs.get(startIndex))
>                         .get("PSGRCHECKEDINSTATION"));
> The exception detail as below
> java.lang.ClassCastException: org.apache.commons.collections.map.ListOrderedMap
> at sun.reflect.GeneratedMethodAccessor279.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585) 
> at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
> at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181) 
> at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.