Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Old class cast exception resurfaces(A CDO classcastexception fixed in 2012 rises again, maybe?)
[CDO] Old class cast exception resurfaces [message #1339141] Wed, 07 May 2014 10:37 Go to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
Hi,

We have some code that Exports our repo model into an xmi file. But in some cases it throws this exception

[ERROR 2014-05-07 15:30:36.945 BST] main:com.yambina.edm.core.utils.ErrorUtils - Failed to export to file:/Users/david/workspace/fullmodeltest.xmi
java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
	at com.yambina.edm.validation.ExportCommandHandler.execute(ExportCommandHandler.java:54)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:850)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:743)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:727)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:662)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4166)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4012)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3651)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at com.yambina.mdwmui.MDWMUIApplication.start(MDWMUIApplication.java:44)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.eclipse.net4j.signal.RemoteException: java.lang.ClassCastException: org.eclipse.emf.cdo.common.revision.CDORevisionUtil$Uninitialized cannot be cast to org.eclipse.emf.cdo.common.id.CDOID
	at org.eclipse.net4j.signal.RequestWithConfirmation.getRemoteException(RequestWithConfirmation.java:141)
	at org.eclipse.net4j.signal.RequestWithConfirmation.setRemoteException(RequestWithConfirmation.java:130)
	at org.eclipse.net4j.signal.SignalProtocol.handleRemoteException(SignalProtocol.java:465)
	at org.eclipse.net4j.signal.RemoteExceptionIndication.indicating(RemoteExceptionIndication.java:66)
	at org.eclipse.net4j.signal.Indication.doExtendedInput(Indication.java:57)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:328)
	at org.eclipse.net4j.signal.Indication.execute(Indication.java:51)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:253)
	at org.eclipse.net4j.signal.Signal.run(Signal.java:149)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassCastException: org.eclipse.emf.cdo.common.revision.CDORevisionUtil$Uninitialized cannot be cast to org.eclipse.emf.cdo.common.id.CDOID
	at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$11.writeValue(CDOTypeImpl.java:242)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.LoadChunkIndication.responding(LoadChunkIndication.java:106)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndication.responding(CDOServerIndication.java:134)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:98)
	at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:298)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:67)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerReadIndication.execute(CDOServerReadIndication.java:36)


I saw this was fixed here https://bugs.eclipse.org/bugs/show_bug.cgi?id=369646

But not clear to me if this is different or the same cause. I am using V4.2.1 of org.eclipse.emf.cdo.server.db in Kepler SR2 using H2, on Java 7 - /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib

i.e. A Mac

Here is the code that does the clone prior to the export, it does not return from this method, but the ClassCastException is not caught in it either?

    private void clone(final Collection<EObject> eObjects, final IProgressMonitor monitor) throws InvocationTargetException {
        SubMonitor subMonitor = SubMonitor.convert(monitor, eObjects.size());
        Object value = null;
        try {
            for (EObject eObject : eObjects) {
                EObject eObjectClone = EDMModelFactory.eINSTANCE.create(eObject.eClass());
                this.clones.put(eObject, eObjectClone);

                for (EAttribute attribute : eObjectClone.eClass().getEAllAttributes()) {
                    if (!attribute.isDerived()) {
                        eObjectClone.eSet(attribute, eObject.eGet(attribute));
                    }
                }

                Collection<EObject> children = new ArrayList<EObject>();
                for (EReference reference : eObjectClone.eClass().getEAllContainments()) {
                    try {
                        value = eObject.eGet(reference);
                        if (reference.isMany()) {
                            children.addAll((Collection<EObject>) value);
                        } else {
                            CollectionUtils.addIgnoreNull(children, value);
                        }
                    } catch (ObjectNotFoundException ex) {
                        //TODO: Remove eObject and all references to it.
                        throw new InvocationTargetException(ex, NLS.bind("{0}#{1} contains an object that can't be found", Utils.getFullyQualifiedName(eObject), reference.getName())); //$NON-NLS-1$
                    }
                }

                this.clone(children, subMonitor.newChild(1));
            }
        } catch (ClassCastException cce) {
        	LogPlugin.error(LOG, true, "{0} is not initialized", value.toString()); //$NON-NLS-1$
        } finally {
            if (monitor != null) {
                monitor.done();
            }
        }
    }


