Specified module could not being found loading DLL in JNA - java

I have this class initialiser:
System.setProperty("java.library.path", "C:\\Users\\lucas\\Desktop\\libraries");
System.loadLibrary("libTTARCHHelper");
TTARCH_LIBRARY=(TtarchLibrary)Native.loadLibrary(TtarchLibrary.class);
And the DLL is located at C:\\Users\\lucas\\Desktop\\libraries\\libTTARCHHelper.dll
If I run this in Eclipse I get 'The specified module could not be found' and if I run it as a JAR I get 'no libTTARCHHelper in java.library.path'.
How do I fix these? I even tried putting the DLL in a folder in the PATH environment variable.
Full debug using the file direct load:
Aug 26, 2020 12:28:51 AM com.sun.jna.Native extractFromResourcePath
INFO: Looking in classpath from jdk.internal.loader.ClassLoaders$AppClassLoader#c387f44 for /com/sun/jna/win32-x86-64/jnidispatch.dll
Aug 26, 2020 12:28:51 AM com.sun.jna.Native extractFromResourcePath
INFO: Found library resource at jar:file:/C:/Users/lucas/Desktop/My%20Stuff/Eclipse%20Workspaces/Build%20Paths/jna-5.6.0.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll
Aug 26, 2020 12:28:51 AM com.sun.jna.Native extractFromResourcePath
INFO: Extracting library to C:\Users\lucas\AppData\Local\Temp\jna-103324076\jna5931694657592960137.dll
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Looking for library 'C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll'
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Adding paths from jna.library.path: null
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Trying C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Loading failed with message: The specified module could not be found.
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Adding system paths: []
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Trying C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Loading failed with message: The specified module could not be found.
Aug 26, 2020 12:28:51 AM com.sun.jna.Native extractFromResourcePath
INFO: Looking in classpath from jdk.internal.loader.ClassLoaders$AppClassLoader#c387f44 for C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll
Aug 26, 2020 12:28:51 AM com.sun.jna.NativeLibrary loadLibrary
INFO: Loading failed with message: Native library (win32-x86-64/C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll) not found in resource path (C:\Users\lucas\eclipse-workspace\TEST\bin;C:\Users\lucas\Desktop\My Stuff\Eclipse Workspaces\Build Paths\jna-5.6.0.jar)
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll':
The specified module could not be found.
The specified module could not be found.
The rest of the trace:
Native library (win32-x86-64/C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll) not found in resource path (C:\Users\lucas\eclipse-workspace\TEST\bin;C:\Users\lucas\Desktop\My Stuff\Eclipse Workspaces\Build Paths\jna-5.6.0.jar)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:301)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:461)
at com.sun.jna.Library$Handler.<init>(Library.java:192)
at com.sun.jna.Native.loadLibrary(Native.java:646)
at com.sun.jna.Native.loadLibrary(Native.java:630)
at com.test.TTARCHHelper.<clinit>(TTARCHHelper.java:17)
at com.test.main.main(main.java:6)
Suppressed: java.lang.UnsatisfiedLinkError: The specified module could not be found.
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:191)
... 6 more
Suppressed: java.lang.UnsatisfiedLinkError: The specified module could not be found.
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:204)
... 6 more
Suppressed: java.io.IOException: Native library (win32-x86-64/C:\Users\lucas\Desktop\libraries\libTTARCHHelper.dll) not found in resource path (C:\Users\lucas\eclipse-workspace\TEST\bin;C:\Users\lucas\Desktop\My Stuff\Eclipse Workspaces\Build Paths\jna-5.6.0.jar)
at com.sun.jna.Native.extractFromResourcePath(Native.java:1095)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:275)
... 6 more
So it looks like it doesnt find it , It throws a
java.lang.UnsatisfiedLinkError: The specified module could not be found.
I found the problem, the DLLs were for the wrong bit. Eclipse runs on 64 and the JAR uses the 32bit JVM. I downloaded the 32 bit dlls too and now it works when I run the JAR. However the 64 bit dlls in Eclipse keep throwing the module exception above

