This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 180773 - ISE: Current thread has already started a transaction
Summary: ISE: Current thread has already started a transaction
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: PC All
: P2 normal (vote)
Assignee: Antonin Nebuzelsky
URL:
Keywords:
: 180044 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-02-16 05:25 UTC by Antonin Nebuzelsky
Modified: 2010-06-10 13:45 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antonin Nebuzelsky 2010-02-16 05:25:35 UTC
java.lang.IllegalStateException: Current thread has already started a transaction
at o.n.modules.xml.xam.AbstractModel.startTransaction (AbstractModel.java:346)
at o.n.modules.xml.xam.AbstractModel.sync (AbstractModel.java:257)
at o.n.modules.maven.customizer.CustomizerProviderImpl.showCustomizer (CustomizerProviderImpl.java:146)
...

Always reproducible with the latest builds (e.g. Build 100216-852030c3a90b) when I open a project's pom.xml in editor, close this editor and try opening the project's Properties from popup menu.
Comment 1 Antonin Nebuzelsky 2010-02-19 05:31:27 UTC
This bug was revealed by the fix of issue #166414.

Now that the ModelSource's lookup always refers to the latest document opened for the POM, the code in CustomizerProviderImpl.showCustomizer() tries to sync the model and a Transaction is started for the sync(), but a Transaction has already been started in CustomizerProviderImpl.init() by creating ModelHandle instance which has the startTransaction() in its constructor.

I see two possible fixes. Moving the sync() calls for POM model and Profiles model from CustomizerProviderImpl.showCustomizer() to ModelHandle's constructor before startTransaction() is called for the models there, or refactoring startTransaction() calls from ModelHandle's constructor to a public method and calling it from CustomizerProviderImpl.showCustomizer() after the sync() is called for the models.
Comment 2 Milos Kleint 2010-02-19 08:48:56 UTC
the startTransaction() calls shall be deleted from the modelhandle and only started in the customizer after sync() I guess. The problem starts with the ModelHandleUtils class that returns a ModelHandle (in public/friend api signature). I suppose in this place we need to sync/startTransation before returning the handle for backward compatibility sake. We should definitely deprecate the ModelHandleUtils class. There is a possible loophole in the ModelHandle concept. No obvious way to explicitly rollback the transactions started. The ModelHandleUtils.write() method commits the transaction, so there could be a similar ModelHandleUtils.rollback() method, or at least explicitly document that a transaction has been started and needs to be commited./rollbacked.
Comment 3 Antonin Nebuzelsky 2010-03-23 16:23:24 UTC
http://hg.netbeans.org/core-main/rev/13ae5b397c61
Comment 4 Antonin Nebuzelsky 2010-04-07 15:22:36 UTC
*** Bug 180044 has been marked as a duplicate of this bug. ***
Comment 5 Jaroslav Pospisil 2010-06-10 13:45:32 UTC
v.