tess4j The specified module could not be found - tess4j

please need your help.. I testing Tess4j but i have a problem
Development environment : eclipse, jdk 1.7
Code
System.setProperty("jna.library.path", "32".equals(System.getProperty("sun.arch.data.model")) ? "/lib/win32-x86" : "/lib/win32-x86-64");
File imgFile = new File("d:\\testImg\\testimg2-1.png");
System.setProperty("jna.debug_load", "true");
Tesseract prc = new Tesseract();
prc.setDatapath("/tessdata");
try{
String rslt = prc.doOCR(imgFile);
}catch(Exception e){
e.printStackTrace();
}
Error
Looking in classpath from sun.misc.Launcher$AppClassLoader#73d16e93 for /com/sun/jna/win32-x86-64/jnidispatch.dll
Found library resource at jar:file:/D:/WorkSpace/sample/lib/jna-4.1.0.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll
Looking for library 'libtesseract304'
Adding paths from jna.library.path: /lib/win32-x86-64;C:\Users\PANDORA\AppData\Local\Temp\tess4j\win32-x86-64
Trying C:\Users\PANDORA\AppData\Local\Temp\tess4j\win32-x86-64\libtesseract304.dll
Adding system paths: []
Trying C:\Users\PANDORA\AppData\Local\Temp\tess4j\win32-x86-64\libtesseract304.dll
Looking for lib- prefix
Trying liblibtesseract304.dll
Looking in classpath from sun.misc.Launcher$AppClassLoader#73d16e93 for libtesseract304
Found library resource at jar:file:/D:/WorkSpace/sample/lib/tess4j-3.2.1.jar!/win32-x86-64/libtesseract304.dll
java.lang.UnsatisfiedLinkError: Can not find the specified moduleat com.sun.jna.Native.open(Native Method)at com.sun.jna.Native.open(Native.java:1759)at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)at com.sun.jna.Native.register(Native.java:1396)at com.sun.jna.Native.register(Native.java:1156

Related

File path issue in mac

nopCommerce version: 4.1
I am using nopCommerce version 4.1 on mac os with visual studio for mac, when I run this solution, I get error on creating path.
Plugin 'Must be assigned to customer role'. Could not load file or
assembly
'/Users/alireza/Desktop/NopCommerce/Presentation/Nop.Web/Plugins\bin/Nop.Plugin.DiscountRules.CustomerRoles.dll'.
The system cannot find the file specified.\n\nCould not load file or
assembly
'/Users/alireza/Desktop/NopCommerce/Presentation/Nop.Web/Plugins\bin/Nop.Plugin.DiscountRules.CustomerRoles.dll'.
The system cannot find the file specified.\n\n
I found the solution by myself:
path = Environment.OSVersion.Platform == PlatformID.Win32NT
? path.Replace("~/", string.Empty).TrimStart('/').Replace('/', '\\')
: path.Replace("~/", string.Empty).TrimStart('/');
in the file opCommerce_4.10_Source/Libraries/Nop.Core/Infrastructure/NopFileProvider.cs
replace the the following function
public virtual string MapPath(string path)
with the following code :
public virtual string MapPath(string path)
{
// path = path.Replace("~/", string.Empty).TrimStart('/').Replace('/', '\\');
path = Environment.OSVersion.Platform == PlatformID.Win32NT
? path.Replace("~/", string.Empty).TrimStart('/').Replace('/', '\\')
: path.Replace("~/", string.Empty).TrimStart('/');
return Path.Combine(BaseDirectory ?? string.Empty, path);
}

Extent reports - Exception in thread "main" java.lang.NoSuchFieldError: VERSION_2_3_23

While running the below code I found following exception. Please help me to resolve the issue. I tried with changing freemaker jar files too.
public class sample1 {
public static void main(String[] args) throws IOException {
ExtentHtmlReporter htmlReporter = new
ExtentHtmlReporter("extent.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(htmlReporter);
ExtentTest test = extent.createTest("MyFirstTest", "Sample description");
test.log(Status.INFO, "This step shows usage of log(status, details)");
test.info("This step shows usage of info(details)");
MediaEntityBuilder
.createScreenCaptureFromPath("screenshot.png")
.build());
test.addScreenCaptureFromPath("screenshot.png");
extent.flush();
}
}
Error details:
Exception in thread "main" java.lang.NoSuchFieldError: VERSION_2_3_23
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.start(ExtentHtmlReporter.java:93)
at com.aventstack.extentreports.Report.attach(Report.java:55)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at com.aventstack.extentreports.ExtentReports.attachReporter(ExtentReports.java:68)
at com.br.mainsript.sample1.main(sample1.java:23)
You need to download the current version 3 of the community edition. The version you have does not support the reporter attachments. Below is the maven depenency:
<!-- pom.xml -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
Thank you. Just i upgraded my eclipse version from Juno to latest oxygen and found that issue is rrsolved. Issue due to java complier version. When I upgraded to jre8 it is working fine.

Error Connect Database Sqlite in Mule Connector

I want to connect and select database Sqlite on Mule AnypointStudio. But it error. Please help me. Thanks all.
No suitable driver found for jdbc:sqlite
here my code:
#Processor (name="select" ,friendlyName ="select")
public void select() {
ArrayList<Story> list = new ArrayList<Story>();
String sql = "select * from chat";
try (Connection conn = this.connect();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql)){
// loop through the result set
while (rs.next()) {
Story s = new Story();
s.setStory(rs.getInt("id"), rs.getString("user_chat"),rs.getString("bot_chat"));
list.add(s);
}
} catch (SQLException | ClassNotFoundException e) {
System.out.println(e.getMessage());
}
for (int i =0 ; i < list.size(); i++){
System.out.print(list.get(i).GetID() +"| "+ list.get(i).GetUserChat() + "| "+ list.get(i).GetBotChat() +"\n" );
}
}
private Connection connect() throws ClassNotFoundException {
// SQLite connection string
Class.forName("org.sqlite.JDBC");
String url = "jdbc:sqlite:C:\\data.db";
Connection conn = null;
try {
conn = DriverManager.getConnection(url);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return conn;
}
}
Make sure You have valid jar/driver in your project classpath.
Open new Mule Project in Studio, and then follow these steps to add/create a datasource in mule flow:
a. Import the driver
b. Create a Datasource,
c. Create a Connector that uses our Datasource, and finally
d. Create a simple flow that uses our connector.
It seems you are missing driver jar in project classpath.
How to Import the Driver?
Once you have the jar file(you can download jar respective to sqllite from some repo ,eg- maven_repo), the next steps are very simple:
In the Package Explorer,
Right-click over the Project folder
Look in the menu for Build Path > Add External Archives…
Look for the jar file in your hard drive and click Open.
Now you should see in the package explorer that the jar file is present in “Referenced Libraries.”
This will allow you to create an insta
nce of the Object driver you will need.
It's probably a classpath issue. If you are using Maven with your project, simply add the dependency in your pom.xml (and right click on your project > Mule > Update project dependencies):
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.20.1</version>
<scope>test</scope>
</dependency>
Make sure you understand how Maven works and how to manipulate your pom.xml file. Maven getting started and POM Introduction might help.
If you are not using Maven, you need to manually import the dependency in your classpath. #Malesh_Loya answer should help.

