[Solved] Class Cast Exception error in j2ee [closed]


These lines set up an Iterator<String> implicitly, since whatever collection you’re returning in plh.findByAllSessions() is a Collection of Strings.

col = plh.findByAllSessions();
Iterator i = col.iterator();

Thus this line tried to force a String to a PaymentsLocal object, which is not possible, causing a ClassCastException.

pl = (PaymentsLocal)i.next();

This is because i.next() returns an object of the type of the collection.

solved Class Cast Exception error in j2ee [closed]