Unfortunately, I have an exception at the line: IJ.runPlugIn("loci.plugins.LociImporter", buffer.toString());
The exception is:
-! 12/02/14 17:53:23:649 warning: AWT-EventQueue-0: null - createSession retry: 1
-! 12/02/14 17:53:28:651 warning: AWT-EventQueue-0: null - createSession retry: 2
Exception
omero.ClientError: Obtained null object proxy
at omero.client.createSession(client.java:698)
at loci.ome.io.OmeroReader.initFile(OmeroReader.java:250)
at loci.formats.FormatReader.setId(FormatReader.java:1244)
at loci.plugins.in.ImportProcess.initializeFile(ImportProcess.java:482)
at loci.plugins.in.ImportProcess.execute(ImportProcess.java:146)
at loci.plugins.in.Importer.showDialogs(Importer.java:141)
at loci.plugins.in.Importer.run(Importer.java:79)
at loci.plugins.LociImporter.run(LociImporter.java:81)
at ij.IJ.runUserPlugIn(IJ.java:195)
at ij.IJ.runPlugIn(IJ.java:160)
at ij.IJ.runPlugIn(IJ.java:149)
at omerotests.OmeroIJ_Plugin$2.actionPerformed(OmeroIJ_Plugin.java:192)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6414)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
at java.awt.Component.processEvent(Component.java:6179)
at java.awt.Container.processEvent(Container.java:2084)
at java.awt.Component.dispatchEventImpl(Component.java:4776)
at java.awt.Container.dispatchEventImpl(Container.java:2142)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
at java.awt.Container.dispatchEventImpl(Container.java:2128)
at java.awt.Window.dispatchEventImpl(Window.java:2492)
at java.awt.Component.dispatchEvent(Component.java:4604)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:690)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
It seems to be a connection issue, but I don't know why
Just to be sure:
- lc.getHostName() is the server address
- lc.getUserName() is the login
- lc.getPassword() is obviously the password
- ctx.getGroupID() is the group ID that I can alse get with the command imdata.getGroupId()
- id it the ImageData ID, so I can get it with the command imdata.getId()
This is the code I use:
- Code: Select all
try {
client cline = new client("omero.ohsu.edu", 4065)) ;
ServiceFactoryPrx entry = clien.createSession("mylogin", "my password") ;
System.out.println("Session opened.") ;
client unsecureClient = clien.createClient(false) ;
ServiceFactoryPrx entryUnencrypted = unsecureClient.getSession() ;
long userId = entryUnencrypted.getAdminService().getEventContext().userId ;
long groupId = entryUnencrypted.getAdminService().getEventContext().groupId ;
IContainerPrx proxy = entryUnencrypted.getContainerService() ;
ParametersI param = new ParametersI() ;
param.exp(omero.rtypes.rlong(userId)) ;
param.leaves() ; //indicate to load the images
RenderingEnginePrx renderproxy = entryUnencrypted.createRenderingEngine();
List<IObject> projects = proxy.loadContainerHierarchy(Project.class.getName(), new ArrayList<Long>(13), param) ;
Iterator<IObject> projectiter = projects.iterator() ;
while ( projectiter.hasNext() )
{
ProjectData project = new ProjectData( (Project) projectiter.next()) ;
Set<DatasetData> datasets = project.getDatasets();
Iterator<DatasetData> datasetiter = datasets.iterator();
while ( datasetiter.hasNext() )
{
DatasetData dataset = datasetiter.next() ;
Set<ImageData> images = dataset.getImages() ;
Iterator<ImageData> imiter = images.iterator() ;
while ( imiter.hasNext() )
{
ImageData imdata = imiter.next() ;
StringBuffer buffer = new StringBuffer() ;
buffer.append("location=[OMERO] open=[omero:server=") ;
buffer.append("omero.ohsu.edu") ;
buffer.append("\nuser=");
buffer.append("mylogin");
buffer.append("\nport=");
buffer.append(4065);
buffer.append("\npass=");
buffer.append("mypassword");
buffer.append("\ngroupID=");
buffer.append(imdata.getGroupId()) ;
buffer.append("\niid=");
buffer.append(imdata.getId()) ;
buffer.append("]");
LociImporter locin = new LociImporter() ;
locin.run(buffer.toString()) ;
//IJ.runPlugIn("loci.plugins.LociImporter", buffer.toString());
}
}
}
renderproxy.close() ;
clien.closeSession() ;
System.out.println("\nSession closed.") ;
if ( unsecureClient != null )
{
unsecureClient.closeSession() ;
System.out.println("Unsecure Client Session closed.") ;
}
System.exit(0) ;
}
catch (Exception ex)
{
System.err.println("Exception :-(") ;
ex.printStackTrace() ;
System.exit(0) ;
}