gitblit-org / gitblit

pure java git solution
http://gitblit.com
Apache License 2.0
2.28k stars 670 forks source link

Can't start gitblit outside GITBLIT_PATH - java.lang.NoClassDefFoundError: org/kohsuke/args4j/CmdLineException #930

Closed gilbertoca closed 9 years ago

gilbertoca commented 9 years ago

Hi, thank you for working on Gitblit. I'm trying to setup os service (openSUSE 13.2). The server start fine inside GITBLIT_PATH folder (/opt/gitblit) but fails outside, thus the service startup no work:

srv-gitblit:~ # pwd
/root
srv-gitblit:~ # java -server -Xmx1024M -Djava.awt.headless=true -jar /opt/gitblit/gitblit.jar --baseFolder /opt/gitblit-data
Exception in thread "main" java.lang.NoClassDefFoundError: org/kohsuke/args4j/CmdLineException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at org.moxie.MxLauncher.main(MxLauncher.java:127)
Caused by: java.lang.ClassNotFoundException: org.kohsuke.args4j.CmdLineException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 3 more
srv-gitblit:~ # 

Inside

srv-gitblit:~ # cd /opt/gitblit
srv-gitblit:/opt/gitblit # java -server -Xmx1024M -Djava.awt.headless=true -jar /opt/gitblit/gitblit.jar --baseFolder /opt/gitblit-data
2015-09-30 17:31:54 [INFO ] *****************************************************************
2015-09-30 17:31:54 [INFO ]             _____  _  _    _      _  _  _
2015-09-30 17:31:54 [INFO ]            |  __ \(_)| |  | |    | |(_)| |
2015-09-30 17:31:54 [INFO ]            | |  \/ _ | |_ | |__  | | _ | |_
2015-09-30 17:31:54 [INFO ]            | | __ | || __|| '_ \ | || || __|
2015-09-30 17:31:54 [INFO ]            | |_\ \| || |_ | |_) || || || |_
2015-09-30 17:31:54 [INFO ]             \____/|_| \__||_.__/ |_||_| \__|
2015-09-30 17:31:54 [INFO ]                          Gitblit v1.6.2
2015-09-30 17:31:54 [INFO ] 
2015-09-30 17:31:54 [INFO ] *****************************************************************
2015-09-30 17:31:54 [INFO ] Running on Linux (4.1.8-1-default)
2015-09-30 17:31:54 [INFO ] Logging initialized @583ms
2015-09-30 17:31:54 [INFO ] Using JCE Unlimited Strength Jurisdiction Policy files
2015-09-30 17:31:54 [INFO ] Setting up HTTPS transport on port 443
2015-09-30 17:31:54 [INFO ]    certificate alias = localhost
2015-09-30 17:31:54 [INFO ]    keyStorePath   = /opt/gitblit-data/serverKeyStore.jks
2015-09-30 17:31:54 [INFO ]    trustStorePath = /opt/gitblit-data/serverTrustStore.jks
2015-09-30 17:31:54 [INFO ]    crlPath        = /opt/gitblit-data/certs/caRevocationList.crl
2015-09-30 17:31:54 [WARN ] Gitblit needs to run with ROOT permissions for ports < 1024!
2015-09-30 17:31:54 [INFO ] Setting up HTTP transport on port 80
2015-09-30 17:31:54 [WARN ] Gitblit needs to run with ROOT permissions for ports < 1024!
2015-09-30 17:31:54 [INFO ] Configuring automatic http(80) -> https(443) redirects
2015-09-30 17:31:54 [INFO ] Shutdown Monitor listening on port 8081
2015-09-30 17:31:54 [INFO ] jetty-9.2.3.v20140905
2015-09-30 17:31:55 [INFO ] NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IRuntimeManager]----
2015-09-30 17:31:55 [INFO ] Basefolder  : /opt/gitblit-data
2015-09-30 17:31:55 [INFO ] Settings    : /opt/gitblit-data/gitblit.properties
2015-09-30 17:31:55 [INFO ] JVM timezone: Brazil/East (BRT -0300)
2015-09-30 17:31:55 [INFO ] App timezone: Brazil/East (BRT -0300)
2015-09-30 17:31:55 [INFO ] JVM locale  : pt_BR
2015-09-30 17:31:55 [INFO ] App locale  : <client>
2015-09-30 17:31:55 [INFO ] PF4J runtime mode is 'deployment'
2015-09-30 17:31:55 [INFO ] Enabled plugins: []
2015-09-30 17:31:55 [INFO ] Disabled plugins: []
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.INotificationManager]----
2015-09-30 17:31:55 [WARN ] Mail service disabled.
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IUserManager]----
2015-09-30 17:31:55 [INFO ] ConfigUserService(/opt/gitblit-data/users.conf)
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IAuthenticationManager]----
2015-09-30 17:31:55 [INFO ] External authentication disabled.
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.transport.ssh.IPublicKeyManager]----
2015-09-30 17:31:55 [INFO ] FileKeyManager (/opt/gitblit-data/ssh)
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IRepositoryManager]----
2015-09-30 17:31:55 [INFO ] Repositories folder : /opt/gitblit-data/git
2015-09-30 17:31:55 [INFO ] Identifying repositories...
2015-09-30 17:31:55 [INFO ] 0 repositories identified with calculated folder sizes in 11 msecs
2015-09-30 17:31:55 [INFO ] Lucene will process indexed branches every 2 minutes.
2015-09-30 17:31:55 [INFO ] Garbage Collector (GC) is disabled.
2015-09-30 17:31:55 [INFO ] Mirror service is disabled.
2015-09-30 17:31:55 [INFO ] Alias UTF-9 & UTF-18 encodings as UTF-8 in JGit
2015-09-30 17:31:55 [INFO ] Preparing 14 day commit cache. please wait...
2015-09-30 17:31:55 [INFO ] 0 repositories identified with calculated folder sizes in 0 msecs
2015-09-30 17:31:55 [INFO ] built 14 day commit cache of 0 commits across 0 repositories in 1 msecs
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IProjectManager]----
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IFederationManager]----
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IGitblit]----
2015-09-30 17:31:55 [INFO ] Starting services manager...
2015-09-30 17:31:55 [INFO ] Federation passphrase is blank! This server can not be PULLED from.
2015-09-30 17:31:55 [INFO ] Fanout PubSub service is disabled.
2015-09-30 17:31:55 [INFO ] Git Daemon is listening on 0.0.0.0:9418
2015-09-30 17:31:55 [INFO ] SSH Daemon (NIO2) is listening on 0.0.0.0:29418
2015-09-30 17:31:55 [WARN ] No ticket service configured.
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] ----[com.gitblit.manager.IPluginManager]----
2015-09-30 17:31:55 [INFO ] No plugins
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:55 [INFO ] All managers started.
2015-09-30 17:31:55 [INFO ] 
2015-09-30 17:31:56 [INFO ] [GitBlitWebApp] init: Wicket core library initializer
2015-09-30 17:31:56 [INFO ] [GitBlitWebApp] init: Wicket extensions initializer
2015-09-30 17:31:56 [INFO ] [GitBlitWebApp] Started Wicket version 1.4.21 in deployment mode
2015-09-30 17:31:56 [INFO ] Started o.e.j.w.WebAppContext@20b2475a{/,file:/opt/gitblit-data/temp/webapp/,AVAILABLE}{file:/opt/gitblit/gitblit.jar}
2015-09-30 17:31:56 [INFO ] Started ServerConnector@2f67a4d3{SSL-HTTP/1.1}{0.0.0.0:443}
2015-09-30 17:31:56 [INFO ] Started ServerConnector@5e3f861{HTTP/1.1}{0.0.0.0:80}
2015-09-30 17:31:56 [INFO ] Started @2367ms
gitblit commented 9 years ago

