xwikisas / application-activedirectory

Provides the UI to set up LDAP for Active Directory
GNU Lesser General Public License v2.1
1 stars 2 forks source link

NPE Error when installing Active Directory Application on XWiki 15.x #77

Closed oanalavinia closed 10 months ago

oanalavinia commented 11 months ago

Environment: Windows 11 Pro, Chrome 117, using a local instance of XWiki 15.5.2 on PostgreSQL 15, Tomcat 9.0.80, Java 17 (Oracle) , Active Directory Application 1.16.3

STEPS TO REPRODUCE

  1. Start an instance of XWiki 15.5.2
  2. Install Active Directory Application (tested with 1.16.3)
  3. Observe the XWiki console

EXPECTED RESULTS

No errors/ warnings are displayed.

ACTUAL RESULTS

Near the moment when the installation process is finished, the following NPE Error is encountered:

2023-09-13 15:40:03,712 [extension/wiki:xwiki job group daemon thread - org.xwiki.extension.job.internal.InstallJob@7bcc3a81([extension, action, com.xwiki.activedirectory:application-activedirectory-ui, wiki:xwiki])] ERROR .o.i.DefaultObservationManager - Failed to send event [org.xwiki.job.event.JobFinishedEvent@3692ce61] to listener [com.xpn.xwiki.XWiki@714162c1]
java.lang.NullPointerException: Cannot invoke "java.lang.Class.getName()" because "authClass" is null
        at com.xpn.xwiki.XWiki.onJobFinished(XWiki.java:7905)
        at com.xpn.xwiki.XWiki.onEvent(XWiki.java:7862)
        at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:338)
        at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:303)
        at org.xwiki.job.AbstractJob.jobFinished(AbstractJob.java:338)
        at org.xwiki.extension.job.internal.AbstractExtensionJob.jobFinished(AbstractExtensionJob.java:134)
        at org.xwiki.job.AbstractJob.runInContext(AbstractJob.java:251)
        at org.xwiki.job.AbstractJob.run(AbstractJob.java:223)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

After installing this module, every application install will throw this error in the XWiki console

The issue was reproduced also when installing AD on XWiki 15.3, but could not be reproduced on XWiki 14.10.16.

oanalavinia commented 11 months ago

This issue was initially opened on licensing https://github.com/xwikisas/application-licensing/issues/149, but it not reproducing for all pro apps. The problem is with the Active Directory API module and is also reproducing for identity-oauth

oanalavinia commented 11 months ago

Based on the stacktrace, the problem seems to be coming from https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java#7914 , where getAuthServiceClass(); returns null and authClass.getName() throws the error. Probably xwiki.authentication.authclass isn't correctly set, and this commit https://github.com/xwiki/xwiki-platform/commit/aadc15058b0c8ad28bd019234d1dfd047e574724 added the check that produces the error on newer XWiki versions

tmortagne commented 10 months ago

this commit https://github.com/xwiki/xwiki-platform/commit/aadc15058b0c8ad28bd019234d1dfd047e574724 added the check that produces the error on newer XWiki versions

Note that this commit is dating from XWiki 13.10, so not exactly a 15.x thing.

tmortagne commented 10 months ago

The change is most probably more https://github.com/xwiki/xwiki-platform/commit/391254acb040dbe843236435d33f3a1362233c3a#diff-da4c9f1d1dde6d89b84570874b4444f9ba12b296ca5dcca2953c5cf18078856dR5984. #onJobFinished needs to be updated to take this use case into account (an authenticator which register itself). Creating an issue on XWiki side.

tmortagne commented 10 months ago

https://jira.xwiki.org/browse/XWIKI-21497

oanalavinia commented 10 months ago

Thanks Thomas! This issue was fixed in the XWiki platform as part of https://jira.xwiki.org/browse/XWIKI-21497 for XWiki versions 15.5.4, 15.9, 15.10-rc1