Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CLASSPATH configuration #104

Open
deric opened this issue Aug 31, 2017 · 2 comments
Open

Refactor CLASSPATH configuration #104

deric opened this issue Aug 31, 2017 · 2 comments

Comments

@deric
Copy link
Owner

deric commented Aug 31, 2017

Currently the CLASSPATH environment variable is reconfigured at multiple places, custom systemd config looks like this:

ExecStart=/bin/sh -c 'set -x; \
   . /etc/zookeeper/conf/environment; \
   CLASSPATH="/usr/lib/zookeeper/zookeeper.jar:/usr/lib/zookeeper/lib/*:$CLASSPATH"; \
   CLASSPATH="$([ -r /usr/lib/zookeeper/bin/zkEnv.sh ] && . /usr/lib/zookeeper/bin/zkEnv.sh ; echo $CLASSPATH)"; \
   mkdir -p /var/log/zookeeper; \
   $JAVA "-Dzookeeper.log.dir=/var/log/zookeeper" "-Dzookeeper.root.logger=$ZOO_LOG4J_PROP" -cp "$CLASSPATH" $JAVA_OPTS "$ZOOMAIN" "$ZOOCFG"'

in /etc/zookeeper/conf/environment file is CLASSPATH set only for archive install method:

<% if scope.lookupvar('zookeeper::install_method') != 'archive' -%>
# TODO this is really ugly
# How to find out, which jars are needed?
# seems, that log4j requires the log4j.properties file to be in the classpath
CLASSPATH="$ZOOCFGDIR:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar:$CLASSPATH"
<% end -%>

Each OS might have slightly different CLASSPATH:

  • Debian: /usr/share/java/zookeeper.jar
  • CentOS: /usr/lib/zookeeper/lib/*:/usr/lib/zookeeper/zookeeper.jar

Originally reported in #103.

@matthewmrichter
Copy link

Any progress on this issue? It's currently hosing me on centos 7 it appears. Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

Is the only alternative to use archive?

@mszymo
Copy link

mszymo commented Aug 3, 2018

@matthewmrichter and anyone else struggling to get this working on centos 7 I got a workaround from here:

#103

Pass in this parameter into the module class:
java_opts => '-cp "/usr/lib/zookeeper/lib/*:/usr/lib/zookeeper/zookeeper.jar"'

It adds /usr/lib/zookeeper/lib/*:/usr/lib/zookeeper/zookeeper.jar to the end of the class path which is what it needs to work on centos 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants