Active directory and groovy runner

how to integrate groovy runner with groovy ldap ?

at present momemt coping groovy-ldap.jar to atlassian-jira/WEB-INF/lib is not an option.

import org.apache.directory.groovyldap.*
ldap = LDAP.newInstance('ldap://zanzibar:10389/')

got this error

java.lang.NoClassDefFoundError: groovy/lang/Closure
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
	at java.lang.Class.getDeclaredMethods(Unknown Source)
	at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:84)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:81)
	at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79)
	at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
	at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
	at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:250)
	at groovy.lang.MetaClassImpl.populateMethods(MetaClassImpl.java:313)
	at groovy.lang.MetaClassImpl.fillMethodIndex(MetaClassImpl.java:292)
	at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3045)
	at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:210)
	at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:241)
	at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:874)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:164)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.asType(ScriptBytecodeAdapter.java:587)
	at com.onresolve.scriptrunner.runner.JoinClassLoader.findClass(JoinClassLoader.groovy:24)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at com.onresolve.scriptrunner.runner.JoinClassLoader.super$2$loadClass(JoinClassLoader.groovy)  <+2>
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
	at com.onresolve.scriptrunner.runner.JoinClassLoader.loadClass(JoinClassLoader.groovy:42)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:655)
	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:523)
	at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:183)
	at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:168)
	at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:124)
	at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:617)
	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:269)
	at org.codehaus.groovy.control.ResolveVisitor.resolveFromModule(ResolveVisitor.java:579)
	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:269)
	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:237)
	at org.codehaus.groovy.control.ResolveVisitor.transformVariableExpression(ResolveVisitor.java:866)
	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:635)
	at org.codehaus.groovy.control.ResolveVisitor.transformMethodCallExpression(ResolveVisitor.java:1004)
	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:643)
	at org.codehaus.groovy.control.ResolveVisitor.transformBinaryExpression(ResolveVisitor.java:956)
	at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:641)
	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:139)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)
	at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1259)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
	at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:50)
	at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:167)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1063)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
	at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1202)
	at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:142)
	at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:643)
	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:923)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:585)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:534)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:286)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:259)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:245)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:203)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:367)
	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:143)
	at javax.script.AbstractScriptEngine.eval(Unknown Source)
	at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy:150)
	at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy)
	at com.onresolve.scriptrunner.runner.rest.common.UserScriptEndpoint.exec(UserScriptEndpoint.groovy:74)  <+3>
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)  <+13> (AbstractResourceMethodDispatchProvider.java:205) (ResourceJavaMethodDispatcher.java:75) (HttpMethodRule.java:288) (RightHandPathRule.java:147) (ResourceClassRule.java:108) (RightHandPathRule.java:147) (RootResourceClassesRule.java:84) (WebApplicationImpl.java:1469) (WebApplicationImpl.java:1400) (WebApplicationImpl.java:1349) (WebApplicationImpl.java:1339) (WebComponent.java:416) (ServletContainer.java:537)
	at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.doFilter(RestDelegatingServletFilter.java:178)  <+1> (ServletContainer.java:795)
	at com.atlassian.plugins.rest.module.RestDelegatingServletFilter.doFilter(RestDelegatingServletFilter.java:73)  <+7> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77) (ServletFilterModuleContainerFilter.java:63) (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.jira.tzdetect.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:39)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.jira.baseurl.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:38)  <+13> (AbstractHttpFilter.java:31) (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70) (RestServletUtilsUpdaterFilter.java:26) (RestServletUtilsUpdaterFilter.java:40) (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70) (ContextFilter.java:25) (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.mywork.client.filter.ServingRequestsFilter.doFilter(ServingRequestsFilter.java:37)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.plugins.cors.CorsFilter.doFilter(CorsFilter.java:65)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFixupFilter.doFilter(PrettyUrlsSiteMeshFixupFilter.java:36)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsDispatcherFilter.doFilter(PrettyUrlsDispatcherFilter.java:60)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFilter.doFilter(PrettyUrlsSiteMeshFilter.java:92)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsMatcherFilter.doFilter(PrettyUrlsMatcherFilter.java:56)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.labs.botkiller.BotKillerFilter.doFilter(BotKillerFilter.java:36)  <+18> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77) (ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (AccessLogFilter.java:103) (AccessLogFilter.java:87) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (XsrfTokenAdditionRequestFilter.java:54) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (ChainedFilterStepRunner.java:87) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (IteratingFilterChain.java:46) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter(PrettyUrlsCombinedMatchDispatcherFilter.java:61)  <+22> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77) (ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (SecurityFilter.java:237) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (TrustedApplicationsFilter.java:100) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (BaseLoginFilter.java:172) (JiraLoginFilter.java:70) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (IteratingFilterChain.java:46) (DelegatingPluginFilter.java:70) (OAuthFilter.java:69) (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.plugins.rest.module.servlet.RestSeraphFilter.doFilter(RestSeraphFilter.java:40)  <+3> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter(PrettyUrlsCombinedMatchDispatcherFilter.java:61)  <+9> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77) (ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (AbstractJohnsonFilter.java:71) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210)
	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)  <+10> (UrlRewriteFilter.java:394) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (GzipFilter.java:74) (GzipFilter.java:51) (JiraGzipFilter.java:55) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (IteratingFilterChain.java:46) (DelegatingPluginFilter.java:70)
	at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter(PrettyUrlsCombinedMatchDispatcherFilter.java:61)  <+40> (DelegatingPluginFilter.java:78) (IteratingFilterChain.java:42) (ServletFilterModuleContainerFilter.java:77) (ServletFilterModuleContainerFilter.java:63) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (ChainedFilterStepRunner.java:87) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (AbstractCachingFilter.java:33) (AbstractHttpFilter.java:31) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (AbstractEncodingFilter.java:41) (AbstractHttpFilter.java:31) (PathMatchingEncodingFilter.java:45) (AbstractHttpFilter.java:31) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (JiraStartupChecklistFilter.java:79) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (MultipartBoundaryCheckFilter.java:41) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (ChainedFilterStepRunner.java:87) (JiraFirstFilter.java:60) (ApplicationFilterChain.java:243) (ApplicationFilterChain.java:210) (StandardWrapperValve.java:222) (StandardContextValve.java:123) (AuthenticatorBase.java:502) (StandardHostValve.java:171) (ErrorReportValve.java:100) (StandardEngineValve.java:118) (AccessLogValve.java:953) (CoyoteAdapter.java:408) (AbstractHttp11Processor.java:1041) (AbstractProtocol.java:603) (JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: groovy.lang.Closure
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
	... 259 more

any solutions ?

4 answers

This widget could not be displayed.

> at present momemt coping groovy-ldap.jar to atlassian-jira/WEB-INF/lib is not an option.

Where have you put the LDAP library then?

This widget could not be displayed.

I asked because originally you said "coping groovy-ldap.jar to atlassian-jira/WEB-INF/lib is not an option"

I'm not sure about this one... this library is a special case because of it's import of Closure screws things up... it relies on a library only available through a plugin's classloader.

Using @Grabmight work, but again this lib is a pain as it's not in any maven repo, and isn't versioned properly.

Personally I try to use the embedded crowd stuff rather than this library, but I guess that's not much help.

for my case i need to get company attribute from AD, is it possible with crowd ?

there. /opt/jira/atlassian-jira/WEB-INF/lib/groovyldap-0.1-SNAPSHOT.jar

This widget could not be displayed.

Hi Aleksey,

as a workaround, I am currently putting groovy-ldap into the Scriptrunner package (just open the JAR file with 7zip or similar and put your groovy-ldap file into the META-INF\lib\ directory, then manually upload the plugin.

It is not perfect, but it works for me. Still, I cannot really retrieve results from LDAP, but I can at least validate entries (in my use case: user names) against LDAP.

@Jamie: crowd stuff is great, but I have not found any way to validate a provided account name against our enterprise Active Directory with Crowd (every class I looked into was only able to see users created in JIRA). Oh - and by the way, you wanted to provide me your LDAP picker few weeks ago ;)

Best regards

Dmitri

Yeah I think that's the only way for now, although it's a pain because you will forget to do it next time you upgrade.

This only applies to jars that themselves depend on groovy... others work fine. I don't know exactly why... "classloader issues".

Well, for the last 3-4 upgrades, I did remember it. :)

Now, seriously - what about that picker? This would solve my issues much more elegant than manipulating Scriptrunner... :)

This widget could not be displayed.

Putting groovy-ldap.jar into META-INF/lib/ works for me when used in script console, or in the built-in 'admin' scripts, but when used in scripted post-function, suddenly it returns com.sun.jndi.ldap.LdapCtx instead of regular Map as a result element.

Any idea how to fix it?

I have the same problem. Could someone give any suggestions?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

720 views 0 3
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