Not clear exactly where it fails as it is a large model so cannot single step it and it does not do the catch where I added the ClassCastException in the code above. Any pointers?


[Updated on: Wed, 07 May 2014 10:38]

Report message to a moderator

Re: [CDO] Old class cast exception resurfaces [message #1343344 is a reply to message #1339141] Fri, 09 May 2014 04:41 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
This might help I set a breakpoint on ClassCastException and found it in my CDOServer implementation..

Daemon Thread [net4j-Thread-3] (Suspended (exception ClassCastException))	
	CDOTypeImpl$11.writeValue(CDODataOutput, Object) line: 242	
	LoadChunkIndication.responding(CDODataOutput) line: 106	
	LoadChunkIndication(CDOServerIndication).responding(ExtendedDataOutputStream) line: 134	
	LoadChunkIndication(IndicationWithResponse).doExtendedOutput(ExtendedDataOutputStream) line: 98	
	LoadChunkIndication(Signal).doOutput(BufferOutputStream) line: 298	
	LoadChunkIndication(IndicationWithResponse).execute(BufferInputStream, BufferOutputStream) line: 67	
	LoadChunkIndication(CDOServerReadIndication).execute(BufferInputStream, BufferOutputStream) line: 36	
	LoadChunkIndication(Signal).runSync() line: 253	
	LoadChunkIndication(Signal).run() line: 149	
	ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1145	
	ThreadPoolExecutor$Worker.run() line: 615	
	Thread.run() line: 724	



Re: [CDO] Old class cast exception resurfaces [message #1368958 is a reply to message #1343344] Tue, 20 May 2014 07:00 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
Is my question so stupid no one wants to answer it? Or is it so difficult no one can?
Re: [CDO] Old class cast exception resurfaces [message #1384248 is a reply to message #1368958] Wed, 28 May 2014 10:08 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
I can reproduce this problem using the CDO Explorer perspective in the CDO Sessions view by trying to open the resource in an active transaction in the CDO Editor

java.lang.ClassCastException: org.eclipse.emf.cdo.common.revision.CDORevisionUtil$Uninitialized cannot be cast to org.eclipse.emf.cdo.common.id.CDOID
org.eclipse.net4j.signal.RemoteException: java.lang.ClassCastException: org.eclipse.emf.cdo.common.revision.CDORevisionUtil$Uninitialized cannot be cast to org.eclipse.emf.cdo.common.id.CDOID
	at org.eclipse.net4j.signal.RequestWithConfirmation.getRemoteException(RequestWithConfirmation.java:141)
	at org.eclipse.net4j.signal.RequestWithConfirmation.setRemoteException(RequestWithConfirmation.java:130)
	at org.eclipse.net4j.signal.SignalProtocol.handleRemoteException(SignalProtocol.java:465)
	at org.eclipse.net4j.signal.RemoteExceptionIndication.indicating(RemoteExceptionIndication.java:66)
	at org.eclipse.net4j.signal.Indication.doExtendedInput(Indication.java:57)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:328)
	at org.eclipse.net4j.signal.Indication.execute(Indication.java:51)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:253)
	at org.eclipse.net4j.signal.Signal.run(Signal.java:149)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassCastException: org.eclipse.emf.cdo.common.revision.CDORevisionUtil$Uninitialized cannot be cast to org.eclipse.emf.cdo.common.id.CDOID
	at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$11.writeValue(CDOTypeImpl.java:242)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.LoadChunkIndication.responding(LoadChunkIndication.java:106)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndication.responding(CDOServerIndication.java:134)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedOutput(IndicationWithResponse.java:98)
	at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:298)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:67)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerReadIndication.execute(CDOServerReadIndication.java:36)
	... 5 more


What worries me is this happens quite frequently with CDO, for the last few years. I don't know how the repos end up in this state, which is the worrying thing.

