You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Vinod Padmanabha Iyer (JIRA)" <ji...@apache.org> on 2015/11/11 12:22:10 UTC
[jira] [Commented] (JCS-102) JCS.getGroupKeys() always triggers a\
ClassCastException
[ https://issues.apache.org/jira/browse/JCS-102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15000253#comment-15000253 ]
Vinod Padmanabha Iyer commented on JCS-102:
-------------------------------------------
Hi Thomas,
I am not sure if I am supposed to update here. Just let me know if I am not supposed to. I used the 2.0-beta1 that is the latest i got from the website. Used the below code and I am getting the same error.
Error:
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.commons.jcs.engine.control.group.GroupAttrName
at org.apache.commons.jcs.access.GroupCacheAccess.getGroupKeys(GroupCacheAccess.java:174)
at com.informatica.mdmbde.jcs.example.EmployeeManager.<init>(EmployeeManager.java:30)
at com.informatica.mdmbde.jcs.example.EmployeeManager.main(EmployeeManager.java:62)
Code Snippet:
private GroupCacheAccess<Object, Object> cache;
public EmployeeManager() {
try {
// Load the cache
cache = JCS.getGroupCacheInstance( "empCache" );
// Initialize the cache, Here data can be loaded during initialization
cache.putInGroup("123", "group1", new Employee( "Nick", "Detroit.USA", "123" ) );
cache.putInGroup("143", "group1", new Employee( "Ric", "Seattle.USA", "143" ) );
cache.putInGroup("153", "group2", new Employee( "Jhon", "Chicago.USA", "153" ) );
cache.putInGroup("163", "group2", new Employee( "Dan", "Houston.USA", "163" ) );
Iterator iter = cache.getGroupKeys("group1").iterator();
while (iter.hasNext()) {
System.out.println("key = " + iter.next());
}
} catch( CacheException e ) {
e.printStackTrace();
}
}
> JCS.getGroupKeys() always triggers a\ ClassCastException
> --------------------------------------------------------
>
> Key: JCS-102
> URL: https://issues.apache.org/jira/browse/JCS-102
> Project: Commons JCS
> Issue Type: Bug
> Components: Composite Cache
> Affects Versions: jcs-2.0-beta-1
> Reporter: Robert Clark
> Assignee: Thomas Vandahl
> Fix For: jcs-2.0-beta-1
>
>
> Using SVN version build Dec 20, 2012:
> This code:
> {code:java}
> JCS<Long, String> jcs = JCS.getInstance("the region");
> jcs.getGroupKeys("the group");
> jcs.putInGroup(Long.valueOf(1), "the group", "some value");
> jcs.getGroupKeys("the group");
> {code}
> will trigger an exception on the *second* getGroupKeys() call (when there is actually something in the cache)
> {noformat}
> Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to org.apache.jcs.engine.control.group.GroupAttrName
> [java] at org.apache.jcs.access.GroupCacheAccess.getGroupKeys(GroupCacheAccess.java:205)
> [java] at my.sample.code.Main.main(Main.java:108)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)