can't find IfxBulkCopy in IBM.Data.Informix 2.81.0.0

Q:
My question consists of two parts:
1- I want to use the following class IfxBulkCopy to insert large amount of data but this class doesn't exist in the dll IBM.Data.Informix 2.81.0.0 how to fix this problem.?
Note : the class exist in the IBM.Data.Informix 9.0.0.2 !but i can't use this version because we use an old version of the informix.
When i use the new version i get the following exception :
Invalid argument
StackTrace = " at IBM.Data.Informix.IfxConnection.ReplaceConnectionStringParms(String szValue, IfxConnSettings& connSettings)\r\n at IBM.Data.Informix.IfxConnection.set_ConnectionString(String value)\r\n at Common.DBConnectionForInformix..ctor(String ConnectionStr...
My .cs:
public static void InsertAsBulk(DataTable dt)
{
using (IfxConnection cn = new IfxConnection(ConfigurationManager.ConnectionStrings["aa"].ToString()))
{
cn.Open();
using (IfxBulkCopy copy = new IfxBulkCopy(cn))
{
copy.ColumnMappings.Add(1, 2);
copy.ColumnMappings.Add(2, 3);
copy.ColumnMappings.Add(3, 4);
copy.ColumnMappings.Add(4, 5);
copy.ColumnMappings.Add(5, 6);
copy.ColumnMappings.Add(6, 7);
copy.DestinationTableName = "schday";
copy.WriteToServer(dt);
}
}
}
2- Is the IfxBulkCopy use the transaction concept during the insertion operation or may result inconsistent data also .
Your connection string is fine. Do you have multiple versions of driver installed? I had same problem when I installed OAT, Informix driver and Informix Client SDK on same machine.
This solved my problem:
1. Uninstallation of driver and client sdk + windows restart
2. Installation of Client SDK together with data server driver
3. Checking system PATH variable. I added
C:\Program Files\IBM Informix Client SDK\bin
C:\Program Files\IBM Informix Client SDK\bin\netf20
to system PATH. I'm not sure what was the problem, maybe just changing PATH variable (without unistallation) can fix it.

