I have a problem with the new Scheduler API and LDAP

Mathias Edblom August 5, 2014

I'm getting this error running from the new Scheduler API from JIRA 6.3, when running scheduled tasks, but not when running ordanary requests.

[INFO] [talledLocalContainer] 2014-08-06 10:08:00,148 atlassian-scheduler-quartz1.clustered_Worker-3 ERROR      [services.ldap.LDAPIntegrationServiceImpl] Error in ldap connection:
[INFO] [talledLocalContainer] javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory]
..
[INFO] [talledLocalContainer] Caused by: java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory
[INFO] [talledLocalContainer] 	... 12 more

Anyone got the same error or have an idé how to solve it? I don't wont to put the JRE (rt.jar) classes in the classpath, thats also causes other problems..

The old PluginScheduler worked fine both ways....

4 answers

1 accepted

0 votes
Answer accepted
Mathias Edblom August 13, 2014

Just for anyone thats interested, I'll solved it by using an other classloader when accessing the com.sun classes within the Scheduler job. Not a perfect solution but I can't solve in another way at this moment.

1 vote
Mathias Edblom August 5, 2014

New info, it doesn't work even in the depreceted PluginScheduler in JIRA 6.3, it's the JIRA version that is the difference. Before JIRA 6.3, it worked fine, in JIRA 6.3 the scheduler doesn't work with com.sun classes, neither in the new Scheduler API or the old PluginScheduler.

Using the same components from an REST-API it works fine, even in JIRA 6.3

0 votes
Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2017

Hi,

I am facing the same issue where i am trying to connect to LDAP from a scheduled plugin Job.

Jira : 7.2.9
JRE : 1.8

I am using the "PluginAccessor.class.getClassLoader()" but still encounter the same issue of class not found.

Logs:

2017-09-26 05:35:15,875 Caesium-1-4 INFO Querying LDAP for user details ...
2017-09-26 05:35:15,880 Caesium-1-4 INFO Old classloader is - com.atlassian.sal.jira [151]
2017-09-26 05:35:15,881 Caesium-1-4 INFO New classloader is - WebappClassLoader
context: jira
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@5e265ba4

2017-09-26 05:35:15,884 Caesium-1-4 ERROR problem querying LDAP to get details for user XXXXXXXX
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory not found by com.atlassian.sal.jira [151]]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674) [?:1.8.0_131]
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) [?:1.8.0_131]
at javax.naming.InitialContext.init(InitialContext.java:244) [?:1.8.0_131]
at javax.naming.InitialContext.<init>(InitialContext.java:216) [?:1.8.0_131]
...
...

Any suggestions/pointers?

Thanks.

Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2017

Please ignore the previous post.

The classloader was reset to com.atlassian.sal.jira because of which the class was not being loaded. The new classloader was able to load the class and connect to LDAP after the fix.

0 votes
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 7, 2014

My main case for LDAP us in JIRA scheduled job for mail handling, that is a once-per-cluster job, would assume without digging that its using the scheduler api somehow. I dont see a similar problem in LDAP InitialContext creation or usage, guess Im lucky ;)

The only suggestion I have is that you should only access LDAP via a registered Component, as this is then initialized by OSGi, the classloader restrictions in place for scheduled jobs then do not apply.

Mathias Edblom August 7, 2014

Hi Andy,

I am only accessing LDAP from a registered component. And it works fine even in JIRA 6.3. The problem occures when accessing the same (working) component from the Scheduler API. I have manage to get it to work by manipilating the classloaders but I don't feel comfortable about it. But it's better then putting internal com.sun classes in the plugin classloader directly.

The last thing you wrote about "classloader restrictions don't apply", doesn't seems to be correct because I'm getting the error anyway. Strange...

Suggest an answer

Log in or Sign up to answer