JNA will look for libraries at locations in the jna.library.path environment variable.
One option is to specify it as a command line option in Eclipse's run configuration. In the Run menu, select Run Configuration. Go to the (x)=Arguments tab. Add this in the VM arguments field:
-Djna.library.path=C:\Users\lucas\Desktop\libraries
You can also programmatically set it in your code before attempting to load the DLL:
System.setProperty("jna.library.path", "C:\\Users\\lucas\\Desktop\\libraries");
As you later indicated with the debug log, it may be finding the DLL but failing to open it. Possible reasons for this can be:
The DLL is runtime-dependent on another DLL on your system that's not in the appropriate path(s). A common one is the Visual C++ Distributable.
You may need to consult the DLL documentation for more information. You can sometimes use Process Monitor from the SysInternals library to try to see what it's opening.
Having a duplicate/incompatible version of a dependent DLL as above
Running a 64-bit JVM and trying to open a DLL that's not 64-bit compatible, or vice-versa
Your Java program may not have permission to read the directory where your library is located
To help diagnose the problem, look at the full stack trace. While the most recent error message may not be relevant (file not found in a "backup" search) if you look down the trace you may see multiple suppressed exceptions from earlier attempts to open a DLL which may give you more informative debugging information.

Related

How to solve GRAVE: Unable to process Jar entry

On every server startup I get the following error:
GRAVE: Unable to process Jar entry
Mai 15, 2017 10:39:31 AM org.apache.catalina.startup.ContextConfig processAnnotationsJar
GRAVE: Unable to process Jar entry [fr/package/model/someClass.class] from Jar [jar:file:/C:/Folder-dev/work/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web/WEB-INF/lib/package-model-0.0.1-SNAPSHOT.jar!/] for annotations
java.io.EOFException
This was a well known error that was caused by some incompatibility issues between TOMCAT 7 & JDK <= 6.
In my case I'm working with this configurations:
Server number: 8.0.9.0
Server version: Apache Tomcat/8.0.9
Architecture: amd64
JVM Version: 1.8.0_131-b11
Can anyone help me to solve this issue ?
I upgraded to tomcat 8.5 and everything works fine.

Google Drive api Java QuickStart EOFException

I am following google drive v3 api quickstart
tutorial
I don't want to use gradle for this application since is a group project.
I have downloaded the google drive v3 libraries.
I am using Intellij, and I have added all of the jar to the class path. All jars are imported successfully and the IDE doesn't give any error.
At run time I get a warning which from reading online seems to be a problem with Windows Compatibility.
I have downloaded the .json file with user ID and user secret and placed it in the same folder as the main
My code is the same as the one of the quickstart example:
The error i get is the following:
Apr 06, 2017 2:31:52 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\HP\.credentials\drive-java-quickstart
Apr 06, 2017 2:31:52 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\HP\.credentials\drive-java-quickstart
Exception in thread "main" java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2624)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3099)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
at com.google.api.client.util.IOUtils.deserialize(IOUtils.java:171)
at com.google.api.client.util.store.FileDataStoreFactory$FileDataStore.<init>(FileDataStoreFactory.java:102)
at com.google.api.client.util.store.FileDataStoreFactory.createDataStore(FileDataStoreFactory.java:73)
at com.google.api.client.util.store.AbstractDataStoreFactory.getDataStore(AbstractDataStoreFactory.java:55)
at com.google.api.client.auth.oauth2.StoredCredential.getDefaultDataStore(StoredCredential.java:171)
at com.google.api.client.auth.oauth2.AuthorizationCodeFlow$Builder.setDataStoreFactory(AuthorizationCodeFlow.java:736)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.setDataStoreFactory(GoogleAuthorizationCodeFlow.java:209)
at com.elox.Main.authorize(Main.java:77)
at com.elox.Main.getDriveService(Main.java:93)
at com.elox.Main.main(Main.java:103)
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:147)
I don't Understand why I get this error or how I could correct it
I know that this is an old post, but I had almost the exact same stacktrace and couldn't find an answer. So, I'm posting in hopes that it will help those that come after me.
The issue appears to be related to file/directory permissions. As soon as I changed the filepath being used by the FileDataStoreFactory to a directory that my application had read/write permissions to, OAuth2 worked correctly. So, make sure that you are using a non-restricted filepath and that all of the directories have the correct ownership and permissions.

