Issue 3720: Cannot load plugin reviewers
Status:  AwaitingInformation
Owner: ----
Reported by bup...@gmail.com, Dec 9, 2015
*****************************************************************
*****                                                       *****
***** !!!! THIS BUG TRACKER IS FOR GERRIT CODE REVIEW !!!!  *****
*****                                                       *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, CYANOGENMOD,  *****
***** INTERNAL ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.*****
*****                                                       *****
*****   THOSE ISSUES BELONG IN DIFFERENT ISSUE TRACKERS     *****
*****                                                       *****
*****************************************************************

Affected Version:
Gerrit 2.8.4

What steps will reproduce the problem?
1.git clone --recursive https://gerrit.googlesource.com/gerrit
2.cd gerrit
3.git clone --recursive https://gerrit.googlesource.com/plugins/reviewers
4.buck build reviewers:reviewers
5.copy generated reviewers.jar in $gerrit_home/review_site/plugins/


What is the expected output? What do you see instead?
expected output: reviewers plugin installed
actual output: Cannot load plugin reviewers, log file:
[2015-12-09 14:16:19,118] WARN  com.google.gerrit.server.plugins.PluginLoader : Cannot load plugin reviewers
java.lang.NoClassDefFoundError: com/google/gerrit/extensions/config/FactoryModule
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:278)
	at com.google.gerrit.server.plugins.PluginLoader.load(PluginLoader.java:548)
	at com.google.gerrit.server.plugins.PluginLoader.loadPlugin(PluginLoader.java:504)
	at com.google.gerrit.server.plugins.PluginLoader.runPlugin(PluginLoader.java:387)
	at com.google.gerrit.server.plugins.PluginLoader.rescan(PluginLoader.java:365)
	at com.google.gerrit.server.plugins.PluginScannerThread.run(PluginScannerThread.java:41)
Caused by: java.lang.ClassNotFoundException: com.google.gerrit.extensions.config.FactoryModule
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

Please provide any additional information below.

Dec 9, 2015
Project Member #1 david.pu...@sonymobile.com
I don't see any 'git checkout' steps, so it looks like you're building the master branch of the plugin against the master branch of Gerrit.

If you're then deploying it on Gerrit version 2.8.4, then that's why it doesn't work.  The API versions are incompatible. The FactoryModule class was moved in the master and stable-2.12 branches of Gerrit.

To build a version that works on Gerrit 2.8.x you'll need to check out that version of Gerrit, check out the stable-2.8 branch of the plugin, and build it again.

Status: AwaitingInformation
Dec 11, 2015
#2 bup...@gmail.com
Hi,

Thank you so much for your quick response. I followed your suggestions to checkout "remotes/origin/stable-2.8" branch of gerrit and reviewers repo. However, getting error at buck build step. The following steps will reproduce the problem:


$git clone --recursive https://gerrit.googlesource.com/gerrit
$cd gerrit
$git checkout remotes/origin/stable-2.8
$git clone --recursive https://gerrit.googlesource.com/plugins/reviewers
$cd reviewers
$git checkout remotes/origin/stable-2.8
$cd ..
$buck build reviewers:reviewers
Using watchman.
Parse error for build file .../gerrit/reviewers/BUCK:   File ".../gerrit/reviewers/BUCK", line 7, in <module>
    'Gerrit-Module: com.googlesource.gerrit.plugins.reviewers.Module',
  File ".../gerrit/tools/default.defs", line 159, in gerrit_plugin
    compile_deps = ['//:%s-lib' % type],
  File ".../gerrit/tools/default.defs", line 96, in java_library2
    srcs = [genfile(j)],
NameError: global name 'genfile' is not defined

[-] PARSING BUCK FILES...FINISHED 0.2s

Dec 15, 2015
#3 icee...@googlemail.com
For 2.8 the plugin  probably can only be built in-tree.

So yu need to check out (or symlink) reviewers into gerrit/plugins and build
from the gerrit dir with 
  buck build plugins/reviewers

Björn
Dec 15, 2015
#4 bup...@gmail.com
Hi Bjorn,

Thanks  so much for your reply. But I still get the same error after building in gerrit tree.
$cd gerrit/plugins
$git clone --recursive https://gerrit.googlesource.com/plugins/reviewers
$cd reviewers
$git checkout remotes/origin/stable-2.8
$cd ../..
$buck build plugins/reviewers
Parse error for build file .../gerrit/plugins/reviewers/BUCK:   File ".../gerrit/plugins/reviewers/BUCK", line 7, in <module>
    'Gerrit-Module: com.googlesource.gerrit.plugins.reviewers.Module',
  File ".../gerrit/tools/default.defs", line 159, in gerrit_plugin
    compile_deps = ['//:%s-lib' % type],
  File ".../gerrit/tools/default.defs", line 96, in java_library2
    srcs = [genfile(j)],
NameError: global name 'genfile' is not defined
Dec 15, 2015
Project Member #5 David.Os...@gmail.com
When you switch between different Gerrit branches,
.buckversion file is changed. This file contains
the SHA-1 for Buck build tool. On stable-2.8 the
content is:

274acb17e9b6dc9ee60bc1371c47a7f49640c24c

What should happen, after you issue buck build is,
Buck sould re-fetch the referenced SHA-1, rebuilt
itself and then and only then start the build
process.

It looks like it doesn't happen in your case. Have
you disabled Buck version checking machanism by
creating .nobuckcheck file in top leve gerrit
project directory? You can't do that. If I try
to build the plugin on both stable-2.8 gerrit
and reviewers plugin branches, it works as expected
and this is the log for Buck upgrading itself: [1].

[1] http://paste.openstack.org/show/482038