on 2023 Apr 14 8:06 PM
Hi,
While a custom Cronjob runs, we are getting an error - Error: could not translate value expression 'session.catalogversions'
There are many active search restrictions in the application, whereas this issue is caused by a particular searchRestriction that has below details
Restricted type: DiscountRow
Applies on: CustomerGroup
Filter: ({item:product} IS NOT NULL OR{item:catalogVersion} IS NULL OR {item:catalogVersion} IN (?session.catalogversions))
We are migrating from 2011 to 2205, We have other environments with same code and the restriction in 2011 version, where we do not face this issue. It only occurs in 2205 version.
Session user is admin in RUN AS tab of my cronjob. So since this restriction is on customergroup, it should not be applicable to admin in my understanding.
Any thoughts how can I resolve this without disabling the searchrestriction?
Thanks in advance!
Request clarification before answering.
Please check your cronjob is not multi-threaded and you forgot to set the context to the thread.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is an example of code on how to set the tenant, user and catalog into a new thread.
for (int i=0;i<100;i++) {
executor.execute(new Runnable() {
public void run() {
try {
Registry.setCurrentTenant(currentTenant);
JaloSession.getCurrentSession().activate();
println JaloSession.getCurrentSession().getSessionID();
userService.setCurrentUser(user);
catalogVersionService.setSessionCatalogVersions(catalogVersions);
//put your code here
} finally {
JaloSession.getCurrentSession().close();
Registry.unsetCurrentTenant();
}
}
});
}
User | Count |
---|---|
7 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.