-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
2.12.0
-
3
-
Severity 3 - Minor
-
6
-
When executing code in a plugin, and calling methods on a RemoteDirectory instance, retrieved from a DirectoryInstanceLoader, these methods get executed using the context classloader of the plugin, rather than that of the host product (which they should, as they're service objects instantiated by the product).
Most of the time this doesn't prevent them from being used, but in some cases (for example when executing the method causes an LDAP interaction), having the wrong contextclassloader might cause the calls to fail with a ClassNotFoundException.
Sample stacktrace:
com.atlassian.crowd.exception.OperationFailedException: org.springframework.transaction.CannotCreateTransactionException: Could not create DirContext instance for transaction; nested exception is org.springframework.ldap.CommunicationException: Loading the socket factory; nested exception is javax.naming.CommunicationException: Loading the socket factory [Root exception is java.lang.ClassNotFoundException: com.atlassian.crowd.directory.ssl.LdapHostnameVerificationSSLSocketFactory]
at com.atlassian.crowd.directory.SpringLDAPConnector.pageSearchResults(SpringLDAPConnector.java:405)
at com.atlassian.crowd.directory.SpringLDAPConnector.searchEntitiesWithRequestControls(SpringLDAPConnector.java:440)
at com.atlassian.crowd.directory.SpringLDAPConnector.searchEntities(SpringLDAPConnector.java:424)
at com.atlassian.crowd.directory.SpringLDAPConnector.searchUserObjects(SpringLDAPConnector.java:627)
at com.atlassian.crowd.directory.SpringLDAPConnector.searchUsers(SpringLDAPConnector.java:974)
- mentioned in
-
Page Failed to load
This is due to `com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler` not wrapping the result of the call from DirectoryInstanceLoader. So the RemoteDirectory service objects don't get wrapped, and it's methods are executed without the classloader switching.