[CDO]Rollback in DBStore NullPointerException [message #990103] |
Mon, 10 December 2012 16:49  |
Eclipse User |
|
|
|
Hello.
I am trying to save an object that extends CDOObject to a database and am getting an exception that seems to be coming from the server. The server is talking to a MySQL database. The server is an instance of the org.eclipse.emf.cdo.server.product.tcp_h2 product using a cdo-server.xml with the following dbAdapter configuration:
<dbAdapter name="mysql"/>
<dataSource class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
url="jdbc:mysql://localhost:3306/repo1"
user="root"
password="password"/>
/>
It worked using the following tutorial (with a few minor changes): http://www.rcp-vision.com/?p=1285&lang=en.
This Server is being run from the IDE.
Note that this all happens the first time a database call is made so there is an empty database schema "repo1" when we start. When the following exception is thrown the CDO meta tables are created (auto created by the server) and some data is actually added to those tables but I'm pretty sure the CDO meta data never gets fully set. When I try to run the same code a second time I get a duplicate key exception.
Following is a dumbed down version of the client code, followed by the exception. I'm just wondering if this exception means anything to any of you? It looks like it's coming from the server end and I'm having a difficult time debugging this. Any help would be appreciated. Thanks
Andrew
PS: What is the significance of the string "/res1" in CDOResource resource = transaction
.getOrCreateResource("/res1") ????
CODE:
public class ReferenceTest {
private static CDOSession cdoSession;
public static void init() {
// The following lines are not needed if the extension
// registry (OSGi/Equinox) is running
Net4jUtil.prepareContainer(IPluginContainer.INSTANCE);
TCPUtil.prepareContainer(IPluginContainer.INSTANCE);
cdoSession = openSession("repo1");
}
public static CDOSession openSession(String repoName) {
final IConnector connector = (IConnector) IPluginContainer.INSTANCE
.getElement( //
"org.eclipse.net4j.connectors", // Product group
"tcp", // Type
"localhost"); // Description
CDOSessionConfiguration config = CDONet4jUtil
.createSessionConfiguration();
((CDONet4jSessionConfiguration) config).setConnector(connector);
((CDONet4jSessionConfiguration) config).setRepositoryName(repoName);
CDOSession session = config.openSession();
session.addListener(new LifecycleEventAdapter() {
@Override
protected void onDeactivated(ILifecycle lifecycle) {
connector.close();
}
});
return session;
}
/**
* Saves the List of EObjects to the specified URI. The URI must not be null.
*
* @param uri
* @param objects
* @throws IOException
*/
//public static void save(List<EObject> objects) throws IOException {
public static void save(EObject object) throws IOException {
try
{
init();
CDOTransaction transaction = cdoSession.openTransaction();
CDOResource resource = transaction
.getOrCreateResource("/res1");
resource.getContents().add(object);
transaction.commit();
cdoSession.close();
} catch (CommitException e) {
e.printStackTrace();
} finally {
if(cdoSession!=null){
cdoSession.close();
}
}
}
public static void main(String [] args)
{
java.lang.System.out.println("Starting");
//Designator extends an object that extends CDOObject
Designator d = ReferenceFactory.eINSTANCE.createDesignator();
String valid = "Y";
d.getValid().add(valid);
//Reference extends an object that extends CDOObject
Reference r = ReferenceFactory.eINSTANCE.createReference();
r.getDesignator().add(d);
try
{
save(d);
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("End");
}
}
EXCEPTON (NOTE: The trace after the string "End" is client side)
Starting
org.eclipse.emf.cdo.util.CommitException: Rollback in DBStore: java.lang.NullPointerException
at org.eclipse.emf.cdo.server.internal.db.mapping.CoreTypeMappings$TMEnum.getDefaultValue(CoreTypeMappings.java:87)
at org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping.setValue(AbstractTypeMapping.java:115)
at org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping.setValueFromRevision(AbstractTypeMapping.java:94)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeValues(HorizontalBranchingClassMapping.java:645)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeRevision(HorizontalBranchingClassMapping.java:842)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevision(DBStoreAccessor.java:584)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevisions(DBStoreAccessor.java:564)
at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:94)
at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:487)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:43)
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.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:262)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:96)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:86)
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:65)
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(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
End
at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:85)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1144)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1164)
at com.src.ewir.nighthawk.analysis.models.reference.test.ReferenceTest.save(ReferenceTest.java:91)
at com.src.ewir.nighthawk.analysis.models.reference.test.ReferenceTest.main(ReferenceTest.java:140)
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06251 seconds