You are correct. This is the expected behavior. You must launch Gitblit from the installation directory.

gilbertoca commented 9 years ago

So, I can't setup it as OS service. How about the scripts(centos, ubuntu, ..) files in the downloaded file?

gitblit commented 9 years ago

Sure you can. Those (working) service scripts chdir to the installation directory. However you decide to startup Gitblit, you must also chdir to the installation directory.

https://github.com/gitblit/gitblit/blob/master/src/main/distrib/linux/service-ubuntu.sh#L31 https://github.com/gitblit/gitblit/blob/master/src/main/distrib/linux/service-centos.sh#L23

gilbertoca commented 9 years ago

Ah, I've used this one https://github.com/gitblit/gitblit/blob/master/src/main/distrib/linux/install-service-fedora.sh It generated the appropriated files(gitblit and gitblit.service) but fails as reported. I will try the one you suggested.

gitblit commented 9 years ago

Are you successful in getting an OpenSUSE service running?

gilbertoca commented 9 years ago

Unfortunately no! I've used your dockerfile as guide and did a manual install https://gist.github.com/gilbertoca/285095002a9325fbe3e3#file-gitblit_on_opensuse

gilbertoca commented 9 years ago

I finally got it working! I've just used the gitblit.service file:

BEM-INF007:/opt # cat /etc/systemd/system/gitblit.service 
[Unit]
Description=Gitblit managing, viewing, and serving Git repositories.
After=network.target

[Service]
User=gitblit
Group=gitblit
Environment="ARGS=-server -Xmx1024M -Djava.awt.headless=true -jar"
Environment="GITBLIT_BASE_FOLDER=/opt/gitblit/data"
WorkingDirectory=/opt/gitblit/app/1.6.2
ExecStart=/usr/bin/java $ARGS gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --dailyLogFile
ExecStop=/usr/bin/java $ARGS gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --stop

[Install]
WantedBy=multi-user.target

Status

BEM-INF007:/opt # systemctl start gitblit.service 
BEM-INF007:/opt # systemctl status gitblit.service 
gitblit.service - Gitblit managing, viewing, and serving Git repositories.
   Loaded: loaded (/etc/systemd/system/gitblit.service; enabled)
   Active: active (running) since Thu 2015-10-01 17:53:09 BRT; 2s ago
  Process: 2771 ExecStop=/usr/bin/java $ARGS gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --stop (code=exited, status=0/SUCCESS)
 Main PID: 2871 (java)
   CGroup: /system.slice/gitblit.service
           └─2871 /usr/bin/java -server -Xmx1024M -Djava.awt.headless=true -jar gitblit.jar --baseFolder /opt/gitblit/data --dailyLogFile

BEM-INF007:/opt #

Very good work on GitBlit. Thanks a lot!

gitblit commented 9 years ago

Glad to hear it. :fireworks: