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

Actions created using @methodAction don't work anymore since Alfresco 7.3 #371

Open
kpiot123 opened this issue Feb 2, 2024 · 1 comment

Comments

@kpiot123
Copy link
Member

kpiot123 commented Feb 2, 2024

With Dynamic Extensions it is possible to create action using the @methodAction annotation, however, this no longer seems to work since Alfresco v7.3.

To confirm this issue I set up an Alfresco v7.3 setup with Dynamic Extensions v3.1.0. I have a DE jar which adds an action that set the description of a node:

    public static final String SET_DESCRIPTION_ACTION = "Examples_setDescription";

    public static final String DESCRIPTION_PARAM = "description";

    @ActionMethod(SET_DESCRIPTION_ACTION)
    public void setDescription(final NodeRef nodeRef, @ActionParam(DESCRIPTION_PARAM) final String description) {
        if (nodeService.exists(nodeRef)) {
            nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, description);
        }
    }

Whenever I try to create a new rule which calls the "Examples_setDescription" action this results in an error:

org.springframework.extensions.webscripts.WebScriptException: 01020004 Wrapped Exception (with status template): null
        at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1139)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:171)
        at org.alfresco.repo.web.scripts.RepositoryContainer.lambda$transactionedExecute$2(RepositoryContainer.java:561)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:452)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:544)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:685)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:721)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:413)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:309)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:423)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210)
        at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:131)
        at org.alfresco.repo.web.scripts.AlfrescoWebScriptServlet.service(AlfrescoWebScriptServlet.java:43)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.alfresco.module.aosmodule.service.ContextRootFilter.doFilter(ContextRootFilter.java:93)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.springframework.extensions.webscripts.servlet.SecurityHeadersFilter.doFilter(SecurityHeadersFilter.java:177)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:68)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.alfresco.web.app.servlet.ClearSecurityContextFilter.doFilter(ClearSecurityContextFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:359)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.reflect.UndeclaredThrowableException
        at com.sun.proxy.$Proxy49.getBean(Unknown Source)
        at org.alfresco.repo.action.ActionServiceImpl.getActionExecuter(ActionServiceImpl.java:614)
        at org.alfresco.repo.action.ActionServiceImpl.verifyActionAccessRestrictions(ActionServiceImpl.java:608)
        at org.alfresco.repo.web.scripts.rule.AbstractRuleWebScript.checkRestrictedAccessActions(AbstractRuleWebScript.java:452)
        at org.alfresco.repo.web.scripts.rule.AbstractRuleWebScript.checkRule(AbstractRuleWebScript.java:445)
        at org.alfresco.repo.web.scripts.rule.RulePost.executeImpl(RulePost.java:74)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)
        ... 42 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.github.dynamicextensionsalfresco.actions.ActionApplicationContextProxy.invoke(ActionApplicationContextProxy.java:54)
        ... 49 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'Examples_setDescription' available
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:874)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1344)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:309)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160)
        ... 54 more

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] question

Expected Behavior

I expect actions to not cause NoSuchBeanDefinitionExceptions.

Current Behavior

Saving a rule with a DE action results in a NoSuchBeanDefinitionException.

Possible Solution

No possible solution yet but Some things have changed between Alfresco 7.2 and Alfresco 7.3.
Alfresco 7.2:
https://github.com/Alfresco/alfresco-community-repo/blob/b4a2e2d8cf5b1eb846824b45070669aa3e8904f0/remote-api/src/main/java/org/alfresco/repo/web/scripts/rule/AbstractRuleWebScript.java#L433
Alfresco 7.3:
https://github.com/Alfresco/alfresco-community-repo/blob/f7b6e90d98ac7e477a527eea766c6594ffe0e273/remote-api/src/main/java/org/alfresco/repo/web/scripts/rule/AbstractRuleWebScript.java#L441
The checkRule method does more checks in Alfresco 7.3 than in Alfresco 7.2. Eventually we end up in the ActionServiceImpl class:
https://github.com/Alfresco/alfresco-community-repo/blob/f7b6e90d98ac7e477a527eea766c6594ffe0e273/repository/src/main/java/org/alfresco/repo/action/ActionServiceImpl.java#L612C28-L612C46
This getActionExecuter method does not exist in Alfresco 7.2. The Exception occurs while calling method applicationContext.getBean. The Examples_setDescription bean cannot be found in the application context.

So was this bean never in the application context and are we just now noticing because of the added check in Alfresco 7.3 or is there a reason why the bean is not added to the application context?

Steps to Reproduce (for bugs)

Here are the jars I used for testing. One for Alfresco 7.2 and one for Alfresco 7.3. They add the "Examples_setDescription" action.
DE-jar.zip
The project to build the jars is actually just the example-dynamic-extension repository on Github

  1. Set up an Alfresco 7.3 environment
  2. Upload the jar via Dynamic Extensions dashboard
  3. Start creating a rule in Alfresco Share on a folder
  4. Choose the "Examples_setDescription" action from the dropdown
  5. Push the "create rule"button
  6. An error occurs in the log.

Your Environment

  • Alfresco version used: Alfresco 7.3.0
  • DE version used: 3.1.0
@oml41
Copy link

oml41 commented Jul 17, 2024

HI All,
the issue is based on significant changes in the ActionServiceImpl class in Alfresco. In this method (Line 612)

`private ActionExecuter getActionExecuter(String actionDefName) {
if (!actionExecuters.containsKey(actionDefName)) {
actionExecuters.put(actionDefName, applicationContext.getBean(actionDefName, ActionExecuter.class));
}

    return actionExecuters.get(actionDefName);
}

`
'getBean' is called with two parameters, but in the ActionApplicationContextProxy only calls with one parameter are considered. Therefore it doesn't find the dynamic action in this context.

Regards
Oliver

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

2 participants