Please share any images or screenshots, if relevant.
[An unexpected error occurred: failed to lazily initialize a collection of role: sailpoint.object.Identity.links, could not initialize proxy - no Session sailpoint.tools.GeneralException: failed to lazily initialize a collection of role: sailpoint.object.I]
Please share any other relevant files that may be required (for example, logs).
Share all details about your problem, including any error messages you may have received.
We are raising a request with multiple entitlements/roles and when we approve the 1st workitem I have custom connector to post the request into a pubsub queue using an api. After that I doing single account aggregation using custom rule. Now the issue is after aggregation ideally it has to process the second workitem. But its throwing below error
An unexpected error occurred: failed to lazily initialize a collection of role: sailpoint.object.Identity.links, could not initialize proxy - no Session
sailpoint.tools.GeneralException: failed to lazily initialize a collection of role: sailpoint.object.Identity.links, could not initialize proxy - no Session
I am fetching Identity Links using IdentityService object.
Please provide me any suggestion that would really help me to fix the issue
Hi Manish,
This is a Custom connector i have developed to process the requests coming from sailPoint of the application type G suite. This logic has lot of other files as dependency. I am not sure why I am getting this error “sailpoint.tools.GeneralException: failed to lazily initialize a collection of role: sailpoint.object.Identity.links, could not initialize proxy - no Session”. I am using the logic to fetch Links at two places in my code, if that can be the cause then i can share you those code snippets here below. I also observed that only after adding the Single account aggregation logic it is giving the errors that i have posted above. If I am not doing Single account aggregation the code is working fine actually.
`Application application = context.getObjectByName(Application.class, applicationName);
IdentityService identityService = new IdentityService(context);
List userLinksForApp = identityService.getLinks(identity, application);
if (accountRequest != null && accountRequest.getNativeIdentity() != null && !accountRequest.getNativeIdentity().trim().isEmpty()) {
for (Link link : userLinksForApp) {
if (link != null && !link.isDisabled()) {
if (link.getNativeIdentity() != null && !link.getNativeIdentity().isEmpty() && link.getNativeIdentity().equals(accountRequest.getNativeIdentity())) {
String primaryEmail = link.getAttribute(“primaryEmail”) != null ?
link.getAttribute(“primaryEmail”).toString() : null;
if (primaryEmail != null) {
return Optional.of(primaryEmail);
}
}
}
}
} else {
for (Link link : userLinksForApp) {
if (link != null && !link.isDisabled()) {
String primaryEmail = link.getAttribute(“primaryEmail”) != null ?
link.getAttribute(“primaryEmail”).toString() : null;
if (primaryEmail != null) {
return Optional.of(primaryEmail);
}
}
}
}`
`Identity identity = plan.getIdentity();
Application app = sailPointContext.getObjectByName(Application.class, configuredApplicationName);
IdentityService identityService = new IdentityService(sailPointContext);
List userLinksForApp = identityService.getLinks(identity, app);
for (Link link : userLinksForApp) {
if (link != null && !link.isDisabled()) {
String nativeIdentity = link.getNativeIdentity();
if (nativeIdentity != null && !nativeIdentity.trim().isEmpty()) {
return Optional.of(nativeIdentity);
}
}
}`
Application appObject = context.getObjectByName(Application.class, applicationName);
if (appObject == null) {
log.error("Application not found: " + applicationName);
return;
}
// Fully load and detach application to avoid LazyInitializationException
context.decache(appObject);
String appConnName = appObject.getConnector();
Connector appConnector = ConnectorFactory.getConnector(appObject, null);
if (appConnector == null) {
log.error("Connector initialization failed for application: " + applicationName);
return;
}
ResourceObject rObj = null;
try {
rObj = (ResourceObject) appConnector.getObject("account", nativeIdentity, null);
} catch (Exception e) {
log.error("Error fetching ResourceObject for nativeIdentity: " + nativeIdentity, e);
return;
}
if (rObj == null) {
log.warn("No account found in target system for nativeIdentity: " + nativeIdentity);
return;
}
Rule customizationRule = appObject.getCustomizationRule();
if (customizationRule != null) {
try {
Map<String, Object> ruleArgs = new HashMap<>();
ruleArgs.put("context", context);
ruleArgs.put("log", log);
ruleArgs.put("object", rObj);
ruleArgs.put("application", appObject);
ruleArgs.put("connector", appConnector);
ruleArgs.put("state", new HashMap<>());
Object ruleResult = context.runRule(customizationRule, ruleArgs, null);
if (ruleResult != null && ruleResult instanceof ResourceObject) {
rObj = (ResourceObject) ruleResult;
}
} catch (Exception e) {
log.error("Error executing customization rule for application: " + applicationName, e);
}
}
Attributes argMap = getAggregationArguments(customObject, customObjectName);
if (argMap == null) {
argMap = new Attributes();
}
try {
Aggregator agg = new Aggregator(context, argMap);
TaskResult taskResult = agg.aggregate(appObject, rObj);
log.info("Single account aggregation completed successfully for nativeIdentity: " + nativeIdentity);
log.debug("Aggregation result summary: " + taskResult.toXml());
} catch (Exception e) {
log.error("Error during single account aggregation for nativeIdentity: " + nativeIdentity, e);
}
Use the above code and let me know if you get the error. Usually, Lazy Initialize Error comes when do not decache the objects. Here Application object is one of that examples that can cause this issue.
I have added the above code you have shared and i got the below error
2025-10-21T04:43:34,224 - Error during single account aggregation for nativeIdentity:” “ : failed to lazily initialize a collection of role: sailpoint.object.Application.activityDataSources, could not initialize proxy - no Session - continuing with main SQS processing
2025-10-21T04:43:34,224 DEBUG - Exception details:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: sailpoint.object.Application.activityDataSources, could not initialize proxy - no Session