Re: [CDO] Old class cast exception resurfaces [message #1397916 is a reply to message #1384248] Thu, 10 July 2014 06:41 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
Bump.

Maybe someone who reads this can guide me on how we determine the cause of this exception.

Starting to wish we had not used CDO as we consistently get this issue in using the Db Store.

We also consistently get another issue when trying to export models to XML. Neither has ever been resolved and as you can see above no one has clue so far, or can't be bother to answer the question.
Re: [CDO] Old class cast exception resurfaces [message #1402966 is a reply to message #1397916] Fri, 18 July 2014 16:31 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
On 10-07-14 12:41, David Wynter wrote:
> Bump.
> Maybe someone who reads this can guide me on how we determine the cause
> of this exception.
> Starting to wish we had not used CDO as we consistently get this issue
> in using the Db Store.
> We also consistently get another issue when trying to export models to
> XML. Neither has ever been resolved and as you can see above no one has
> clue so far, or can't be bother to answer the question.
Hi David,
As you can see Eike is not very present on the forum lately. Any chance
you can debug/reproduce the problem yourself? It's new for me. (I use
CDO extensively).

Cheers CHristophe
Re: [CDO] Old class cast exception resurfaces [message #1403198 is a reply to message #1402966] Tue, 22 July 2014 06:16 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
Christophe can you drop me an email to my gmail account. My user name is stpdave there. I will have to share a rather large, and private repo with you that exhibits the issue of the corrupt repo with the class cast exception. I will also add a JUnit test case, assume you have a CDO Server implementation to connect to the H2 repo I supply.

Thx

David

[Updated on: Tue, 22 July 2014 08:51]

Report message to a moderator

Re: [CDO] Old class cast exception resurfaces [message #1403264 is a reply to message #1403198] Tue, 22 July 2014 12:52 Go to previous messageGo to next message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
I now have a JUnit test case and repo that have the problem. The repo is 140MB so need to share via a google drive.

...
    private CDONet4jSession session;
    private CDOTransaction transaction;
    private final Map<EObject, EObject> clones = new HashMap<EObject, EObject>();

	@Before
	public void setUp() throws Exception {
            IManagedContainer container = ContainerUtil.createContainer();
            Net4jUtil.prepareContainer(container);
            TCPUtil.prepareContainer(container);
            CDONet4jUtil.prepareContainer(container);
            container.activate();

            IConnector connector = Net4jUtil.getConnector(container, url);

            CDONet4jSessionConfiguration sessionConfiguration = CDONet4jUtil.createNet4jSessionConfiguration();
            sessionConfiguration.setConnector(connector);
            sessionConfiguration.setRepositoryName(repo);
            PasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(login, password);
            sessionConfiguration.setCredentialsProvider(credentialsProvider);

            try {
                this.session = sessionConfiguration.openNet4jSession();
                session.options().setGeneratedPackageEmulationEnabled(true);
                this.transaction = this.session.openTransaction();
            } catch (Exception ex) {
        	throw new SessionException(url, login, password, repo, ex);
            }
   	}

	@After
	public void tearDown() throws Exception {
            if (this.transaction != null) {
                this.transaction.commit();
                this.transaction.close();
                this.transaction = null;
            }
        
            if (this.session != null) {
                this.session.close();
                this.session = null;
            }
	}

	@Test
	public void test() {
            CDOResource resource = this.transaction.getResource("resTR");
            EList<EObject> contents = resource.getContents();
            this.clone(contents);

	    assert(clones.size()>0);
	}

	private void clone(Collection<EObject> children2) {
	    for (EObject eObject : children2) {
	        EObject eObjectClone = EDMModelFactory.eINSTANCE.create(eObject.eClass());
	        this.clones.put(eObject, eObjectClone);
	
	        for (EAttribute attribute : eObjectClone.eClass().getEAllAttributes()) {
	            if (!attribute.isDerived()) {
	                eObjectClone.eSet(attribute, eObject.eGet(attribute));
	            }
	        }
	
	        Collection<EObject> children = new ArrayList<EObject>();
	        for (EReference reference : eObjectClone.eClass().getEAllContainments()) {
	            try {
	                Object value = eObject.eGet(reference);
	                if (reference.isMany()) {
	                    children.addAll((Collection<EObject>) value);
	                } else {
	                    CollectionUtils.addIgnoreNull(children, value);
	                }
	            } catch (ObjectNotFoundException ex) {
	            }
	        }
	
	        this.clone(children);
	    }
        }
}


Any takers?

[Updated on: Wed, 23 July 2014 05:41]

Report message to a moderator

Re: [CDO] Old class cast exception resurfaces [message #1404031 is a reply to message #1403264] Tue, 29 July 2014 05:09 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
On 22-07-14 18:52, David Wynter wrote:
> I now have a JUnit test case and repo that have the problem. The repo is
> 140MB so need to share via a google drive.
Hi David,

Propose you put this in a new Bug and refer to the other bug you
mentioned earlier. Also mention clearly what you observe. ("The problem"
is not enough). People like to see the concise/complete issue in one go,
not spread over multiple emails please. For example, I don't see how
this test case relates to the exception you wrote earlier about.

On the Repo, it might not be needed considering it's size, but if can
provide the details of your configuration, (the cdo-server.xml),the CDO
build you use, also the DB you use, which version etc... could prove
handy. Perhaps also mention your model and EPackages, is it legacy, have
you converted it to CDO?

I notice this:

setGeneratedPackageEmulationEnabled

I never have to set this, but it might be there for a reason? Not sure
what it does.


I also notice in your clone method, you don't really clone (make a
copy), but move objects to the new destination. For Containment
references, this implies the object will not be in the source resource
anymore.


Thank You,
Christophe
>
>
> ..
> private CDONet4jSession session;
> private CDOTransaction transaction;
> private final Map<EObject, EObject> clones = new HashMap<EObject,
> EObject>();
>
> @Before
> public void setUp() throws Exception {
> IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container);
> TCPUtil.prepareContainer(container);
> CDONet4jUtil.prepareContainer(container);
> container.activate();
>
> IConnector connector = Net4jUtil.getConnector(container, url);
>
> CDONet4jSessionConfiguration sessionConfiguration =
> CDONet4jUtil.createNet4jSessionConfiguration();
> sessionConfiguration.setConnector(connector);
> sessionConfiguration.setRepositoryName(repo);
> PasswordCredentialsProvider credentialsProvider = new
> PasswordCredentialsProvider(login, password);
> sessionConfiguration.setCredentialsProvider(credentialsProvider);
>
> try {
> this.session = sessionConfiguration.openNet4jSession();
> session.options().setGeneratedPackageEmulationEnabled(true);
> this.transaction = this.session.openTransaction();
> } catch (Exception ex) {
> throw new SessionException(url, login, password, repo, ex);
> }
> }
>
> @After
> public void tearDown() throws Exception {
> if (this.transaction != null) {
> this.transaction.commit();
> this.transaction.close();
> this.transaction = null;
> }
> if (this.session != null) {
> this.session.close();
> this.session = null;
> }
> }
>
> @Test
> public void test() {
> CDOResource resource = this.transaction.getResource("resTR");
> EList<EObject> contents = resource.getContents();
> this.clone(contents);
>
> assert(clones.size()>0);
> }
>
> private void clone(Collection<EObject> children2) {
> for (EObject eObject : children2) {
> EObject eObjectClone =
> EDMModelFactory.eINSTANCE.create(eObject.eClass());
> this.clones.put(eObject, eObjectClone);
>
> for (EAttribute attribute :
> eObjectClone.eClass().getEAllAttributes()) {
> if (!attribute.isDerived()) {
> eObjectClone.eSet(attribute, eObject.eGet(attribute));
> }
> }
>
> Collection<EObject> children = new ArrayList<EObject>();
> for (EReference reference :
> eObjectClone.eClass().getEAllContainments()) {
> try {
> Object value = eObject.eGet(reference);
> if (reference.isMany()) {
> children.addAll((Collection<EObject>) value);
> } else {
> CollectionUtils.addIgnoreNull(children, value);
> }
> } catch (ObjectNotFoundException ex) {
> }
> }
>
> this.clone(children);
> }
> }
> }
>
>
> Any takers?
>
>
Re: [CDO] Old class cast exception resurfaces [message #1404033 is a reply to message #1403264] Tue, 29 July 2014 05:15 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
One more thing, I propose you use the ECoreUtil.Copier method to create
your clone. To rule out your implementation is the culprit.

On 22-07-14 18:52, David Wynter wrote:
> I now have a JUnit test case and repo that have the problem. The repo is
> 140MB so need to share via a google drive.
>
>
> ..
> private CDONet4jSession session;
> private CDOTransaction transaction;
> private final Map<EObject, EObject> clones = new HashMap<EObject,
> EObject>();
>
> @Before
> public void setUp() throws Exception {
> IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container);
> TCPUtil.prepareContainer(container);
> CDONet4jUtil.prepareContainer(container);
> container.activate();
>
> IConnector connector = Net4jUtil.getConnector(container, url);
>
> CDONet4jSessionConfiguration sessionConfiguration =
> CDONet4jUtil.createNet4jSessionConfiguration();
> sessionConfiguration.setConnector(connector);
> sessionConfiguration.setRepositoryName(repo);
> PasswordCredentialsProvider credentialsProvider = new
> PasswordCredentialsProvider(login, password);
> sessionConfiguration.setCredentialsProvider(credentialsProvider);
>
> try {
> this.session = sessionConfiguration.openNet4jSession();
> session.options().setGeneratedPackageEmulationEnabled(true);
> this.transaction = this.session.openTransaction();
> } catch (Exception ex) {
> throw new SessionException(url, login, password, repo, ex);
> }
> }
>
> @After
> public void tearDown() throws Exception {
> if (this.transaction != null) {
> this.transaction.commit();
> this.transaction.close();
> this.transaction = null;
> }
> if (this.session != null) {
> this.session.close();
> this.session = null;
> }
> }
>
> @Test
> public void test() {
> CDOResource resource = this.transaction.getResource("resTR");
> EList<EObject> contents = resource.getContents();
> this.clone(contents);
>
> assert(clones.size()>0);
> }
>
> private void clone(Collection<EObject> children2) {
> for (EObject eObject : children2) {
> EObject eObjectClone =
> EDMModelFactory.eINSTANCE.create(eObject.eClass());
> this.clones.put(eObject, eObjectClone);
>
> for (EAttribute attribute :
> eObjectClone.eClass().getEAllAttributes()) {
> if (!attribute.isDerived()) {
> eObjectClone.eSet(attribute, eObject.eGet(attribute));
> }
> }
>
> Collection<EObject> children = new ArrayList<EObject>();
> for (EReference reference :
> eObjectClone.eClass().getEAllContainments()) {
> try {
> Object value = eObject.eGet(reference);
> if (reference.isMany()) {
> children.addAll((Collection<EObject>) value);
> } else {
> CollectionUtils.addIgnoreNull(children, value);
> }
> } catch (ObjectNotFoundException ex) {
> }
> }
>
> this.clone(children);
> }
> }
> }
>
>
> Any takers?
>
>
Re: [CDO] Old class cast exception resurfaces [message #1404040 is a reply to message #1404031] Tue, 29 July 2014 05:46 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5486
Registered: July 2009
Senior Member
Am 29.07.2014 11:09, schrieb Christophe Bouhier:
> On 22-07-14 18:52, David Wynter wrote:
>> I now have a JUnit test case and repo that have the problem. The repo is
>> 140MB so need to share via a google drive.
> Hi David,
>
> Propose you put this in a new Bug and refer to the other bug you mentioned earlier. Also mention clearly what you
> observe. ("The problem" is not enough). People like to see the concise/complete issue in one go, not spread over
> multiple emails please. For example, I don't see how this test case relates to the exception you wrote earlier about.
>
> On the Repo, it might not be needed considering it's size, but if can provide the details of your configuration, (the
> cdo-server.xml),the CDO build you use, also the DB you use, which version etc... could prove handy. Perhaps also
> mention your model and EPackages, is it legacy, have you converted it to CDO?
David, some more questions:

