Got MissingMethodException when call gerrit extension api in plugin written in groovy

26 views
Skip to first unread message

Makson Lee

unread,
Sep 17, 2017, 10:16:02 PM9/17/17
to Repo and Gerrit Discussion
here is the plugin,

import com.google.gerrit.sshd.*
import com.google.gerrit.extensions.annotations.*
import com.google.gerrit.extensions.api.*
import com.google.gerrit.extensions.api.accounts.*
import com.google.inject.*

@Export("email")
class GroovyCommand extends SshCommand {
  @Inject GerritApi api
  public void run() {
    def account = api.accounts().get()
    stdout.println account.email
  }
}

and i got the following error when run the plugin, i don't know why the get() method [1] can't be found, can you help?

groovy.lang.MissingMethodException: No signature of method: com.google.gerrit.server.api.accounts.AccountsImpl.get() is applicable for argument types: () values: []
Possible solutions: grep(), grep(java.lang.Object), getAt(java.lang.String), wait(), self(), any()
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
        at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
        at GroovyCommand.run(user-1.0.groovy:11)
        at com.google.gerrit.sshd.SshCommand$1.run(SshCommand.java:35)
        at com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:418)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:418)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Sven Selberg

unread,
Sep 18, 2017, 3:51:51 AM9/18/17
to Makson Lee, Repo and Gerrit Discussion

Hi,


What you get is not AccountApi implemented by AccountApiImpl, but instead GerritApi#accounts returns an Accounts implemented by AccountsImpl [1] which does not have a get() mehtod.


/Sven


[1] https://gerrit.googlesource.com/gerrit/+/stable-2.14/gerrit-server/src/main/java/com/google/gerrit/server/api/accounts/AccountsImpl.java



From: repo-d...@googlegroups.com <repo-d...@googlegroups.com> on behalf of Makson Lee <cdle...@gmail.com>
Sent: Monday, September 18, 2017 4:16 AM
To: Repo and Gerrit Discussion
Subject: Got MissingMethodException when call gerrit extension api in plugin written in groovy
 
--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Makson Lee

unread,
Sep 18, 2017, 5:39:49 AM9/18/17
to Repo and Gerrit Discussion
yep, my mistake, thanks for correcting.
Reply all
Reply to author
Forward
0 new messages