Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchElementException when reading images of different groups with session ID #99

Open
Rylern opened this issue Feb 19, 2025 · 0 comments

Comments

@Rylern
Copy link

Rylern commented Feb 19, 2025

Bug report

Describe the bug

This is similar to #98 but the process and the error are different so I created another issue.

When using a session ID to connect to an OMERO server, a NoSuchElementException exception occurs when getting the ImageData of an image after getting the ImageData of another image that is owned by a different group.
However, when a username/password combination is used instead of the session ID, everything works correctly.

To Reproduce

Steps to reproduce the behavior:

  1. Create an OMERO server with a user belonging to two groups, and upload one image in each group.
  2. Login to the server and get the session ID. I use this request to OMERO.web.
  3. Run the following code (replace the parameters):
String serverAddress = "localhost";
int firstGroupId = 4;
int firstImageId = 46;
int secondGroupId = 5;
int secondImageId = 45;
String sessionId = "83424cb3-ebb9-4ebe-979b-d9ec190e5992";
String username = "user";
String password = "password_user";

Gateway gateway = new Gateway(new SimpleLogger());
LoginCredentials loginCredential = new LoginCredentials(sessionId, sessionId, serverAddress);
//LoginCredentials loginCredential = new LoginCredentials(username, password, serverAddress);
gateway.connect(loginCredential);

SecurityContext context1 = new SecurityContext(firstGroupId);
BrowseFacility browser1 = gateway.getFacility(BrowseFacility.class);
ImageData imageData1 = browser1.getImage(context1, firstImageId);

SecurityContext context2 = new SecurityContext(secondGroupId);
BrowseFacility browser2 = gateway.getFacility(BrowseFacility.class);
ImageData imageData2 = browser2.getImage(context2, secondImageId);

SecurityContext context3 = new SecurityContext(firstGroupId);
BrowseFacility browser3 = gateway.getFacility(BrowseFacility.class);
ImageData imageData3 = browser3.getImage(context3, firstImageId);

This code gets the ImageData of an image, then gets the ImageData of another image, then gets the ImageData of the first image. This is where the error happens.

You will get the following exception:

Exception in thread "main" java.util.NoSuchElementException
	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1052)
	at omero.gateway.facility.BrowseFacility.getImage(BrowseFacility.java:1157)
	at qupath.ext.Main.yo(Main.java:61)
	at qupath.ext.Main.main(Main.java:27)
  1. Run the following code:
String serverAddress = "localhost";
int firstGroupId = 4;
int firstImageId = 46;
int secondGroupId = 5;
int secondImageId = 45;
String sessionId = "1c128ef4-cc12-4c45-965a-6bbee7d3c526";
String username = "user";
String password = "password_user";

Gateway gateway = new Gateway(new SimpleLogger());
//LoginCredentials loginCredential = new LoginCredentials(sessionId, sessionId, serverAddress);
LoginCredentials loginCredential = new LoginCredentials(username, password, serverAddress);
gateway.connect(loginCredential);

SecurityContext context1 = new SecurityContext(firstGroupId);
BrowseFacility browser1 = gateway.getFacility(BrowseFacility.class);
ImageData imageData1 = browser1.getImage(context1, firstImageId);

SecurityContext context2 = new SecurityContext(secondGroupId);
BrowseFacility browser2 = gateway.getFacility(BrowseFacility.class);
ImageData imageData2 = browser2.getImage(context2, secondImageId);

SecurityContext context3 = new SecurityContext(firstGroupId);
BrowseFacility browser3 = gateway.getFacility(BrowseFacility.class);
ImageData imageData3 = browser3.getImage(context3, firstImageId);

No exception is thrown here. The only difference is that a username/password were used to connect instead of a session ID.

Expected behavior

No exception thrown.

Version:

@Rylern Rylern changed the title NoSuchElementException when readin images of different groups with session ID NoSuchElementException when reading images of different groups with session ID Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant