Alessandro De Stasio wrote: > Hi, > I'm writing a Fold Change Plugin. I need to extract all the Annotations > from a list of BioAssay. > So When I try: > > ... > DbControl dc = sc.newDbControl(); > //From the input > BioAssaySet source = getSourceBioAssaySet(dc); > List<BioAssay> bioAssays = (List<BioAssay>) > job.getValues("bioAssays"); > if(bioAssays!=null){ > Iterator it = bioAssays.iterator(); > while(it.hasNext()){ > BioAssay bassay = (BioAssay) it.next(); > AnnotationSet annSet = bassay.getAnnotationSet(); > .... > > On "bassay.getAnnotationSet()" call, I have this Exception: > > net.sf.basedb.core.ConnectionClosedException: The connection has been > closed. > at net.sf.basedb.core.DbControl.getItem(DbControl.java:718) > at net.sf.basedb.core.BioAssay.getAnnotationSet(BioAssay.java:185) > at > foldchange.src.net.sf.basedb.foldchangePlugin.FoldChangePlugin.run(FoldChangePlugin.java:170) > at > net.sf.basedb.core.PluginExecutionRequest.invoke(PluginExecutionRequest.java:108) > at > net.sf.basedb.core.InternalJobQueue$JobRunner.run(InternalJobQueue.java:487) > at java.lang.Thread.run(Thread.java:619) > > An idea? Thanks in advance
Yes, the DbControl that the 'bassay' object was loaded with is closed before the run() method on your plug-in is invoked. I was pretty sure that this was documented somewhere but I can't find anything except a single code example on http://base.thep.lu.se/chrome/site/latest/html/developerdoc/plugin_developer/plugin_developer.analyse.html I guess this is something that should be clearly stated somewhere since it is a very common mistake, even among experienced developers. In any case, the solution is simpe. Just reload the 'bassay' object with the new DbControl. The safest way is to use: bassay = BioAssay.getById(dc, bassay.getId()); before the 'bassay' object is used. In your case you should be able to do (if you change the iterator to Iterator<BioAssay>) BioAssay bassay = BioAssay.getById(dc, it.next().getId()); /Nicklas ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ basedb-devel mailing list basedb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/basedb-devel