Issue met when using Tess4j - tess4j

I am trying to create the TessBaseAPI using TessBaseAPICreate() and met the error as below:
java.lang.UnsatisfiedLinkError: Error looking up function 'TessPDFRendererCreateTextonly': dlsym(0x7fc93f349590, TessPDFRendererCreateTextonly): symbol not found
at com.sun.jna.Function.<init>(Function.java:212)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:541)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:518)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:504)
at com.sun.jna.Native.register(Native.java:1655)
at com.sun.jna.Native.register(Native.java:1529)
at com.sun.jna.Native.register(Native.java:1252)
at net.sourceforge.tess4j.TessAPI1.<clinit>(TessAPI1.java:41)
at com.mail.service.Tess4jServiceImpl.<init>(Tess4jServiceImpl.java:23)
My code is as below
public class Tess4jServiceImpl {
private String imageFilePath;
private TessAPI1.TessBaseAPI tessBaseAPI;
private static String tessDataPath = "***/tessdata/";
public Tess4jServiceImpl(String imageFilePath){
this.imageFilePath = imageFilePath;
tessBaseAPI = TessAPI1.TessBaseAPICreate();
}
I have excluded com.sun.jna in the dependency of net.sourceforge.tess4j and added new jna dependency as
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.2.1</version>
</dependency>
Is there anything special i have to notice for this issue?
Thanks.

I had the same problem with tesseract version 4.0 (compiled from source) and tess4j version 3.4.0 on Ubuntu 16.4 LTS. As I couldn't find any solution, I have uninstalled tesseract version 4 and installed the version 3.04 from the Ubuntu repositories. I changed the tess4j version in my pom.xml to 3.0.0 and the problem was solved.
I guess, tess4j with version 3.4.0 is not compatible with tesserct version 4, which is, after all, still in alpha.
I hope this helps.

Related

Jfxtras ScalableContentPane error - the unnamed module reads package jfxtras.labs.util.event from both jfxtras.labs and vworkflows.fx

I trying to run tutorial code from VWorkflow (I've just copied code and only package changed). Before this code it works. I have requires and dependencies in code to this library. Everythings seems to be OK but only ScalableContentPane is not working and because this my code doesn't run. I add jfxtras dependences in pom.xml
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r6</version>
</dependency>
And also I add requires to module-info.java
requires jfxtras.labs;
And my importing code.
import jfxtras.labs.scene.layout.ScalableContentPane;
But when I trying to run this app build output gives me that error
java: the unnamed module reads package jfxtras.labs.util.event from both jfxtras.labs and vworkflows.fx
as main error. And another error in module-info errors
java: module com.example.learningfx reads package jfxtras.labs.util.event from both jfxtras.labs and vworkflows.fx
There is all errors
I'm using IntelliJ and use JavaFX to build.
If you need VWorkflow github.
What do I need to do?
First of all you're using JFXtras labs, which is experimental and unsupported code, so if it does not work anymore, then that's it. It's called labs for a reason :-)
But apparently you are using a version of Java with JPMS, 9+, then you should also use JFXtras 9 or 11. You are currently using JFXtras 8.

[A]Newtonsoft.Json.Linq.JObject cannot be cast to [B]Newtonsoft.Json.Linq.JObject. Type A originates from 'Newtonsoft.Json, Version=9.0.0.0

I am using Microsoft.Azure.Devices for get iot devices from cloud. Using below code I'm getting error
newton.json
var device = await query.GetNextAsTwinAsync();
foreach (Twin twin in device)
{}
Using azure function v2.0 same code was working (no error).
Using azure function v1.0 same code I got error.
Microsoft.NET.Sdk.Functions package still has the dependency on the older version of the package. If you create a Function Project you cannot use any other Nuget Packages that have a dependency on Newtonsoft.Json version which is higher than the function runtime dependent version.
I have faced this earlier and made a small blog here about most of the issues

Error NU1202 Package Microsoft.Data.Sqlite.Core 2.0.0 is not compatible with uap10.0.14393 (UAP,Version=v10.0.14393) / win10-x64.

I've downloaded a working UWP solution targeting 16299 which I changed to target 14393 (Anniversary) so it would work on all Windows 10 Phones as well. Apart from the obvious errors where the solution uses newer W10 version methods and namespaces, I also get:
Error NU1202 Package Microsoft.Data.Sqlite.Core 2.0.0 is not compatible with uap10.0.14393 (UAP,Version=v10.0.14393) / win10-x64. (multiple times)
But according to https://blogs.windows.com/buildingapps/2017/02/06/using-sqlite-databases-uwp-apps/ Microsoft SQLite should work from 14393.
I've tried installing the oldest version number available (2.0.0 instaed of 2.1.0 now included) but that doesn't change the error.
How can I solve this problem?
Dick
sqlite.core is the core version and will work only from fall creators update and above. if you want to use sqlite on older versions then you can see details here : https://learn.microsoft.com/en-us/windows/uwp/data-access/sqlite-databases

How can I fix this? JavaFX - Wrong JPEG library version: library is 80, caller expects 70

I get this error whenever I try to create an Image in JavaFX. Absolutely no images are loading, but everything else on the UI is. The only time I see this is when prism.verbose=true
Other answers to similiar questions here on StackOverflow suggest reinstalling libjpeg. But when I do sudo apt-get remove libjpeg8, it tries to remove 4 GB worth of packages that seem pretty dang important.
Has anyone else experienced this and found a feasible solution that isn't going to require me to reinstall my entire OS?
Here is the entire stacktrace:
java.io.IOException: Wrong JPEG library version: library is 80, caller expects 70
at com.sun.javafx.iio.jpeg.JPEGImageLoader.initDecompressor(Native Method)
at com.sun.javafx.iio.jpeg.JPEGImageLoader.<init>(JPEGImageLoader.java:187)
at com.sun.javafx.iio.jpeg.JPEGImageLoaderFactory.createImageLoader(JPEGImageLoaderFactory.java:49)
at com.sun.javafx.iio.ImageStorage.getLoaderBySignature(ImageStorage.java:419)
at com.sun.javafx.iio.ImageStorage.loadAll(ImageStorage.java:266)
at com.sun.javafx.tk.quantum.PrismImageLoader2.loadAll(PrismImageLoader2.java:142)
at com.sun.javafx.tk.quantum.PrismImageLoader2.<init>(PrismImageLoader2.java:77)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.processStream(PrismImageLoader2.java:252)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.processStream(PrismImageLoader2.java:225)
at com.sun.javafx.runtime.async.AbstractRemoteResource.call(AbstractRemoteResource.java:109)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.access$201(PrismImageLoader2.java:225)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.lambda$call$428(PrismImageLoader2.java:259)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.call(PrismImageLoader2.java:258)
at com.sun.javafx.tk.quantum.PrismImageLoader2$AsyncImageLoader.call(PrismImageLoader2.java:225)
at com.sun.javafx.runtime.async.AbstractAsyncOperation.lambda$new$272(AbstractAsyncOperation.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
And this is my version info for java. I'm using the Oracle version.
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
EDIT:
I ran strace on my app and it looks like something is searching specifically for libjpeg 8 only. It's not ever trying to look for any default libjpeg library or libjpeg 7 at all.
A possible workaround is to not let JPEGImageLoader decode the jpegs but rather do it with ImageIO instead. You lose some of the built-in features of the javafx Image only available via constructor parameters such as smooth, preserveRatio, backgroundLoading but at least it is safer on linux.
Something like this might work for you:
import java.awt.image.BufferedImage;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
public static Image createImage(File file) throws IOException {
BufferedImage bufferedImage = ImageIO.read(file);
WritableImage writableImage = SwingFXUtils.toFXImage(bufferedImage, null);
if (writableImage.isError()) {
throw new RuntimeException(writableImage.getException());
}
return writableImage;
}
I think that Java is linked against libjpeg7, but you might have libjpeg8 in your LD_LIBRARY_PATH, so the interface does not match.
libjpeg.so comes with Java (in the lib/amd64 folder for x64 systems), but this is not beeing used probably due to an override in your LD_LIBRARY_PATH.

Plone ZMySQLDA, Couldn't install MySQL-python 1.2.4c1 with buildout

I want to use mysql form ploneformgen, but I
Can't buildout plone.
buildout log http://pastie.org/5345272.js
Getting required 'MySQL-python>=1.2.1'
required by Products.ZMySQLDA 3.1.1.
We have no distributions for MySQL-python that satisfies 'MySQL-python>=1.2.1'.
Getting distribution for 'MySQL-python>=1.2.1'.
Running easy_install:
/usr/local/Plone/Python-2.6/bin/python "-c" "from setuptools.command.easy_install import main; main()" "-mUNxd" "/usr/local/Plone/zeocluster/../buildout-cache/eggs/tmpDSODu0" "-Z" "/usr/local/Plone/buildout-cache/downloads/dist/MySQL-python-1.2.4c1.zip"
path=/usr/local/Plone/buildout-cache/eggs/distribute-0.6.21-py2.6.egg
Processing MySQL-python-1.2.4c1.zip
Running MySQL-python-1.2.4c1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-gFbWLf/MySQL-python-1.2.4c1/egg-dist-tmp-16g1TE
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.19 (/usr/local/Plone/Python-2.6/lib/python2.6/site-packages/distribute-0.6.19-py2.6.egg))
error: Setup script exited with 2
An error occured when trying to install MySQL-python 1.2.4c1. Look above this message for any errors that were output by easy_install.
While:
Installing client1.
Getting distribution for 'MySQL-python>=1.2.1'.
Error: Couldn't install: MySQL-python 1.2.4c1
*************** PICKED VERSIONS ****************
[versions]
Products.PloneFormGen = 1.7.1
Products.ZMySQLDA = 3.1.1
collective.classifieds = 1.6
plone.app.ldap = 1.2.8
quintagroup.dropdownmenu = 1.2.5
quintagroup.pfg.captcha = 1.0.5
zettwerk.ui = 1.1.1
buildout conf http://pastie.org/5345300
some links:
http://blog.mysqlboy.com/2010/08/installing-mysqldb-python-module.html
http://plone.293351.n2.nabble.com/Plone-amp-MySQL-No-quot-Z-MYSQL-Database-Connection-quot-from-ZMI-td5487160.html
It appears the MySQLdb egg requires a newer version of distribute:
The required version of distribute (>=0.6.28) is not available,
and
(Currently using distribute 0.6.19 (/usr/local/Plone/Python-2.6/lib/python2.6/site-packages/distribute-0.6.19-py2.6.egg))
Upgrade your distribute egg first; if you are using the unified installer, for example, versions.cfg pins the version. If so, edit versions.cfg to correct the version number there:
[versions]
...
# Buildout infrastructure
...
distribute = 0.6.28
While you have a perfectly good answer for the specific problem, I highly recommend forgetting about ZMySQLDA and use SQLAlchemyDA which gives you access to any database supported by SQLAlchemy (I've used all of MySQL, PostGreSQL, Oracle, SQLServer) with a single product, and is better supported.

Resources