I work on a trading engine where at the time of run, I get the log from the engine.log
like the following,
2018_01_02_03_28_20_684 INFO ZMQCommunicatorService REMOTE_EXECUTOR_MARKET_ADMIN-ALL_MARKETS-0-5 - no jzmq in java.library.path, sleeping 2 minutes then try again
2018_01_02_03_28_20_697 INFO ZMQCommunicatorService ENGINE_MARKET_ADMIN-ALL_MARKETS-0-4 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_30_20_696 INFO ZMQCommunicatorService REMOTE_EXECUTOR_MARKET_ADMIN-ALL_MARKETS-0-5 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_30_20_710 INFO ZMQCommunicatorService ENGINE_MARKET_ADMIN-ALL_MARKETS-0-4 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_32_20_697 INFO ZMQCommunicatorService REMOTE_EXECUTOR_MARKET_ADMIN-ALL_MARKETS-0-5 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_32_20_711 INFO ZMQCommunicatorService ENGINE_MARKET_ADMIN-ALL_MARKETS-0-4 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_34_20_698 INFO ZMQCommunicatorService REMOTE_EXECUTOR_MARKET_ADMIN-ALL_MARKETS-0-5 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_34_20_712 INFO ZMQCommunicatorService ENGINE_MARKET_ADMIN-ALL_MARKETS-0-4 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_36_20_699 INFO ZMQCommunicatorService REMOTE_EXECUTOR_MARKET_ADMIN-ALL_MARKETS-0-5 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
2018_01_02_03_36_20_713 INFO ZMQCommunicatorService ENGINE_MARKET_ADMIN-ALL_MARKETS-0-4 - Could not initialize class org.zeromq.ZMQ, sleeping 2 minutes then try again
I believe the first line tells the main issue,
No jzmq in java.library.path
I followed the setup manual for the ZMQ binding
for Java,
cd /root
wget https://github.com/zeromq/jzmq/archive/v3.1.0.tar.gz -O jzmq-3.1.0.tar.gz
tar zxf jzmq-3.1.0.tar.gz
cd jzmq-3.1.0
./autogen.sh
./configure --prefix=/opt/jzmq-3.1.0
nice make
make install
After I load the project, it was required to run the commands in the project root,
root@debian:~# export LD_LIBRARY_PATH=/opt/jzmq-3.1.0/lib
root@debian:~# java -Xss256k -cp /opt/jzmq-3.1.0/share/java/zmq.jar:draglet-common/target/lib/*:draglet-balser/target/lib/*:draglet-engine/target/lib/*:draglet-remote/target/lib/*:draglet-mapu/target/lib/*:draglet-shaba/target/lib/*:draglet-meba/target/lib/* -Dlog4j.configurationFile=draglet-common/src/main/resources/log4j2.xml -DisThreadContextMapInheritable=true com.draglet.batch.Batch draglet.yml
At the time I get outputs like,
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Tue Jan 02 03:59:17 EST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Is the issue has anything to do with the warning provided in the Intellij
terminal? How do I check if the jzmq is in the java.library.path
?
Ok. So, let's get hands dirty together:
to see on your machine, if this works as it ought, after a due installation, or not:
One of the simplest formal-archetype is a REQ/REP
example, that uses two parts, one - a "server":
import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;
public class rrserver{
public static void main (String[] args) {
Context context = ZMQ.context(1);
// Socket to talk to clients
Socket responder = context.socket(ZMQ.REP);
responder.bind("tcp://localhost:5560");
System.out.println("launch and connect server.");
while (!Thread.currentThread().isInterrupted()) {
// Wait for next request from client
byte[] request = responder.recv(0);
String string = new String(request);
System.out.println("Received request: ["+string+"].");
// Do some 'work'
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Send reply back to client
responder.send("World".getBytes(), 0);
}
// We never get here but clean up anyhow
responder.close();
context.term();
}
}
and another part, a "client":
import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;
public class rrclient{
public static void main(String[] args) {
Context context = ZMQ.context(1);
// Socket to talk to server
Socket requester = context.socket(ZMQ.REQ);
requester.connect("tcp://localhost:5560"); // REF ABOVE AND LET START THIS AFTER "server"
System.out.println("launch and connect client.");
for (int request_nbr = 0; request_nbr < 10; request_nbr++) {
requester.send("Hello", 0);
String reply = requester.recvStr(0);
System.out.println("Received reply " + request_nbr + " [" + reply + "]");
}
// We never get here but clean up anyhow
requester.close();
context.term();
}
}
This ought get up and running quite fast to show, if the installation was done right or not. Code was borrowed from ZeroMQ published trivial examples for inspiration.
If indeed serious about going into a domain of distributed computing, do not hesitate to read a great book from Pieter HINTJENS, "Code Connected, Volume 1" ( also available in pdf ). Worth time and efforts.
On OSX I was having a similar problem. I installed ZMQ using these instructions.
The last step says to set library path with -Djava.library.path=/usr/local/lib
.
I found it much easier to simply add the path into
~/.bash_profile
for example:
echo "export JAVA_LIBRARY_PATH=$JAVA_LIBRARY_PATH:/usr/local/lib" >> ~/.bash_profile
After restarting Intellij it was able to correctly find libjzmq
.
Also it may be a good idea to export the DYLD_LIBRARY_PATH
as well if you are planning on doing any C/C++ development.
Simply add
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/lib"
to
~/.bash_profile
.
来源:https://stackoverflow.com/questions/48057894/no-jzmq-in-java-library-path