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)