Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-dev] [protege-discussion] Problem with events and database backing

Timothy Redmond tredmond at stanford.edu
Mon Feb 17 08:11:28 PST 2014


The deadlock issue is a known issue.  The problem is that

 1. The graphical user interface, which holds the AWT-EventQueue lock,
    makes calls to the knowledge base, which is synchronized.
 2. The listeners in the knowledge base may make graphics calls.

This leads to the necessary conditions for a deadlock (the UI lock waits 
for the knowledge base lock which waits for the UI lock...).

There is a wiki page about this:

      http://protegewiki.stanford.edu/wiki/MultiThreadingConsiderationsInProtege3


I am guessing that your best solution will be the second one - run all 
knowledge base calls in the swing thread, perhaps by using the 
SwingUtilities.invokeLater routine.

-Timothy



On 02/17/2014 07:32 AM, clemens utschig wrote:
> ok next step, a deadlock if I try to update an instance directly in 
> the knowledgebase with the protege app sitting on the same project 
> instance
>
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:412)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:407)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:399)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultCls.createDirectInstance(Defaul
> tCls.java:49)
>         at 
> org.soacommunity.platform.a2x.ontology.A2XOntologyFactory.createEntit
> y(A2XOntologyFactory.java:445)
>         at 
> TestConcurrentBundles.testBundleEvents(TestConcurrentBundles.java:90)
>
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> java:39)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
> Method.java:45)
>         at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
> lable.java:15)
>         at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
> thod.java:42)
>         at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet
> hod.java:20)
>         at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>         at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.java:68)
>         at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.java:47)
>         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>         at 
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>         at 
> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>         at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4
> TestReference.java:46)
>         at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> .java:38)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:467)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:683)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
> Runner.java:390)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> tRunner.java:197)
>
> "VM Thread" prio=10 tid=0x02b3c800 nid=0x1b70 runnable
>
> "VM Periodic Task Thread" prio=10 tid=0x02b96000 nid=0x232c waiting on 
> condition
>
>
> JNI global references: 2250
>
>
> Found one Java-level deadlock:
> =============================
> "AWT-EventQueue-0":
>   waiting to lock monitor 0x02b7bf24 (object 0x286513c8, a 
> edu.stanford.smi.prot
> ege.model.DefaultKnowledgeBase),
>   which is held by "main"
> "main":
>   waiting to lock monitor 0x0329a604 (object 0x27f7d4d0, a 
> java.awt.Component$AW
> TTreeLock),
>   which is held by "AWT-EventQueue-0"
>
> Java stack information for the threads listed above:
> ===================================================
> "AWT-EventQueue-0":
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.getSystemFrames(D
> efaultKnowledgeBase.java:127)
>         - waiting to lock <0x286513c8> (a 
> edu.stanford.smi.protege.model.Default
> KnowledgeBase)
>         at 
> edu.stanford.smi.protege.model.DefaultFrame.isSystem(DefaultFrame.jav
> a:334)
>         at 
> edu.stanford.smi.protege.model.DefaultFrame.isIncluded(DefaultFrame.j
> ava:330)
>         at 
> edu.stanford.smi.protege.model.DefaultFrame.isEditable(DefaultFrame.j
> ava:322)
>         at 
> edu.stanford.smi.protege.ui.FrameRenderer.load(FrameRenderer.java:107
> )
>         at 
> edu.stanford.smi.protege.util.DefaultRenderer.setup(DefaultRenderer.j
> ava:464)
>         at 
> edu.stanford.smi.protege.util.DefaultRenderer.getTreeCellRendererComp
> onent(DefaultRenderer.java:230)
>         at 
> javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimen
> sions(BasicTreeUI.java:2712)
>         at 
> javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayout
> Cache.java:475)
>         at 
> javax.swing.tree.FixedHeightLayoutCache.getBounds(FixedHeightLayoutCa
> che.java:535)
>         at 
> javax.swing.tree.FixedHeightLayoutCache.getBounds(FixedHeightLayoutCa
> che.java:169)
>         at 
> javax.swing.tree.AbstractLayoutCache.getPreferredWidth(AbstractLayout
> Cache.java:215)
>         at 
> javax.swing.plaf.basic.BasicTreeUI.updateCachedPreferredSize(BasicTre
> eUI.java:1820)
>         at 
> javax.swing.plaf.basic.BasicTreeUI.getPreferredSize(BasicTreeUI.java:
> 1921)
>         at 
> javax.swing.plaf.basic.BasicTreeUI.getPreferredSize(BasicTreeUI.java:
> 1909)
>         at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
>         at 
> javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:76
> 9)
>         at java.awt.Container.layout(Container.java:1421)
>         at java.awt.Container.doLayout(Container.java:1410)
>         at java.awt.Container.validateTree(Container.java:1507)
>         at java.awt.Container.validate(Container.java:1480)
>         - locked <0x27f7d4d0> (a java.awt.Component$AWTTreeLock)
>         at 
> javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.j
> ava:669)
>         at 
> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
> EventQueueUtilities.java:124)
>         at 
> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>         at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
>         at java.awt.EventQueue.access$000(EventQueue.java:84)
>         at java.awt.EventQueue$1.run(EventQueue.java:602)
>         at java.awt.EventQueue$1.run(EventQueue.java:600)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at 
> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessCo
> ntrolContext.java:87)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
>         at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
> ad.java:269)
>         at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
> java:184)
>         at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
> ad.java:174)
>         at 
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
>
>         at 
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
>
>         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
> "main":
>         at java.awt.Component.setFont(Component.java:1798)
>         - waiting to lock <0x27f7d4d0> (a java.awt.Component$AWTTreeLock)
>         at java.awt.Container.setFont(Container.java:1554)
>         at javax.swing.JComponent.setFont(JComponent.java:2723)
>         at 
> edu.stanford.smi.protege.util.DefaultRenderer.setup(DefaultRenderer.j
> ava:451)
>         at 
> edu.stanford.smi.protege.util.DefaultRenderer.getTreeCellRendererComp
> onent(DefaultRenderer.java:230)
>         at 
> javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimen
> sions(BasicTreeUI.java:2712)
>         at 
> javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayout
> Cache.java:475)
>         at 
> javax.swing.tree.FixedHeightLayoutCache.getBounds(FixedHeightLayoutCa
> che.java:535)
>         at 
> javax.swing.tree.FixedHeightLayoutCache.getBounds(FixedHeightLayoutCa
> che.java:181)
>         at 
> javax.swing.plaf.basic.BasicTreeUI.getPathBounds(BasicTreeUI.java:510
> )
>         at 
> javax.swing.plaf.basic.BasicTreeUI.getPathBounds(BasicTreeUI.java:503
> )
>         at javax.swing.JTree.getPathBounds(JTree.java:2063)
>         at javax.swing.JTree.getRowBounds(JTree.java:2076)
>         at 
> edu.stanford.smi.protege.util.DefaultRenderer.getPreferredSize(Defaul
> tRenderer.java:138)
>         at 
> javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimen
> sions(BasicTreeUI.java:2721)
>         at 
> javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayout
> Cache.java:475)
>         at 
> javax.swing.tree.FixedHeightLayoutCache.getBounds(FixedHeightLayoutCa
> che.java:535)
>         at 
> javax.swing.tree.FixedHeightLayoutCache.getBounds(FixedHeightLayoutCa
> che.java:181)
>         at 
> javax.swing.plaf.basic.BasicTreeUI.getPathBounds(BasicTreeUI.java:510
> )
>         at 
> javax.swing.plaf.basic.BasicTreeUI.getPathBounds(BasicTreeUI.java:503
> )
>         at 
> javax.swing.plaf.basic.BasicTreeUI$Handler.treeNodesChanged(BasicTree
> UI.java:3765)
>         at 
> javax.swing.tree.DefaultTreeModel.fireTreeNodesChanged(DefaultTreeMod
> el.java:468)
>         at 
> javax.swing.tree.DefaultTreeModel.nodesChanged(DefaultTreeModel.java:
> 330)
>         at 
> javax.swing.tree.DefaultTreeModel.nodeChanged(DefaultTreeModel.java:2
> 61)
>         at 
> edu.stanford.smi.protege.util.LazyTreeRoot.notifyNodeChanged(LazyTree
> Root.java:84)
>         at 
> edu.stanford.smi.protege.util.LazyTreeNode.notifyNodeChanged(LazyTree
> Node.java:368)
>         at 
> edu.stanford.smi.protege.util.LazyTreeNode.notifyNodeChanged(LazyTree
> Node.java:368)
>         at 
> edu.stanford.smi.protege.util.LazyTreeNode.notifyNodeChanged(LazyTree
> Node.java:368)
>         at 
> edu.stanford.smi.protege.ui.ParentChildNode.notifyNodeChanged(ParentC
> hildNode.java:130)
>         at 
> edu.stanford.smi.protege.ui.ParentChildNode$1.directInstanceAdded(ParentChildNode.java:42) 
> ****************************************************** UI Listener?
>         at 
> edu.stanford.smi.protege.model.framestore.EventDispatchFrameStore.dispatchClsEvent(EventDispatchFrameStore.java:425)
>         at 
> edu.stanford.smi.protege.model.framestore.EventDispatchFrameStore.dis
> patchEvent(EventDispatchFrameStore.java:296)
>         at 
> edu.stanford.smi.protege.model.framestore.EventDispatchFrameStore.dis
> patchEvents(EventDispatchFrameStore.java:269)
>         at 
> edu.stanford.smi.protege.model.framestore.EventDispatchFrameStore.dis
> patchEvents(EventDispatchFrameStore.java:241)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.framestore.EventDispatchFrameStore.dis
> patchEvents(EventDispatchFrameStore.java:232)
>         at 
> edu.stanford.smi.protege.model.framestore.EventDispatchFrameStore.cre
> ateSimpleInstance(EventDispatchFrameStore.java:814)
>         at 
> edu.stanford.smi.protege.model.framestore.undo.CreateSimpleInstanceCo
> mmand.doIt(CreateSimpleInstanceCommand.java:22)
>         at 
> edu.stanford.smi.protege.model.framestore.undo.UndoFrameStore.simpleC
> ommandExecute(UndoFrameStore.java:90)
>         at 
> edu.stanford.smi.protege.model.framestore.undo.UndoFrameStore.execute
> (UndoFrameStore.java:84)
>         at 
> edu.stanford.smi.protege.model.framestore.undo.UndoFrameStore.createS
> impleInstance(UndoFrameStore.java:171)
>         at 
> edu.stanford.smi.protege.model.framestore.ArgumentCheckingFrameStore.
> createSimpleInstance(ArgumentCheckingFrameStore.java:137)
>         at 
> edu.stanford.smi.protege.model.framestore.ChangeMonitorFrameStore.cre
> ateSimpleInstance(ChangeMonitorFrameStore.java:46)
>         at 
> edu.stanford.smi.protege.model.framestore.FrameStoreAdapter.createSim
> pleInstance(FrameStoreAdapter.java:306)
>         at 
> edu.stanford.smi.protege.model.framestore.FrameStoreAdapter.createSim
> pleInstance(FrameStoreAdapter.java:306)
>         at 
> edu.stanford.smi.protege.model.framestore.ImmutableNamesFrameStore.cr 
> <http://edu.stanford.smi.protege.model.framestore.ImmutableNamesFrameStore.cr>
> eateSimpleInstance(ImmutableNamesFrameStore.java:89)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createSimpleInsta
> nce(DefaultKnowledgeBase.java:230)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:430)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:412)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:407)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultKnowledgeBase.createInstance(De
> faultKnowledgeBase.java:399)
>         - locked <0x286513c8> (a 
> edu.stanford.smi.protege.model.DefaultKnowledge
> Base)
>         at 
> edu.stanford.smi.protege.model.DefaultCls.createDirectInstance(DefaultCls.java:49) 
> ************************************************** this is the api 
> creating the thing
>         at 
> org.soacommunity.platform.a2x.ontology.A2XOntologyFactory.createEntit
> y(A2XOntologyFactory.java:445)
>         at 
> TestConcurrentBundles.testBundleEvents(TestConcurrentBundles.java:90)
>
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> java:39)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
> Method.java:45)
>         at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
> lable.java:15)
>         at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
> thod.java:42)
>         at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet
> hod.java:20)
>         at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>         at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.java:68)
>         at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun
> ner.java:47)
>         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>         at 
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>         at 
> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>         at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4
> TestReference.java:46)
>         at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> .java:38)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:467)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> eTestRunner.java:683)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
> Runner.java:390)
>         at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> tRunner.java:197)
>
> Found 1 deadlock.
>
> -------------------------
> Arg ...
>
>
> On Mon, Feb 17, 2014 at 12:56 PM, clemens utschig 
> <clemens.utschig at gmail.com <mailto:clemens.utschig at gmail.com>> wrote:
>
>     So, i got to the point of sneaking a kb object under the protege
>     app at runtime -
>     pretty much a new constructor in project (using the code from the
>     one with uri, and calling all the methods) and then
>     projectmanager.getpm.
>     setcurrentproject...
>
>         public Project(KnowledgeBase base, Collection errors, URI
>     projectUri)
>         {
>             if (log.isLoggable(Level.FINE)) {
>               log.fine("Creating Project " + "HACK" + " multiserver =
>     " + isMultiUserServer);
>             }
>             setProjectURI(projectUri);
>             _projectKB = base; // loadProjectKB(uri, factory, errors);
>
>     ProjectFixupsPluginManager.fixProject(_projectKB);
>             removeUnreferencedInstances(_projectKB);
>
>             if (_projectKB != null) {
>                 _projectInstance = getProjectInstance(_projectKB);
>             }
>
>     createDomainKnowledgeBase(base.getKnowledgeBaseFactory(), errors,
>     true);
>             setupJournaling();
>             updateKBNames();
>         }
>
>     Seriously - almost there, but now i really need your help - all
>     the default widgets are working - but when i click on an instance
>     within the instances tab the instance form does not show? no error
>     whatsoever
>
>     If i use the default project constructor (with a string) and do
>     the same thing - the instance form does show up.. Unfortunately i
>     cant debug into this with all the threads running around, so i
>     really need some advice here - is there some other magic? some
>     flag needed to be set...
>
>     On Sunday, February 16, 2014, clemens utschig
>     <clemens.utschig at gmail.com <mailto:clemens.utschig at gmail.com>> wrote:
>     > Hey timothy - first of all thanks a ton for the reply.
>     >
>     > Yes i am on version 3.5.. The problem is that i cant create a
>     server project first as i use the ontology to configure a (remote)
>     application on the fly - and want to use the protege app to do
>     configuration on top of that - think of the ontology as a graph
>     within a deployable server app. And i dont want to start messing
>     with two servers (my own and its lifecyle and the protege one ;-)
>     >
>     > I'll try to tweak the protege app tmrw a little - and see if i
>     can sneak a project instance underneath it on the fly (rather than
>     it *owning* and opening a uri..)..
>     >
>     > If you have some other super smart idea, any help is appreciated...
>     >
>     > Cheers from germany, i actually studied at stanford during my
>     time in san francisco ;-)
>     >
>     > On Saturday, February 15, 2014, Timothy Redmond
>     <tredmond at stanford.edu <mailto:tredmond at stanford.edu>> wrote:
>     >>
>     >> Just in case you didn't see my reply.
>     >>
>
>
>
>
> _______________________________________________
> protege-dev mailing list
> protege-dev at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-dev/attachments/20140217/03c61860/attachment-0001.html>


More information about the protege-dev mailing list