error while loading shared libraries: libcrfpp.so.0 - java

I checked all previous threads, set
LD_LIBRARY_PATH and followed accordingly. But still no issue.
I am trying to execute cherrypicker software and executing in this way:
./cherrypicker.sh input.txt
Error message :
/root/Desktop/karim/software/cherrypicker1.01/tools/crf++/.libs/lt-crf_test: error while loading shared libraries: libcrfpp.so.0: cannot open shared object file: No such file or directory
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at java.util.Vector.get(Vector.java:744)
at CreateNPSpan.<init>(CreateNPSpan.java:30)
at CreateNPSpan.main(CreateNPSpan.java:81)
creating feature file....
java.io.FileNotFoundException: input.txt.npspan (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at java.io.FileReader.<init>(FileReader.java:58)
at CherryPick.LoadManualEntities(CherryPick.java:111)
at CherryPick.LoadEntities(CherryPick.java:139)
at CherryPick.<init>(CherryPick.java:30)
at CherryPick.main(CherryPick.java:2188)
Exception in thread "main" java.lang.NullPointerException
at CherryPick.SortEntityMentions(CherryPick.java:171)
at CherryPick.LoadEntities(CherryPick.java:141)
at CherryPick.<init>(CherryPick.java:30)
at CherryPick.main(CherryPick.java:2188)
classifying clusters using cr joint model.....
creating output.....
Gotcha creating entities : java.lang.NumberFormatException: For input string: "no"
I checked usr/lib but there's no such file.
In directory : cherrypicker1.01/tools/crf++/.libs I found following files
crf_learn feature_index.o libcrfpp.lai lt-crf_test tagger.o
crf_test feature.o libcrfpp.o node.o
encoder.o lbfgs.o libcrfpp.so.0.0.0 param.o
feature_cache.o libcrfpp.a lt-crf_learn path.o
Any suggestion for this?

Follow these steps
Go to http://taku910.github.io/crfpp/#download and download CRF++-0.58.tar.gz
Untar above file and do ./configure, make install
In parent directories lookup for file sudo find ./ | grep libcrfpp.so.0, from there you will get where the missing file is located
copy that file to /usr/lib and cherrypicker1.01/tools/crf++/.libs/
Now it should work

The path to which the libraries reside depends upon the value passed to --prefix to the configure script. If it is not passed, then according to the source code, the default path is /usr/local/.
Actually, by default /usr/local/lib is not present the path where system searches for dynamic libraries. Hence, one can do:
echo "/usr/local/lib/" | sudo tee /etc/ld.so.conf.d/CRF.conf
sudo rm -f /etc/ld.so.cache
sudo ldconfig
Now, perform:
ldd $(which crf_test)
The output should be something similar to:
linux-vdso.so.1 (0x00007ffefc1f0000)
libcrfpp.so.0 => /usr/local/lib/libcrfpp.so.0 (0x00007f6b715b4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6b71398000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f6b71016000)
libm.so.6 => /lib64/libm.so.6 (0x00007f6b70d0e000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f6b70af7000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6b70737000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6b717f3000)
The CRF developers may wish to hard code /usr/local/lib/ or $PREFIX/lib as one of the directories to search for, inside the binaries, using RPATH. To check if a binary contains RPATH, do:
objdump -x $binary | grep RPATH

Related

Why protoc executable fails to run from Gradle on GitHub Action?

I have a ubuntu-latest GitHub action which builds a project using Gradle.
One of the Gradle tasks is a JavaExec task which runs a code generator:
task("generateCode", JavaExec::class) {
mainClass.set("code.generator.Main")
classpath = generateCodeClasspath
}
Recently the Java application has been modified to download a binary (protoc), copy it to the file system and execute it. "It works on my machine", but it fails on GitHub Action and I can't find out why.
The protoc binary is downloaded to /home/runner/work/project/project/submodule/build/protoc/bin.
Immediately before the JVM attempts to spawn the protoc process, file exists and is executable:
stat protoc
File: protoc
Size: 4539800 Blocks: 8872 IO Block: 4096 regular file
Device: 811h/2065d Inode: 1822895 Links: 1
Access: (0744/-rwxr--r--) Uid: ( 1001/ runner) Gid: ( 121/ docker)
Access: 2022-03-14 14:51:45.943750443 +0000
Modify: 2022-03-14 14:51:45.979750853 +0000
Change: 2022-03-14 14:51:45.979750853 +0000
Birth: -
ldd protoc
linux-vdso.so.1 (0x00007ffd43ba6000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc367fd3000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc367fb0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc367dbe000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc368133000)
The program is started with ProcessBuilder using these arguments:
ProcessBuilder(
"protoc",
"--proto_path",
intermediateProtoDir.absolutePath,
"--plugin",
binDir.resolve("proto-gen-rust").absolutePath,
)
However, running protoc fails with:
Exception in thread "main" java.io.IOException: Cannot run program "protoc" (in directory "/home/runner/work/project/project/submodule/build/protoc/bin"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
What am I missing?
I take it, you change into the particular directory (/home/runner/work/project/project/submodule/build/protoc/bin) before trying to execute it? Then I believe the program is not found because the current working directory is not in your $PATH and you are not specifying an absolute path in your call.
Try either adding /home/runner/work/project/project/submodule/build/protoc/bin to your $PATH or change "protoc" to "./protoc" in your call:
ProcessBuilder(
"./protoc",
"--proto_path",
intermediateProtoDir.absolutePath,
"--plugin",
binDir.resolve("proto-gen-rust").absolutePath,
)

linux - how to run a selenium-server-standalone?

I created a .sh file with the following content:
java -jar selenium-server-standalone-3.3.1.jar -Dwebdriver.gecko.driver=./opt/webdrivers/geckodriver
I already made sure that the file /opt/webdrivers/geckodriver has permission to get executed by using chmod 770 and I even changed the user to root.
But this is the result if I execute my .sh file:
root#mycomputer:/opt/Selenium# ./selenium.sh
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -Dwebdriver.gecko.driver=./opt/webdrivers/geckodriver
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$1.setConfiguration(GridLauncherV3.java:227)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:155)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:75)
What am I doing wrong?
You have to specify the parameters right after -jar:
java -jar -Dwebdriver.gecko.driver=./opt/webdrivers/geckodriver selenium-server-standalone-3.3.1.jar
Note: This is a knowledge sharing answer (share your knowledge, Q&A-style)

