|
Re: Exception thrown by transaction.commit() on an empty resource [message #646947 is a reply to message #646942] |
Mon, 03 January 2011 12:38 |
|
Hi Julien,
You get better attention for CDO questions if you prefix the title with [CDO].
Comments below...
Am 03.01.2011 12:30, schrieb julien.jorge@acapnos.com:
> Hi,
>
> I have an inconsistent behavior with CDO and I don't understand the problem.
>
> Initially I have an empty database where the CDO server creates his tables "cdo_*" and "eresource_*". In my client code, I do a transaction.getOrCreateResource("R") and I add something using resource.getContents().add( MyObjectFactory.eINSTANCE.createSomething() ).
>
> When I commit the changes on the transaction, I have the following exception:
>
> Quote:
>> org.eclipse.emf.cdo.util.CommitException: java.lang.UnsupportedOperationException
>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:921)
>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:932)
>> ...
>> Caused by: java.lang.UnsupportedOperationException
>> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.doSave(Reso urceImpl.java:1438)
>> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1406)
>> at org.eclipse.emf.cdo.common.model.EMFUtil.getEPackageBytes(EM FUtil.java:254)
>> at org.eclipse.emf.cdo.common.model.CDOModelUtil.writePackage(C DOModelUtil.java:386)
>> at org.eclipse.emf.cdo.internal.common.model.CDOPackageUnitImpl .write(CDOPackageUnitImpl.java:267)
>> at org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputIm pl.writeCDOPackageUnit(CDODataOutputImpl.java:79)
>> at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactio nRequest.requestingCommit(CommitTransactionRequest.java:170)
>> at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactio nRequest.requesting(CommitTransactionRequest.java:141)
>> at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactio nRequest.requesting(CommitTransactionRequest.java:116)
>> at org.eclipse.net4j.signal.RequestWithMonitoring.requesting(Re questWithMonitoring.java:163)
>> at org.eclipse.net4j.signal.RequestWithConfirmation.doExtendedO utput(RequestWithConfirmation.java:117)
>> at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:285)
>> at org.eclipse.net4j.signal.RequestWithConfirmation.doExecute(R equestWithConfirmation.java:102)
>> at org.eclipse.net4j.signal.RequestWithMonitoring.doExecute(Req uestWithMonitoring.java:233)
>> at org.eclipse.net4j.signal.SignalActor.execute(SignalActor.jav a:66)
>> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:240)
>> at org.eclipse.net4j.signal.SignalProtocol.startSignal(SignalPr otocol.java:462)
>> at org.eclipse.net4j.signal.RequestWithConfirmation.doSend(Requ estWithConfirmation.java:87)
>> at org.eclipse.net4j.signal.RequestWithConfirmation.send(Reques tWithConfirmation.java:73)
>> at org.eclipse.net4j.signal.RequestWithMonitoring.send(RequestW ithMonitoring.java:108)
>> at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtoco l.send(CDOClientProtocol.java:375)
>> at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtoco l.commitTransaction(CDOClientProtocol.java:258)
>> at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactio nStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:7 3)
>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:907)
>> ... 45 more
This is strange. Please tell me what the following statements print out:
System.out.println(MyObjectPackage.eINSTANCE);
System.out.println(MyObjectPackage.eINSTANCE.eResource());
Are you running standalone or within OSGi?
>
>
> *But*, if I first create something in the resource using Eclipse's CDO Sessions view, then the exact same code that threw the exception above will work perfectly.
That's probably because the exception is caused by the remote registration of a *new* EPackage. If you already added an object of a class of that package your code would not try to commit the package again. The question is: Why does the CDOSessions view not fail with the same message. From the exception I can not see it. Maybe you can send me an executable example?
>
> So my question is: how do I add a first object in the resource from the client code?
There are no special obligations.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: Exception thrown by transaction.commit() on an empty resource [message #646948 is a reply to message #646947] |
Mon, 03 January 2011 12:43 |
|
Please, if you can, add the following line to the beginning of EMFUtil.getEPackageBytes():
System.out.println(ePackage);
System.out.println(ePackage.eResource());
and tell me what they print out...
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 03.01.2011 13:38, schrieb Eike Stepper:
> Hi Julien,
>
> You get better attention for CDO questions if you prefix the title with [CDO].
>
> Comments below...
>
>
>
> Am 03.01.2011 12:30, schrieb julien.jorge@acapnos.com:
>> Hi,
>>
>> I have an inconsistent behavior with CDO and I don't understand the problem.
>>
>> Initially I have an empty database where the CDO server creates his tables "cdo_*" and "eresource_*". In my client code, I do a transaction.getOrCreateResource("R") and I add something using resource.getContents().add( MyObjectFactory.eINSTANCE.createSomething() ).
>>
>> When I commit the changes on the transaction, I have the following exception:
>>
>> Quote:
>>> org.eclipse.emf.cdo.util.CommitException: java.lang.UnsupportedOperationException
>>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:921)
>>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:932)
>>> ...
>>> Caused by: java.lang.UnsupportedOperationException
>>> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.doSave(Reso urceImpl.java:1438)
>>> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1406)
>>> at org.eclipse.emf.cdo.common.model.EMFUtil.getEPackageBytes(EM FUtil.java:254)
>>> at org.eclipse.emf.cdo.common.model.CDOModelUtil.writePackage(C DOModelUtil.java:386)
>>> at org.eclipse.emf.cdo.internal.common.model.CDOPackageUnitImpl .write(CDOPackageUnitImpl.java:267)
>>> at org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputIm pl.writeCDOPackageUnit(CDODataOutputImpl.java:79)
>>> at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactio nRequest.requestingCommit(CommitTransactionRequest.java:170)
>>> at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactio nRequest.requesting(CommitTransactionRequest.java:141)
>>> at org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactio nRequest.requesting(CommitTransactionRequest.java:116)
>>> at org.eclipse.net4j.signal.RequestWithMonitoring.requesting(Re questWithMonitoring.java:163)
>>> at org.eclipse.net4j.signal.RequestWithConfirmation.doExtendedO utput(RequestWithConfirmation.java:117)
>>> at org.eclipse.net4j.signal.Signal.doOutput(Signal.java:285)
>>> at org.eclipse.net4j.signal.RequestWithConfirmation.doExecute(R equestWithConfirmation.java:102)
>>> at org.eclipse.net4j.signal.RequestWithMonitoring.doExecute(Req uestWithMonitoring.java:233)
>>> at org.eclipse.net4j.signal.SignalActor.execute(SignalActor.jav a:66)
>>> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:240)
>>> at org.eclipse.net4j.signal.SignalProtocol.startSignal(SignalPr otocol.java:462)
>>> at org.eclipse.net4j.signal.RequestWithConfirmation.doSend(Requ estWithConfirmation.java:87)
>>> at org.eclipse.net4j.signal.RequestWithConfirmation.send(Reques tWithConfirmation.java:73)
>>> at org.eclipse.net4j.signal.RequestWithMonitoring.send(RequestW ithMonitoring.java:108)
>>> at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtoco l.send(CDOClientProtocol.java:375)
>>> at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtoco l.commitTransaction(CDOClientProtocol.java:258)
>>> at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactio nStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:7 3)
>>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:907)
>>> ... 45 more
> This is strange. Please tell me what the following statements print out:
>
> System.out.println(MyObjectPackage.eINSTANCE);
> System.out.println(MyObjectPackage.eINSTANCE.eResource());
>
> Are you running standalone or within OSGi?
>
>
>>
>>
>> *But*, if I first create something in the resource using Eclipse's CDO Sessions view, then the exact same code that threw the exception above will work perfectly.
> That's probably because the exception is caused by the remote registration of a *new* EPackage. If you already added an object of a class of that package your code would not try to commit the package again. The question is: Why does the CDOSessions view not fail with the same message. From the exception I can not see it. Maybe you can send me an executable example?
>
>>
>> So my question is: how do I add a first object in the resource from the client code?
> There are no special obligations.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: Exception thrown by transaction.commit() on an empty resource [message #646968 is a reply to message #646954] |
Mon, 03 January 2011 16:28 |
|
Hi Julien,
I think Ed figured this out: You probably forgot to deploy org.eclipse.emf.ecore.xmi to your flat classpath.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 03.01.2011 15:48, schrieb julien.jorge@acapnos.com:
> Eike
>> This is strange. Please tell me what the following statements print out:
>>
>> System.out.println(MyObjectPackage.eINSTANCE);
>> System.out.println(MyObjectPackage.eINSTANCE.eResource());
>
>
> The result is:
> console
>> com.company.myobject.impl.MyObjectPackageImpl@65d9e279 (name: myobject) (nsURI: http://www.company.com/company/myobject, nsPrefix: com.company.myobject)
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl@105585dc uri='http://www.company.com/company/myobject'
>
>
> Eike
>> Are you running standalone or within OSGi?
>
> We are running without OSGi, from a BlazeDS server in Tomcat actually. Also, I did try to add a static main() in my class and run it from Eclipse as a Java application and ended with the same error.
>
> Eike
>> Julien
>> > *But*, if I first create something in the resource using Eclipse's CDO Sessions view, then the exact same code that threw the exception above will work perfectly.
>>
>> That's probably because the exception is caused by the remote registration of a *new* EPackage. If you already added an object of a class of that package your code would not try to commit the package again. The question is: Why does the CDOSessions view not fail with the same message. From the exception I can not see it. Maybe you can send me an executable example?
>
>
> I can't send you a running example but I can show you how I initialize the whole stuff. Maybe I did something wrong:
> private CDOTransaction m_transaction;
> private CDOSession m_session;
> private IConnector m_connector;
> private IManagedContainer m_container;
> private CDOResource m_resource;
>
> // The initialization is below
>
> this.m_container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(this.m_container);
> TCPUtil.prepareContainer(this.m_container);
> CDONet4jUtil.prepareContainer(this.m_container);
>
> this.m_container.activate();
> this.m_connector = TCPUtil.getConnector(this.m_container, "localhost:2036");
>
> CDOSessionConfiguration configuration = CDONet4jUtil.createSessionConfiguration();
> configuration.setConnector(this.m_connector);
> configuration.setRepositoryName( "MyRepository" );
> this.m_session = configuration.openSession();
> this.m_session.getPackageRegistry().putEPackage(MyObjectPack age.eINSTANCE);
> this.m_transaction = this.m_session.openTransaction();
> this.m_resource = this.m_transaction.getOrCreateResource("MyResource");
>
> Eike
>> Please, if you can, add the following line to the beginning of EMFUtil.getEPackageBytes():
>>
>> System.out.println(ePackage);
>> System.out.println(ePackage.eResource());
>>
>> and tell me what they print out...
>
>
> Unfortunately I have no access to EMFUtil source code.
>
> Thanks for the quick feedback by the way :)
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: Exception thrown by transaction.commit() on an empty resource [message #646977 is a reply to message #646971] |
Mon, 03 January 2011 17:30 |
|
Am 03.01.2011 18:02, schrieb julien.jorge@acapnos.com:
> Eike Stepper wrote on Mon, 03 January 2011 11:28
>> Hi Julien,
>>
>> I think Ed figured this out: You probably forgot to deploy org.eclipse.emf.ecore.xmi to your flat classpath.
>
>
> Indeed, that was the problem, thank you :)
You're welcome.
> But do you understand why the exception was not thrown when the database is non empty?
From my first answer: That's probably because the exception is caused by the remote registration of a *new* EPackage. If you already added an object of a class of that package your code would not try to commit the package again.
Only new packages are serialized (in XMI format) to the server. In your case that happened from the CDOSessions view and there, in OSGI, the ecore.xmi plugin was properly deployed. Later, on your client the generated package was deployed. No need to serialize or deserialize it.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
>
> By the way, I have now a different exception:
> Quote:
>> org.eclipse.emf.cdo.util.CommitException: org.eclipse.net4j.signal.RemoteException: org.eclipse.emf.common.util.WrappedException: java.lang.ClassNotFoundException: com.company.myobject.MyObjectPackage
>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:921)
>> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. commit(CDOTransactionImpl.java:932)
>> ...
>> Caused by: org.eclipse.net4j.signal.RemoteException: org.eclipse.emf.common.util.WrappedException: java.lang.ClassNotFoundException: com.company.myobject.MyObjectPackage
>> at org.eclipse.net4j.signal.RequestWithConfirmation.setRemoteEx ception(RequestWithConfirmation.java:128)
>> at org.eclipse.net4j.signal.SignalProtocol.handleRemoteExceptio n(SignalProtocol.java:535)
>> at org.eclipse.net4j.signal.RemoteExceptionIndication.indicatin g(RemoteExceptionIndication.java:53)
>> at org.eclipse.net4j.signal.Indication.doExtendedInput(Indicati on.java:55)
>> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:315)
>> at org.eclipse.net4j.signal.Indication.execute(Indication.java: 49)
>> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:240)
>> at org.eclipse.net4j.signal.Signal.run(Signal.java:146)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool Executor.java:1110)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo lExecutor.java:603)
>> at java.lang.Thread.run(Thread.java:636)
>> Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.ClassNotFoundException: com.company.myobject.MyObjectPackage
>> at org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescript or.getEPackage(RegistryReader.java:279)
>> at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage( EPackageRegistryImpl.java:133)
>> at org.eclipse.emf.cdo.internal.common.model.CDOPackageUnitImpl .loadPackageFromGlobalRegistry(CDOPackageUnitImpl.java:378)
>> at org.eclipse.emf.cdo.internal.common.model.CDOPackageUnitImpl .read(CDOPackageUnitImpl.java:288)
>> at org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImp l.readCDOPackageUnit(CDODataInputImpl.java:105)
>> at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicatingCommit(CommitTransactionIndicat ion.java:213)
>> at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicating(CommitTransactionIndication.ja va:167)
>> at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTra nsactionIndication.indicating(CommitTransactionIndication.ja va:122)
>> at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating (IndicationWithMonitoring.java:84)
>> at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedIn put(IndicationWithResponse.java:90)
>> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:315)
>> at org.eclipse.net4j.signal.IndicationWithResponse.execute(Indi cationWithResponse.java:63)
>> at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(In dicationWithMonitoring.java:63)
>> ... 5 more
>> Caused by: java.lang.ClassNotFoundException: com.company.myobject.MyObjectPackage
>> at org.eclipse.osgi.internal.loader.BundleLoader.findClassInter nal(BundleLoader.java:506)
>> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund leLoader.java:422)
>> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund leLoader.java:410)
>> at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:107)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>> at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(Bund leLoader.java:338)
>> at org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:232)
>> at org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1197)
>> at org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescript or.getEPackage(RegistryReader.java:272)
>> ... 17 more
>
>
> I give you this only in the case it would be obvious for you but I will search on my side too.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Powered by
FUDForum. Page generated in 0.03872 seconds