Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367170 - Cast exception on the result of view.queryResources
Summary: Cast exception on the result of view.queryResources
Status: CLOSED DUPLICATE of bug 361346
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-20 05:57 EST by Federico Tomassetti CLA
Modified: 2012-05-23 02:58 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Federico Tomassetti CLA 2011-12-20 05:57:30 EST
Build Identifier: 20110916-0149

When I execute these lines:

				List<CDOResourceNode> nodes = view.queryResources(null,
						null, false);
				for (Object obj : nodes){
					System.out.println("> "+obj);
				}

I get an exception:

it.csipiemonte.modelrepo.cdo.commons.OperationFailException: java.lang.ClassCastException: org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl cannot be cast to org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl
	at it.csipiemonte.modelrepo.cdo.commons.SessionOperator.doWithView(SessionOperator.java:37)
	at it.csipiemonte.modelrepo.cdo.client.AbstractClientOperations.getAllResources(AbstractClientOperations.java:182)
	at it.csipiemonte.modelrepo.cdo.client.AbstractClientOperations.getAllResources(AbstractClientOperations.java:176)
	at it.csipiemonte.cdoexperiments.adminconsole.AdminConsole$PrintResourceTreeCommand.exec(AdminConsole.java:118)
	at it.polito.softeng.common.console.CommandLine.handleCommand(CommandLine.java:36)
	at it.polito.softeng.common.console.CommandLine.run(CommandLine.java:53)
	at it.csipiemonte.cdoexperiments.adminconsole.AdminConsole.main(AdminConsole.java:289)
Caused by: java.lang.ClassCastException: org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl cannot be cast to org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:715)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:1)
	at org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl.adapt(CDOQueryResultIteratorImpl.java:55)
	at org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl$QueryResultList$ECDOIDIterator.next(CDOQueryResultIteratorImpl.java:268)
	at it.csipiemonte.modelrepo.cdo.client.AbstractClientOperations$6.execute(AbstractClientOperations.java:188)
	at it.csipiemonte.modelrepo.cdo.client.AbstractClientOperations$6.execute(AbstractClientOperations.java:1)
	at it.csipiemonte.modelrepo.cdo.commons.SessionOperator.doWithView(SessionOperator.java:33)

The exception thrown is:

Caused by: java.lang.ClassCastException: org.eclipse.emf.internal.cdo.object.DynamicCDOObjectImpl cannot be cast to org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:715)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:1)
	at org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl.adapt(CDOQueryResultIteratorImpl.java:55)
	at org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl$QueryResultList$ECDOIDIterator.next(CDOQueryResultIteratorImpl.java:268)

and it is thrown while iterating the list obtained from view.queryResources


Reproducible: Didn't try
Comment 1 Federico Tomassetti CLA 2011-12-20 06:37:43 EST
On the same repository the query:

 List<CDOResourceNode> nodes = view.queryResources(null,
                        "", false);

works ok
Comment 2 Eike Stepper CLA 2012-01-06 13:51:16 EST
It very much strikes me that this is a dup of bug 361346. Please reopen if you've updated and the problem is still there.

If you can't update please check if the following code early in your app helps (and let me know):

    // Ensure that these 3 packages are registered with the global package registry in stand-alone
    EcorePackage.eINSTANCE.getClass();
    EresourcePackage.eINSTANCE.getClass();
    EtypesPackage.eINSTANCE.getClass();

*** This bug has been marked as a duplicate of bug 361346 ***