Flyway output to SQL File

Is it possible to output the db migration to an SQL file instead of directly invoking database changes in flyway?
Most times this will not be needed as with Flyway the DB migrations themselves will already be written in SQL.
Yes it's possible and as far as I am concerned the feature is an absolute must for DBAs who don't want to allow flyway in prod.
I made do with modifying code from here, it's a dry run command for flyway, you can add a filewriter and write out migrationDetails:
https://github.com/killbill/killbill/commit/996a3d5fd096525689dced825eac7a95a8a7817e
I did it like so... Project structure (just copied it out of killbill's project and renamed package to flywaydr:
.
./main
./main/java
./main/java/com
./main/java/com/flywaydr
./main/java/com/flywaydr/CapturingMetaDataTable.java
./main/java/com/flywaydr/CapturingSqlMigrationExecutor.java
./main/java/com/flywaydr/DbMigrateWithDryRun.java
./main/java/com/flywaydr/MigrationInfoCallback.java
./main/java/com/flywaydr/Migrator.java
./main/java/org
./main/java/org/flywaydb
./main/java/org/flywaydb/core
./main/java/org/flywaydb/core/FlywayWithDryRun.java
In Migrator.java add (implement callback and put it in DbMigrateWithDryRun.java) :
} else if ("dryRunMigrate".equals(operation)) {
MigrationInfoCallback mcb = new MigrationInfoCallback();
flyway.dryRunMigrate();
MigrationInfoImpl[] migrationDetails = mcb.getPendingMigrationDetails();
if(migrationDetails.length>0){
writeMasterScriptToFile(migrationDetails);
}
}
Then to write stuff to file something like:
private static void writeMasterScriptToFile(MigrationInfoImpl[] migrationDetails){
FileWriter fw = null;
try{
String masterScriptLoc="path/to/file";
fw = new FileWriter(masterScriptLoc);
LOG.info("Writing output to " + masterScriptLoc);
for (final MigrationInfoImpl migration : migrationDetails){
Path file =Paths.get(migration.getResolvedMigration().getPhysicalLocation());
//if you want to copy actual script files parsed by flyway
Files.copy(file, Paths.get(new StringBuilder(scriptspathloc).append(File.separator).append(file.getFileName().toString()).toString()), REPLACE_EXISTING);
}
//or just get the sql
for (final SqlStatement sqlStatement : sqlStatements) {
//sqlStatement.getSql();
}
fw.write(stuff.toString());
} catch(Exception e){
LOG.error("Could not write to file, io exception was thrown.",e);
} finally{
try{fw.close();}catch(Exception e){LOG.error("Could not close file writer.",e);}
}
}
One last thing to mention, I compile and package this into a jar "with dependencies" (aka fatjar) via maven (google assembly plugin + jar with dependencies) and run it via command like below or you can include it as a dependency and call it via mvn exec:exec goal, which is something I had success with as well.
$ java -jar /path/to/flywaydr-fatjar.jar dryRunMigrate -regular.flyway.configs -etc -etc
I didnt find a way. Switched to mybatis migration. Looks quite nice.

Resources