Neo4j Server Startup Exception

Iam unable to start the neo4j server..iam using java 1.7 and neo4j 2.0.0 when i run the sample java with maven example, iam getting this problem. Here is the log file
Oct 09, 2013 8:49:14 AM org.neo4j.server.logging.Logger log
INFO: Setting startup timeout to: 120000ms based on -1
Oct 09, 2013 8:49:15 AM org.neo4j.server.logging.Logger log
SEVERE:
org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.XaDataSourceManager#ce8273' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:211)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:86)
at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:49)
Caused by: java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.XaDataSourceManager#ce8273' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:280)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207)
at org.neo4j.kernel.impl.recovery.StoreRecoverer.recover(StoreRecoverer.java:114)
at org.neo4j.server.preflight.PerformRecoveryIfNecessary.run(PerformRecoveryIfNecessary.java:59)
at org.neo4j.server.preflight.PreFlightTasks.run(PreFlightTasks.java:70)
at org.neo4j.server.AbstractNeoServer.runPreflightTasks(AbstractNeoServer.java:276)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:162)
... 2 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.XaDataSourceManager#ce8273' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258)
... 10 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource#1f5329f' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
at org.neo4j.kernel.impl.transaction.XaDataSourceManager.start(XaDataSourceManager.java:128)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
... 12 more
Caused by: org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException: Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true"
at org.neo4j.kernel.impl.storemigration.ConfigMapUpgradeConfiguration.checkConfigurationAllowsAutomaticUpgrade(ConfigMapUpgradeConfiguration.java:39)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.attemptUpgrade(StoreUpgrader.java:66)
at org.neo4j.kernel.impl.nioneo.store.StoreFactory.tryToUpgradeStores(StoreFactory.java:113)
at org.neo4j.kernel.impl.nioneo.store.StoreFactory.newNeoStore(StoreFactory.java:96)
at org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.start(NeoStoreXaDataSource.java:240)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
... 15 more
Oct 09, 2013 8:49:15 AM org.neo4j.server.logging.Logger log
SEVERE: Failed to start Neo Server on port [7474]
How to clear this?
According to the documentation,
set the Neo4j configuration parameter "allow_store_upgrade=true" in your neo4j.properties or embedded configuration
Hope that helps.
In general with Neo4j, a database can be upgraded from a minor version to the next, e.g. 1.7 → 1.8, and 1.8 → 1.9, but you can not jump directly from 1.7 → 2.0.
You have two options:
upgrade to each minor version in succession setting the Neo4j configuration parameter "allow_store_upgrade=true" as in #Vidya's answer, or
re-import your data into the new 2.0 version of Neo4j.

Need help in error in Neo4j

I am getting this error while clicking on the neo4j.bat file in Windows. I tried other answers on stackoverflow but none of them is working. I set all variables in path JAVA_HOME & JRE_HOME. It says database incorrectly shutdown, performing recovery. And then console goes off. I have installed jdk 1.7 & jre7.
Sep 15, 2013 11:52:57 PM org.neo4j.server.logging.Logger log
INFO: Setting startup timeout to: 120000ms based on -1
Sep 15, 2013 11:52:58 PM org.neo4j.server.logging.Logger log
SEVERE:
java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter#3e890800' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:280)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207)
at org.neo4j.kernel.impl.recovery.StoreRecoverer.recover(StoreRecoverer.java:114)
at org.neo4j.server.preflight.PerformRecoveryIfNecessary.run(PerformRecoveryIfNecessary.java:59)
at org.neo4j.server.preflight.PreFlightTasks.run(PreFlightTasks.java:70)
at org.neo4j.server.AbstractNeoServer.runPreflightTasks(AbstractNeoServer.java:280)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:160)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:86)
at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:49)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter#3e890800' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258)
... 10 more
Caused by: org.neo4j.kernel.StoreLockException: Could not create lock file
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
... 12 more
Sep 15, 2013 11:52:58 PM org.neo4j.server.logging.Logger log
SEVERE: Failed to start Neo Server on port [7474]
Most likely, you have an instance already running. Kill any Java processes and try again.