1) Does this only happen when the server is used by concurrent clients?
2) How exactly do you launch your server? And how exactly do you configure your CDOSessions?
3) In particular, do you use CDOSession.Options.setCollectionLoadingPolicy()? If so, how?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> I notice this:
>
> setGeneratedPackageEmulationEnabled
>
> I never have to set this, but it might be there for a reason? Not sure what it does.
>
>
> I also notice in your clone method, you don't really clone (make a copy), but move objects to the new destination. For
> Containment references, this implies the object will not be in the source resource anymore.
>
>
> Thank You,
> Christophe
>>
>>
>> ..
>> private CDONet4jSession session;
>> private CDOTransaction transaction;
>> private final Map<EObject, EObject> clones = new HashMap<EObject,
>> EObject>();
>>
>> @Before
>> public void setUp() throws Exception {
>> IManagedContainer container = ContainerUtil.createContainer();
>> Net4jUtil.prepareContainer(container);
>> TCPUtil.prepareContainer(container);
>> CDONet4jUtil.prepareContainer(container);
>> container.activate();
>>
>> IConnector connector = Net4jUtil.getConnector(container, url);
>>
>> CDONet4jSessionConfiguration sessionConfiguration =
>> CDONet4jUtil.createNet4jSessionConfiguration();
>> sessionConfiguration.setConnector(connector);
>> sessionConfiguration.setRepositoryName(repo);
>> PasswordCredentialsProvider credentialsProvider = new
>> PasswordCredentialsProvider(login, password);
>> sessionConfiguration.setCredentialsProvider(credentialsProvider);
>>
>> try {
>> this.session = sessionConfiguration.openNet4jSession();
>> session.options().setGeneratedPackageEmulationEnabled(true);
>> this.transaction = this.session.openTransaction();
>> } catch (Exception ex) {
>> throw new SessionException(url, login, password, repo, ex);
>> }
>> }
>>
>> @After
>> public void tearDown() throws Exception {
>> if (this.transaction != null) {
>> this.transaction.commit();
>> this.transaction.close();
>> this.transaction = null;
>> }
>> if (this.session != null) {
>> this.session.close();
>> this.session = null;
>> }
>> }
>>
>> @Test
>> public void test() {
>> CDOResource resource = this.transaction.getResource("resTR");
>> EList<EObject> contents = resource.getContents();
>> this.clone(contents);
>>
>> assert(clones.size()>0);
>> }
>>
>> private void clone(Collection<EObject> children2) {
>> for (EObject eObject : children2) {
>> EObject eObjectClone =
>> EDMModelFactory.eINSTANCE.create(eObject.eClass());
>> this.clones.put(eObject, eObjectClone);
>>
>> for (EAttribute attribute :
>> eObjectClone.eClass().getEAllAttributes()) {
>> if (!attribute.isDerived()) {
>> eObjectClone.eSet(attribute, eObject.eGet(attribute));
>> }
>> }
>>
>> Collection<EObject> children = new ArrayList<EObject>();
>> for (EReference reference :
>> eObjectClone.eClass().getEAllContainments()) {
>> try {
>> Object value = eObject.eGet(reference);
>> if (reference.isMany()) {
>> children.addAll((Collection<EObject>) value);
>> } else {
>> CollectionUtils.addIgnoreNull(children, value);
>> }
>> } catch (ObjectNotFoundException ex) {
>> }
>> }
>>
>> this.clone(children);
>> }
>> }
>> }
>>
>>
>> Any takers?
>>
>>
>
Re: [CDO] Old class cast exception resurfaces [message #1404368 is a reply to message #1404031] Thu, 31 July 2014 11:12 Go to previous message
David Wynter is currently offline David Wynter
Messages: 4544
Registered: July 2009
Senior Member
Christophe,

In answer to your question about why I use setGeneratedPackageEmulationEnabled(true) is ably explained by Eike in response to one of your posts. In a nutshell it is required when the ECore model resides in the repo only, generally using a JUnit test.

https://www.eclipse.org/forums/index.php/mv/msg/634055/1227482/#msg_1227482

I use the clone code because it exposes the error simply by walking the model.

I am coming to this cold the guy who wrote it is no longer around. So now realise CDO is not simple and there is a great deal to learn.

Part of the problem is that while the test case exhibits the ObjectNoFoundException, the ClassCastException only shows when using the design tool product and trying to persist. So we do not have a repo that exhibits this error currently, because they fail to persist. Since the model in question has about 100 hours of data entry and the CCE has occurred about 5 times during this this is a difficulty.

I will go through the code and make changes according to Eike's suggestions and only then raise the issue if the problem persists.

Previous Topic:[EMF] long loading time
Goto Forum:
  


Current Time: Thu Jul 31 23:59:59 EDT 2014

Powered by FUDForum. Page generated in 0.01935 seconds