Struts 6.3 upgrade in Confluence 8.6

Hi @cheinig
You might find my previous reply helpful.

1 Like

That works! I thought we already had this package-import, but it was only com.opensymphony.xwork2;resolution:=optional

Thank you.

Does confluence-compat-lib have documentation posted anywhere? I don’t see it on https://docs.atlassian.com/

The return type of actionContextCompatManager.getParameters() seems to have changed from Map<String,String[]> to Map<String,String>, which isn’t caught by the compiler (apparently) but was fortunately caught by our QA testing. It would be great to have documentation and/or release notes to spell out such changes more explicitly.

(I’m guessing that’s what you were talking about when you said “Fixed #getParameters not being consistent between WebWork and Struts2”, but that doesn’t really explain what the inconsistency was or that it was a breaking change.)

Thanks for providing this compat lib! It’s immensely helpful!

2 Likes

We’ll look to create a dedicated page for confluence-compat-lib prior to its next release.

Unfortunately, we were unable to enforce type safety with many of the getter APIs as WebWork itself does not enforce type safety for the underlying APIs. So we recommend verifying the return type before acting on it.

1 Like

Thanks @Kusal
I have noticed on my 8.6.1 test server that I have this all over the place. Is this a problem with Confluence? I see it for every page render… a warning from SecurityMemberAccess about a non-public ConfluenceActionSupport.settingsManager.

2023-11-09 15:37:21,644 WARN [http-nio-8090-exec-78] [opensymphony.xwork2.ognl.SecurityMemberAccess] isAccessible Access to non-public [protected com.atlassian.confluence.setup.settings.SettingsManager com.atlassian.confluence.core.ConfluenceActionSupport.settingsManager] is blocked!
– url: /display/TS/MyPage | userName: admin | referer: https://myhost/display/TS/MyPage | traceId: 8c9eac3dd94019e9

This is a known issue (inconsequential to functionality) and will be rectified in 8.7.0.

1 Like

Hi there, has anyone experienced the following error after upgrading and trying to start a Confluence instance?

[INFO] [talledLocalContainer] 14:39:08,136 ERROR [Caesium-1-4] [scheduler.core.JobLauncher] launchAndBuildResponse Scheduled job with ID 'LuceneContentIndexFlusher' failed due to binary incompatibilities
[INFO] [talledLocalContainer] java.lang.NoSuchMethodError: 'java.lang.String com.opensymphony.xwork2.ActionContext.getName()'

Thanks in advance!

1 Like

hi there again @Kusal,
when updating the confluence-compat-lib to version 1.6.1 on one of our other apps we’ve seen that method getServletConfig() from class com.atlassian.confluence.compat.struts2.servletactioncontext.ServletActionContextCompatManager has been removed, is that correct?

Thanks in advance!

1 Like

@avelino

Yes getServletConfig() was removed as Struts does not contain such a method (only WebWork in Confluence 7.19) and so compatibility between versions for that method could not be provided.

You may find getServletContext() sufficient and it can be integrated into a dummy ServletConfig as follows:

return new ServletConfig() {
    @Override
    public String getServletName() {
        return null;
    }

    @Override
    public ServletContext getServletContext() {
        return servletActionContextManager.getServletContext();
    }

    @Override
    public String getInitParameter(String s) {
        return null;
    }

    @Override
    public Enumeration<String> getInitParameterNames() {
        return null;
    }
};

And yes the action name retrieval method has also changed and is not currently supported in confluence-compat-lib. Please use reflection instead.

1 Like

Hi there @Kusal, thanks for the solution proposed.

For the getName() error, we tried using com.atlassian.confluence.compat.struts2.servletactioncontext.ServletActionContextCompatManager as suggested in the official guide with no luck. when running the plugin an NPE is raised from inside the method:

public String getName() {
    try {
        return ((ActionContextCompat)this.delegate.get()).getName();
    } catch (NullPointerException var2) {
        log.error("Couldn't get the Name");
        return null;
    }
}

Isn’t it the proper way to go? If not, how and where you suggest using reflection?
We have the following code where the error is happening:

private Optional<String> getCurrentActionName() {

    boolean isConfluence7 = GeneralUtil.getVersionNumber().startsWith("7");

    if (isConfluence7) {
        Optional<com.opensymphony.xwork.ActionContext> contextOptional = Optional.ofNullable(com.opensymphony.xwork.ActionContext.getContext());
        return contextOptional.map(ActionContext::getName);
    }

    Optional<com.opensymphony.xwork2.ActionContext> contextOptional = Optional.ofNullable(com.opensymphony.xwork2.ActionContext.getContext());
    return contextOptional.map(com.opensymphony.xwork2.ActionContext::getName);
}

Hope you can help with that as we are kind of stuck :slight_smile:

Thanks in advance

@avelino

I’ve just reinspected the confluence-compat-lib code and I can see that we do indeed provide proper compatibility for the getName() method so please ignore my previous message - no reflection is required on your end as long as you are using the ActionContextCompatManager.

Your getCurrentActionName method should look like:

private Optional<String> getCurrentActionName() {
    return Optional.ofNullable(new ActionContextCompatManager().getName());
}
1 Like

Hello @Kusal ,

Regarding the ActionContextCompatManager issue, is what we already applied and apparently it works, thanks. But…we can not avoid error logs like this one:


ERROR [Caesium-1-4] [struts2.actioncontext.ActionContextCompatManager] getName Couldn't get the Name

Is there any way to resolve if ActionContextCompat object is null or not (that is the one is causing the exception I guess) in order to call getName() method ? Is it only available in an action context? We would not like to have so much errors in the logs.

Thanks,

Gorka.

2 Likes

HI @Kusal ,
We are getting the following error when the customer upgraded to 8.6.x, configuration link is not working any more and in the logs I see the following.

There is no Action mapped for namespace [/admin/plugins/visibility/config] and action name [viewAnalytics] associated with context path []. - [unknown location]
 -- url: /admin/plugins/visibility/config/viewAnalytics.action | userName: automation | referer: https://confluencemax.bobfire.com/plugins/servlet/upm | traceId: 9731d4c698abafc8
2023-12-27 08:18:07,729 WARN [http-nio-8090-exec-746 url: /admin/plugins/visibility/config/viewAnalytics.action; user: automation] [apache.struts2.dispatcher.Dispatcher] logConfigurationException Could not find action or result: /admin/plugins/visibility/config/viewAnalytics.action```

        <action name="viewAnalytics" method="doViewAnalytics"
                class="com.servicerocket.confluence.plugin.visibility.analytics.VisibilityAnalyticsConfigAction">
            <result name="view" type="velocity">
                /com/servicerocket/analytics/confluence/analytics-configuration.vm
            </result>
        </action>
        <action name="analyticsConfig" method="doAnalyticsConfig"
                class="com.servicerocket.confluence.plugin.visibility.analytics.VisibilityAnalyticsConfigAction">
            <result name="success" type="redirect">viewAnalytics.action</result>
            <result name="error" type="velocity">
                /com/servicerocket/analytics/confluence/analytics-configuration.vm
            </result>
        </action>
        <action name="licenseConfig"
                class="com.servicerocket.confluence.plugin.visibility.license.ServiceRocketLicenseConfigAction">
            <result name="input" type="velocity">/templates/license/sr-license.vm</result>
            <result name="error" type="velocity">/templates/license/sr-license.vm</result>
            <result name="success" type="velocity">/templates/license/sr-license.vm</result>
        </action>
    </package>
</xwork>```

plugin xml xwork for the actions which are not working anymore are mentioned above.

Please help us in this regard. Note that it is working fine with local host url. Let me know if you need any additional details.

Thanks
RK

@GorkaGalloBustinza You should only expect the ActionContext to be populated on request threads. I can see you are trying to execute this call from a background thread - I expect that will always fail.

@ramakrishna You’ve redacted the most relevant part - the package element definition

    <package extends="default" namespace="/admin/plugins/visibility/config">
        <default-interceptor-ref name="defaultStack"/>

        <action name="viewAnalytics" method="doViewAnalytics"
                class="com.servicerocket.confluence.plugin.visibility.analytics.VisibilityAnalyticsConfigAction">
            <result name="view" type="velocity">
                /com/servicerocket/analytics/confluence/analytics-configuration.vm
            </result>
        </action>
        <action name="analyticsConfig" method="doAnalyticsConfig"
                class="com.servicerocket.confluence.plugin.visibility.analytics.VisibilityAnalyticsConfigAction">
            <result name="success" type="redirect">viewAnalytics.action</result>
            <result name="error" type="velocity">
                /com/servicerocket/analytics/confluence/analytics-configuration.vm
            </result>
        </action>
        <action name="licenseConfig"
                class="com.servicerocket.confluence.plugin.visibility.license.ServiceRocketLicenseConfigAction">
            <result name="input" type="velocity">/templates/license/sr-license.vm</result>
            <result name="error" type="velocity">/templates/license/sr-license.vm</result>
            <result name="success" type="velocity">/templates/license/sr-license.vm</result>
        </action>
    </package>

There is nothing obvious amiss.
Try navigating to /plugins/servlet/upm and check all of your plugin modules are enabled.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.