I have a problem with the new Scheduler API and LDAP

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
Accepted answer

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.

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

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.

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...


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.


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:

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?


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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 13, 2019 in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

619 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you