Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] ClassCastException persisting EJavaObject to DB
[CDO] ClassCastException persisting EJavaObject to DB [message #1219778] Thu, 05 December 2013 18:37 Go to next message
Kyle B is currently offline Kyle BFriend
Messages: 14
Registered: April 2013
Junior Member
Hello,

I posted a similar topic about a month back but didn't get much traction. I investigated further and opened a bug since this is blocking us in releasing our CDO migrated product... If anyone can give me any ideas on how to fix the issue it would be greatly appreciated.

Issue: ClassCastException when attempting to persist EStructuralFeature to an H2 database containing an EJavaObject.

EJavaObject is persisted to the database in a BLOB field.

CDO attempts to load the revision from the DB with the following function:

org.eclipse.emf.cdo.server.internal.db.mapping.CoreTypeMappings.TMJavaObject#getResultSetValue(ResultSet)
public Object getResultSetValue(ResultSet resultSet) throws SQLException
{
return resultSet.getBytes(getField().getName());
}


The byte[] returned from the getResultSetValue is then stored in the CDORevisionImpl Object[] values class variable with its index being the features id. When loading the revision and attempting to write the indication for the EJavaObject based EStructuralFeature from the following function:

org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl#writeCDOFeatureValue(EStructuralFeature, Object)
public void writeCDOFeatureValue(EStructuralFeature feature, Object value) throws IOException
{
CDOType type = CDOModelUtil.getType(feature);
type.writeValue(this, value);
}


CDOType for an EJavaObject is resolved as org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CUSTOM

the writeValue function for CUSTOM is:
public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
out.writeString((String)value);
}


the CopyValue similarly is:
protected String doCopyValue(Object value)
{
return (String)value;
}


In both the writeValue and copyValue functions, the incoming Object value is of type byte[] and a ClassCastException: cannot cast B to String is thrown. Client is unable to connect.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=423355

CDO Version 4.3-M2 (20131002-0902)

Thank you very much in advance,
Kyle

Stacktraces:
java.lang.ClassCastException: [B cannot be cast to java.lang.String
	at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$26.writeValue(CDOTypeImpl.java:561)
	at org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl.writeCDOFeatureValue(CDODataOutputImpl.java:491)
	at org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision.writeValues(BaseCDORevision.java:893)
	at org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision.write(BaseCDORevision.java:236)
	at org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl.writeCDORevision(CDODataOutputImpl.java:381)
	at org.eclipse.emf.cdo.spi.common.revision.RevisionInfo.writeRevision(RevisionInfo.java:215)
	at org.eclipse.emf.cdo.spi.common.revision.RevisionInfo.writeResult(RevisionInfo.java:153)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.LoadRevisionsIndication.responding(LoadRevisionsIndication.java:188)
	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)
	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$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


java.lang.ClassCastException: [B cannot be cast to java.lang.String
	at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$26.doCopyValue(CDOTypeImpl.java:552)
	at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$26.doCopyValue(CDOTypeImpl.java:1)
	at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.copyValue(CDOTypeImpl.java:939)
	at org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl.<init>(CDORevisionImpl.java:60)
	at org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl.copy(CDORevisionImpl.java:67)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.computeDirtyObject(TransactionCommitContext.java:1089)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.computeDirtyObjects(TransactionCommitContext.java:1036)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:602)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:46)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
	at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
	at org.eclipse.emf.cdo.internal.server.Repository.commitUnsynced(Repository.java:931)
	at org.eclipse.emf.cdo.internal.server.Repository.commit(Repository.java:924)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:315)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:100)
	at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
	at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:87)
	at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:92)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:328)
	at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:65)
	at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:66)
	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)
Re: [CDO] ClassCastException persisting EJavaObject to DB [message #1227413 is a reply to message #1219778] Sat, 04 January 2014 12:21 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 05.12.2013 19:37, schrieb Kyle B:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=423355
Thanks for the bug report. I've fixed it.

Cheers
/Eike

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


Previous Topic:[CDO] Connection Aware URI, how to use it in a ResourceSet
Next Topic:[CDO] ClassCastException loading EJavaObject
Goto Forum:
  


Current Time: Fri Apr 19 00:29:00 GMT 2024

Powered by FUDForum. Page generated in 0.01494 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top