jooq startup: command line to generate classes

could you help me to change this command line to use it in a MacOS? the jar files will be on the desktop.
java -classpath jooq-2.0.0.jar;jooq-meta-2.0.0.jar;jooq-codegen-2.0.0.jar;mysql-connector-java-5.1.18-bin.jar;. org.jooq.util.GenerationTool /guestbook.xml
Thank you.
F.
UPDATE:
ok, this is the full lines and the error that I got. All the listed jars are present in the folder:
java -classpath ~/Desktop/JOOQ/jooq-2.1.0.jar:~/Desktop/JOOQ/jooq-
meta-2.1.0.jar:~/Desktop/JOOQ/jooq-codegen-2.1.0.jar:~/Desktop/JOOQ/
mysql-connector-java-5.1.15-bin.jar:. org.jooq.util.GenerationTool /bookstore.xml
Exception in thread "main" java.lang.NoClassDefFoundError: org/jooq/
util/GenerationTool
Caused by: java.lang.ClassNotFoundException:
org.jooq.util.GenerationTool
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
UPDATE 2
If I change the path removing ~/ and usign:
java -classpath /Users/fabio/Desktop/JOOQ/jooq-2.1.0.jar:/Users/fabio/Desktop/JOOQ/jooq-meta-2.1.0.jar:/Users/fabio/Desktop/JOOQ/jooq-codegen-2.1.0.jar:/Users/fabio/Desktop/JOOQ/mysql-connector-java-5.1.15-bin.jar org.jooq.util.GenerationTool /Users/fabio/Desktop/JOOQ/bookstore.xml
I got a different error:
Apr 1, 2012 5:19:52 PM org.jooq.tools.JooqLogger error
SEVERE: Cannot find /Users/fabio/Desktop/JOOQ/bookstore.xml
Apr 1, 2012 5:19:52 PM org.jooq.tools.JooqLogger error
SEVERE: -----------
Apr 1, 2012 5:19:52 PM org.jooq.tools.JooqLogger error
SEVERE: Please be sure it is located on the classpath and qualified as a classpath location.
Apr 1, 2012 5:19:52 PM org.jooq.tools.JooqLogger error
SEVERE: If it is located at the current working directory, try adding a '/' to the path
Apr 1, 2012 5:19:52 PM org.jooq.tools.JooqLogger error
SEVERE: Usage : GenerationTool
You can prepend the full path to each jar file (e.g. ~/Desktop/), and you also need to replace the windows classpath separator (semicolon, ';'), with the UNIX/MAC separator (colon, ':'). For example:
java -classpath ~/Desktop/jooq-2.0.0.jar:~/Desktop/jooq-meta-2.0.0.jar:~/Desktop/jooq-codegen-2.0.0.jar:~/Desktop/mysql-connector-java-5.1.18-bin.jar:. org.jooq.util.GenerationTool /guestbook.xml
Ok found. Commands to use:
cd /Users/fabio/Desktop/JOOQ
java -classpath /Users/fabio/Desktop/JOOQ/jooq-2.1.0.jar:/Users/fabio/Desktop/JOOQ/jooq-meta-2.1.0.jar:/Users/fabio/Desktop/JOOQ/jooq-codegen-2.1.0.jar:/Users/fabio/Desktop/JOOQ/mysql-connector-java-5.1.15-bin.jar:. org.jooq.util.GenerationTool /bookstore.xml
The ':.' after the last jar file is required.
Thank you.

Categories

Resources