jnetpcap - java.lang.UnsatisfiedLinkError: com.slytechs.library.NativeLibrary.dlopen(Ljava/lang/String;)J

I am using IntelliJ to run a sample java-jnetpcap application. I have 64 bit JDK in the class path and included the following dependency
<dependency>
<groupId>jnetpcap</groupId>
<artifactId>jnetpcap</artifactId>
<version>1.4.r1425-1f</version>
</dependency>
I am running the below sample.java class
public class PcapReaderDemo
{
private static final String filePath= "/src/main/resources/TAPcapture.pcap";
public static void main(String [] arguments){
final StringBuilder errbuf = new StringBuilder();
Pcap pcap = Pcap.openOffline(filePath,errbuf);
if (pcap == null) {
System.err.printf("Error while opening device for capture: "
+ errbuf.toString());
return;
}
PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {
public void nextPacket(PcapPacket packet, String user) {
System.out.printf("Received at %s caplen=%-4d len=%-4d %s\n",
new Date(packet.getCaptureHeader().timestampInMillis()),
packet.getCaptureHeader().caplen(), // Length actually captured
packet.getCaptureHeader().wirelen(), // Original length
user // User supplied object
);
}
};
System.out.println("Cleared");
}
}
It is throwing the below exception:
PcapReaderDemo
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.slytechs.library.NativeLibrary.dlopen(Ljava/lang/String;)J
at com.slytechs.library.NativeLibrary.dlopen(Native Method)
at com.slytechs.library.NativeLibrary.<init>(Unknown Source)
at com.slytechs.library.JNILibrary.<init>(Unknown Source)
at com.slytechs.library.JNILibrary.loadLibrary(Unknown Source)
at com.slytechs.library.JNILibrary.register(Unknown Source)
at com.slytechs.library.JNILibrary.register(Unknown Source)
at com.slytechs.library.JNILibrary.register(Unknown Source)
at org.jnetpcap.Pcap.<clinit>(Unknown Source)
at com.demo.myapexapp.PcapReaderDemo.main(PcapReaderDemo.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Please suggest your inputs on where it is going wrong.
I solved the same issue this way:
using Ubuntu 16.04
installing jre-1.8.0_181 manually:
download specific java version (https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html) jre-8u181-linux-x64.tar.gz
create java directory: mkdir /opt/jre
extract java: tar -zxf jre-8u181-linux-x64.tar.gz
Update used java version:
update-alternatives --install /usr/bin/java java /opt/jre/jre1.8.0_181/bin/java 100
Download, extract und copy jnetpcap files to lib directory
wget -O jnetpcap-1.4.r1425 https://downloads.sourceforge.net/project/jnetpcap/jnetpcap/Latest/jnetpcap-1.4.r1425-1.linux64.x86_64.tgz
tar -xvf jnetpcap-1.4.r1425
cp jnetpcap-1.4.r1425/libjnetpcap.so /lib/
Run your program
I ran into this exception as well, and discovered that I had forgotten an installation step from RELEASE_NOTES.txt.
The library will fail to find the binaries unless they're placed in an OS default location, or Java is given some way to find them. For me, following the directions made this error go away.
It's hard to summarize it better than the source material, so I'll paste it here directly:
2) Setup native jnetpcap dynamically loadable library. This varies between
operating systems.
* On Win32 systems do only one of the following
- copy the jnetpcap.dll library file, found at root of jnetpcap's
installation directory to one of the window's system folders. This
could be \windows or \windows\system32 directory.
- add the jNetPcap's installation directory to system PATH variable. This
is the same variable used access executables and scripts.
- Tell Java VM at startup exactly where to find jnetpcap.dll by setting
a java system property 'java.library.path' such as:
c:\> java -Djava.library.path=%JNETPCAP_HOME%
- You can change working directory into the root of jnetpcap's
installation directory.
* On unix based systems, use one of the following
- add /usr/lib directory to LD_LIBRARY_PATH variable as java JRE does not
look in this directory by default
- Tell Java VM at startup exactly where to find jnetpcap.dll by setting
a java system property 'java.library.path' such as:
shell > java -Djava.library.path=$JNETPCAP_HOME
- You can change working directory into the root of jnetpcap's
installation directory.
* For further trouble shooting information, please see the following link:
(http://jnetpcap.wiki.sourceforge.net/Troubleshooting+native+library)
The solution that works for me was to see what was missing for libjnetpcap with ldd :
$ ldd libjnetpcap.so<br>
linux-vdso.so.1 => (0x00007ffe42706000)<br>
libstdc++.so.6 (0x00007f12ef2ad000)<br>
libpcap.so.0.9.4 => **not found**<br>
libc.so.6 => /lib64/libc.so.6 (0x00007f12eeefe000)<br>
libm.so.6 => /lib64/libm.so.6 (0x00007f12eec7a000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007f12ef861000)<br>
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f12eea63000)<br>
My version of libjnetpcap.so was searching for a libpcap.so.0.9.4.
So I just made a quick link and check with ldd :
$ ln -s /usr/lib64/libpcap.so /usr/lib64/libpcap.so.0.9.4<br>
$ ldd libjnetpcap.so<br>
linux-vdso.so.1 => (0x00007ffdaadee000)<br>
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007eff8f974000)<br>
libpcap.so.0.9.4 => /usr/lib64/libpcap.so.0.9.4 (0x00007eff8f734000)<br>
libc.so.6 => /lib64/libc.so.6 (0x00007eff8f39f000)<br>
libm.so.6 => /lib64/libm.so.6 (0x00007eff8f11b000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007eff8ff42000)<br>
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007eff8ef05000)<br>
Then all was good for me.
In Ubuntu, I also needed this library:
sudo apt install libpcap-dev
I also cp the files as described by #NormanSp and #user977860
1st Place your libjnetpcap.so inside /lib64
2nd Make sure your java version is 1.8.0_181 or below.

