ERROR [nucleusNamespace.] Invalid attempt to resolve component '' in scope global. It is defined in scope prototype

2.7k views Asked by At

I am getting the above mentioned error when i try to use the GenericService.resolveName(java.lang.String pName) The similer error for session scope as well. If i change the scope to 'global', things are working as expected. But I need to have my component in prototype scope. So what can i do..?

2

There are 2 answers

3
Mouli On

You might not be able to resolve lower scope component from higher scope object.

If you are calling resolveComponent from global scope component will might not be able to resolve it.

A component’s properties should always point to objects whose scope is equal to or greater than its own. Thus, global-scope component properties should only point to objects that also have global scope; session-scope component properties should only point to objects that have global or session scope; while request-scope component properties can point to objects of any scope, including request.

Please read the ATG documentation below

http://docs.oracle.com/cd/E35318_02/Platform.10-1-1/ATGPlatformProgGuide/html/s0205componentscopes01.html

0
Gustavo Recio On

Please validate your requirements to ensure that you actually have to use prototype scope.

As we don't know your requirements we cannot validate if what you are trying to achieve is a good practice or not, but my 2 cents to overcome your technical problem is to resolve that component starting at the request level.

If you have access to the current request, do something like:

request.resolveName(componentName);

Otherwise, do something like:

ServletUtil.getCurrentRequest().resolveName(componentName);

resolveName is a computationally expensive operation, so it should only be used when you don't have any other option (for example in a request servlet pipeline, to refer to a request or session component), but if you have to, it will solve your problem.