History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: COR-1059
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Dirk Louwers
Reporter: Dheeraj Guntupalli
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
db4o Core

ClassCastException for Treemap

Created: 26/Dec/07 12:53 PM   Updated: 29/Jan/08 03:58 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.27

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0h
Time Spent - 10.5h
Time Spent: 10.5h
Time Spent - 10.5h

File Attachments: 1. Java Source File Cor1059TestCase.java (0.8 kb)

Environment: 6.4.14.8131

Peers: Patrick Roemer and Richard Liang
Order: 3
Iteration: 27
Original IDS Estimate: 2
Resolution Date: 29/Jan/08 03:58 PM
First Response Date: 10/Jan/08 01:23 PM
Labels:
Participants: Dheeraj Guntupalli, Dirk Louwers and Patrick Roemer
Number of Attachments: 1
Number of Comments: 5


 Description  « Hide

 I have created the demo db through objectmanager 6.4.14.8131. I query for the Collections.java class (code below).

ObjectContainer oc = Db4o.openFile("objectmanager-6.4.14.8131/demo.db");
Query query = oc.query();
query .constrain( oc.ext().reflector().forName("demo.objectmanager.model.Collections"));
ObjectSet set = query .execute();
while(set.hasNext()){
System.out.println(set.next());
}

It throws the following exception. Let me know if i am missing anything.

Exception in thread "main" com.db4o.internal.ReflectException
at com.db4o.internal.TranslatedFieldMetadata.setOn(Unknown Source)
at com.db4o.internal.TranslatedFieldMetadata.instantiate(Unknown Source)
at com.db4o.internal.marshall.ObjectMarshaller$1.processField(Unknown Source)
at com.db4o.internal.marshall.ObjectMarshaller.traverseFields(Unknown Source)
at com.db4o.internal.marshall.ObjectMarshaller.traverseFields(Unknown Source)
at com.db4o.internal.marshall.ObjectMarshaller.instantiateFields(Unknown Source)
at com.db4o.internal.ClassMetadata.instantiateFields(Unknown Source)
at com.db4o.internal.ClassMetadata.activate(Unknown Source)
at com.db4o.internal.ClassMetadata.instantiate(Unknown Source)
at com.db4o.internal.marshall.UnmarshallingContext.readInternal(Unknown Source)
at com.db4o.internal.marshall.UnmarshallingContext.read(Unknown Source)
at com.db4o.internal.ObjectReference.read(Unknown Source)
at com.db4o.internal.ObjectReference.activate1(Unknown Source)
at com.db4o.internal.PartialObjectContainer.activatePending(Unknown Source)
at com.db4o.internal.PartialObjectContainer.readActivatedObjectNotInCache(Unknown Source)
at com.db4o.internal.query.result.AbstractQueryResult.activatedObject(Unknown Source)
at com.db4o.internal.query.result.AbstractQueryResult$1.map(Unknown Source)
at com.db4o.foundation.MappingIterator.moveNext(Unknown Source)
at com.db4o.foundation.Iterable4Adaptor.moveNext(Unknown Source)
at com.db4o.foundation.Iterable4Adaptor.hasNext(Unknown Source)
at com.db4o.internal.query.result.StatefulQueryResult.hasNext(Unknown Source)
at com.db4o.internal.query.ObjectSetFacade.hasNext(Unknown Source)
at Test.main(Test.java:17)
Caused by: java.lang.ClassCastException: com.db4o.reflect.generic.GenericObject
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.put(TreeMap.java:465)
at com.db4o.config.TMap.onActivate(Unknown Source)
... 23 more
[db4o 6.4.14.8131 2007-12-26 18:14:32]
 'objectmanager-6.4.14.8131/demo.db' closed by ShutdownHook.


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Patrick Roemer - 10/Jan/08 01:23 PM
Not reproducable against db4o build (6.4.14.8131-java5) and demo db file that come with OMEJ 1.0.0 drop from 12/31/07 - the attached test case reports:

| com.db4o.cases.cor1059.Cor1059TestCase.testQueryCollections
| (G) demo.objectmanager.model.Collections
| GREEN (1 tests) - 370ms

Dheeraj Guntupalli - 13/Jan/08 06:22 AM
Hi, Sorry for not being clear. The demo db in OMEJ doesn't have TreeMap in Collections class. The above exception occurs when i try to open demo.db created by objectmanager-6.4.14.8131 by using the code given above. If the demo.objectmanager.model.Collections class definition is not present it throws the exception. But if you open through the present objectmanager it works fine.

Please let me know if I am not clear.

Thanks & Regards,
Dheeraj

Dirk Louwers - 15/Jan/08 03:06 PM
Reporter used a different database file. Need to try reproduce using the same db file.

Dheeraj Guntupalli - 16/Jan/08 02:23 PM
The database is created using objectmanager-6.4.14.8131. And select File --> Create Demo DB

Patrick Roemer - 29/Jan/08 03:58 PM
The problem is a mix of instances of known and unknown classes inside the object graph: A "known" TreeMap contains "unknown" elements. When the map is reinstantiated, the translator fills in its elements, represented as GenericObject instances. But the map expects objects implementing the Comparable interface. (A similar scenario with a reverse direction of known <-> unknown has been reported in the OSGi forum: http://developer.db4o.com/forums/thread/46234.aspx)

This particular scenario might be fixed by making GenericObject implement Comparable, however, the ordering semantics of the retrieved map would be slightly different. This may be acceptable for ObjectManager style applications (and perhaps even C/S without class definitions on the server), but it might trigger side effects in other scenarios. (In these scenarios generic reflector should be disabled by default, anyway, see COR-236.) In general, typing issues with object graphs containing a mix of known and unknown classes cannot be avoided in a generic way.