Open file in Eclipse through URL handler

In my project, I have a special JSP which displays the exception stacktrace in case of Exceptions.
Is there a way to use an URL handler or something else which would have Eclipse open a file? Maybe with xdg-open?
I use Eclipse 4.3 on Kubuntu Linux.
I've ended up with this solution:
Edit xdebug.ini (it should be somewhere like /etc/php/7.0/mods-available/xdebug.ini), add:
xdebug.file_link_format="xdebug://%f(%l)"
Restart your server or php-fpm. For Apache on Ubuntu use sudo service apache2 restart.
Create eclipse-launch.sh. It is intended to parse URL and pass a file to Eclipse. You can name it as you want and put it anywhere you want, I've placed it in the eclise directory. Be sure to replace /home/user with your actual home directory and path="..." with actual eclipse path:
#! /bin/bash
arg=$1
path="/home/user/eclipse/eclipse-neon/"
# file name directly followed by a line number in parenthesis
regex="//([^(]*)\(([0-9]+)\)"
if [[ $arg =~ $regex ]]
then
file=${BASH_REMATCH[1]}
line=${BASH_REMATCH[2]}
$path/eclipse --launcher.openFile "$file"+"$line"
else
msg="Unsupported URL: $arg"
zenity --info --text="$msg"
# alternatives:
# notify-send "$msg" # another notification program
# $path/eclipse # just run eclipse
fi
Read more about Eclipse command line options here: http://help.eclipse.org/mars/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/product_open_file.htm
Give the file executable permissions: chmod +a eclipse-launch.sh
Create xdebug.desktop at ~/.local/share/applications/. It will be used by xdg-open (Chrome uses xdg-open by default).
[Desktop Entry]
Comment=
Exec=/home/user/eclipse/eclipse-neon/eclipse-launch.sh "%u"
Icon=/home/user/eclipse/eclipse-neon/eclipse/icon.xpm
Name=Eclipse xdebug Launch
NoDisplay=false
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
MimeType=x-scheme-handler/xdebug;
Run xdg-mime default xdebug.desktop x-scheme-handler/xdebug. This should add an entry to ~.local/share/applications/mimeapps.list to [Default Applications] section. The entry itself should look like x-scheme-handler/xdebug=xdebug.desktop
For Firefox follow instructions from here: https://xdebug.org/docs/all_settings#file_link_format
Open about:config
Add a new boolean setting network.protocol-handler.expose.xdebug and set it to false
The first time you click on xdebug:/// link Firefox will prompt you to select an application to run, point to the created eclipse-launch.sh file.

tdbloader on Cygwin: Gettging FileNotFoundException: d:\cygdrive\d\....\node2id.idn

I am completely new to Jena/TDB. All I want to do is to load data from some sample rdf, N3 etc file using tdb scripts or through java api.
I am tried to use tbdloader on Cygwin to load data (tdb-0.9.0, on Windows XP with IBM Java 1.6). Following are the command that I ran:
$ export TDBROOT=/cygdrive/d/Project/Store_DB/jena-tdb-0.9.0-incubating
$ export PATH=$TDBROOT/bin:$PATH
I also changed classpath for java in the tdbloader script as mentioned at tdbloader on Cygwin: java.lang.NoClassDefFoundError :
exec java $JVM_ARGS $SOCKS -cp "PATH_OF_JAR_FILES" "tdb.$TDB_CMD" $TDB_SPEC "$#"
So when I run $ tdbloader --help it shows the help correctly.
But when I run
$ tdbloader --loc /cygdrive/d/Project/Store_DB/data1
OR
$ tdbloader --loc /cygdrive/d/Project/Store_DB/data1 test.rdf
I am getting following exception:
com.hp.hpl.jena.tdb.base.file.FileException: Failed to open: d:\cygdrive\d\Project\Store_DB\data1\node2id.idn (mode=rw)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.open$(ChannelManager.java:83)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.openref$(ChannelManager.java:58)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.acquire(ChannelManager.java:47)
at com.hp.hpl.jena.tdb.base.file.FileBase.<init>(FileBase.java:57)
at com.hp.hpl.jena.tdb.base.file.FileBase.<init>(FileBase.java:46)
at com.hp.hpl.jena.tdb.base.file.FileBase.create(FileBase.java:41)
at com.hp.hpl.jena.tdb.base.file.BlockAccessBase.<init>(BlockAccessBase.java:46)
at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.createStdFile(BlockMgrFactory.java:98)
at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.createFile(BlockMgrFactory.java:82)
at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.create(BlockMgrFactory.java:58)
at com.hp.hpl.jena.tdb.setup.Builder$BlockMgrBuilderStd.buildBlockMgr(Builder.java:196)
at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.createBPTree(Builder.java:165)
at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.buildRangeIndex(Builder.java:134)
at com.hp.hpl.jena.tdb.setup.Builder$IndexBuilderStd.buildIndex(Builder.java:112)
at com.hp.hpl.jena.tdb.setup.Builder$NodeTableBuilderStd.buildNodeTable(Builder.java:85)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd$NodeTableBuilderRecorder.buildNodeTable(DatasetBuilderStd.java:389)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeNodeTable(DatasetBuilderStd.java:300)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd._build(DatasetBuilderStd.java:167)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:157)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:70)
at com.hp.hpl.jena.tdb.StoreConnection.make(StoreConnection.java:132)
at com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction.<init>(DatasetGraphTransaction.java:46)
at com.hp.hpl.jena.tdb.sys.TDBMakerTxn._create(TDBMakerTxn.java:50)
at com.hp.hpl.jena.tdb.sys.TDBMakerTxn.createDatasetGraph(TDBMakerTxn.java:38)
at com.hp.hpl.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.java:166)
at com.hp.hpl.jena.tdb.TDBFactory.createDatasetGraph(TDBFactory.java:74)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:53)
at tdb.cmdline.ModTDBDataset.createDataset(ModTDBDataset.java:95)
at arq.cmdline.ModDataset.getDataset(ModDataset.java:34)
at tdb.cmdline.CmdTDB.getDataset(CmdTDB.java:137)
at tdb.cmdline.CmdTDB.getDatasetGraph(CmdTDB.java:126)
at tdb.cmdline.CmdTDB.getDatasetGraphTDB(CmdTDB.java:131)
at tdb.tdbloader.loadQuads(tdbloader.java:163)
at tdb.tdbloader.exec(tdbloader.java:122)
at arq.cmdline.CmdMain.mainMethod(CmdMain.java:97)
at arq.cmdline.CmdMain.mainRun(CmdMain.java:59)
at arq.cmdline.CmdMain.mainRun(CmdMain.java:46)
at tdb.tdbloader.main(tdbloader.java:53)
Caused by: java.io.FileNotFoundException: d:\cygdrive\d\Project\Store_DB\data1\node2id.idn (The system cannot find the path specified.)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:222)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:107)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.open$(ChannelManager.java:80)
... 37 more
I am not sure what node2id.idn file is and why is it expecting it?
The file node2id.idn is one of TDB's internal index files. It's not something that you have to create or manage for yourself. I've just tried tdbloader on cygwin myself, it it worked OK for me. I can think of two basic possibilities:
your disk is full
the TDB index is corrupted
If this is the first file you are loading into an otherwise emtpy TDB, the second possibility is unlikely. If you are loading into a non-empty TDB, try deleting the TDB image and starting again. Note that TDB by itself does not manage concurrent writes: if you have more than one process writing to a single TDB image, you must handle locking at the application level, or use TDB's transactions.
The final possibility, of course, is that your disk is flaky. You might want to try your code on another machine.
If none of these suggestions help, please send a complete minimal test case to the Jena users list.

Categories

Resources