I am trying to connect a java program to a database. I have sajdbc4.jar in the build path and it worked before, but now I keep getting this error when I try to make the connection:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no dbjdbc12 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at sybase.jdbc4.sqlanywhere.IDriver.try_load(IDriver.java:455)
at sybase.jdbc4.sqlanywhere.IDriver.(IDriver.java:396)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
at java.sql.DriverManager$2.run(Unknown Source)
at java.sql.DriverManager$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.sql.DriverManager.loadInitialDrivers(Unknown Source)
at java.sql.DriverManager.(Unknown Source)
at Main.main(Main.java:26)
Can someome please help me? Can't find anything abount this issue online.
For windows find this file in your computer:
dbjdbc12.dll
For linux find this file:
libdbjdbc12.so
Put the location of this file on the java.library.path either with a command line option:
java -Djava.library.path=DIRECTORYWITHDLL ...
or using System.setProperty in your code:
System.setProperty("java.library.path","DIRECTORYWITHDLL");
For Linux, you need to add the dbjdbc12.so to java.library.path using:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/some/path/that/contain/dbjdbc12.so
this is the same for dbjdbc16 also.
Since, sybase.jdbc4 driver need this file. Please refer- https://blogs.sap.com/2014/05/02/connecting-to-sql-anywhere-using-jdbc-2/#:~:text=jar%20is%20in%20the%20classpath,Connection%20con%20%3D%20DriverManager.
Similarly, for windows add dbjdbc12.dll file.
For SQL Anywhere 17 libdbjdbc17.so was not suffiecient, it was then complaning about the next file:
failed: java.lang.UnsatisfiedLinkError: /usr/local/tomcat/native-jni-lib/libdbjdbc17.so: libdbtasks17_r.so: cannot open shared object file: No such file or directory
So I ended up adding all files from the lib64 folder from the Database client (after I installed it on some other linux machine) to my tomcat lib path and it worked.
Related
We have a JavaWebStart application, which allows to scan images and write them to a file. All works fine but today I've got an exception from a customer, which I cannot understand.
java.lang.UnsatisfiedLinkError: no jpeg in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter$1.run(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi.createWriterInstance(Unknown Source)
at javax.imageio.spi.ImageWriterSpi.createWriterInstance(Unknown Source)
at javax.imageio.ImageIO$ImageWriterIterator.next(Unknown Source)
at javax.imageio.ImageIO$ImageWriterIterator.next(Unknown Source)
at de.eurodata.commons.scan.domain.ScanUtils.writeImageToFile(ScanUtils.java:81)
This exception is occured on Win7 x86. I've searched for this exception using Google but found only some irrelevant (Linux, Oracle 9i) or unanswered posts.
My question is: can I prevent this problem? Probably another pure Java jpeg plugin for ImageIO (if exists and stable)?
I created a Java Applet which manipulates a JSP webpage's form fields. The JSP calls the Java Applet, of course.
This the error I'm getting in the Java Console, when I run my Java Applet on my JSP:
Ignored exception: java.security.PrivilegedActionException:
java.lang.reflect.InvocationTargetException
I am not calling InvocationTargetException or passing any exceptions in the code. Somehow, I managed to trace it, by painstaking trial-and-error, that the line causing the error is:
BlowfishCBC bfcbc = new BlowfishCBC(testkey, 0, testkey.length, CBCIV_START);
As a test, I disabled all code that has dependencies on the JSP, so I can just run it inside Eclipse. I created a main method to execute the Java Applet and then ran it inside Eclipse. I got no errors or warnings, at all.
I exported the same Java Applet, as a JAR, copied it to the server, restarted Apache Tomcat, went to the page on my web browser, ran the applet, and the same InvocationTargetException error occurred
What could be the problem?
Note: I am not using try..catch anywhere in my code. What can I put in the code that will capture this exception information and how do I do that?
Thank you.
Update:
Here is the stacktrace from the Java Console:
java.net.MalformedURLException: no protocol:
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation.checkLiveConnectCaller(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation.access$000(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.liveconnect.SecureInvocation.CallMethod(Unknown Source)
java.net.MalformedURLException: no protocol:
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation.checkLiveConnectCaller(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation.access$000(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.liveconnect.SecureInvocation.CallMethod(Unknown Source)
java.net.MalformedURLException: no protocol:
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation.checkLiveConnectCaller(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation.access$000(Unknown Source)
at sun.plugin.liveconnect.SecureInvocation$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.liveconnect.SecureInvocation.CallMethod(Unknown Source)
in encrypt method
trying to get pwd value from document
got pwd from document, password is 12345
is this getting here?
Ignored exception: java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException
I think that's the stacktrace. I hope that information is sufficient and helpful.
I found the problem. It had nothing to do with the code, persay. It was the manifest file.
Here was the manifest file, as it was originally created by Eclipse:
Manifest-Version: 1.0
Here it is after I modified it:
Manifest-Version: 1.0
Class-Path: blowfishj.jar
I didn't realize that the Java Control Panel is supposed to show the blowfishj.jar file in its Resources. I see my Java Applet, there, but the blowfishj.jar file was not there, until I made the change to this manifest file. I didn't realize it needed the manifest file.
I don't understand why it needs this in the manifest file and why this modification fixes it, though. Maybe someone can answer that question.
Thank you.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: com.melloware.jintellitype.JIntellitypeException: Could not load JIntellitype.dll from local file system or from inside JAR
at com.melloware.jintellitype.JIntellitype.<init>(JIntellitype.java:114)
at com.melloware.jintellitype.JIntellitype.getInstance(JIntellitype.java:174)
at CaptureScreen.registerHotkeys(CaptureScreen.java:163)
at CaptureScreen.<init>(CaptureScreen.java:100)
at CaptureScreen.main(CaptureScreen.java:199)
... 5 more
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\B\AppData\Local\Temp: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.melloware.jintellitype.JIntellitype.<init>(JIntellitype.java:99)
... 9 more
I get this error when I run from the command line, however, it does not cause any issues with my program running on my machine, however, on other peoples machines the program will not run at all.
I have never come across this error before and fairly confused.. mostly that it runs fine on my machine, but not on others even though it throws this error on both.
This is a classpath error. Its likely that you have it set up right for compile time but not runtime. Make sure that either your jar is in the right location and/or that you've set your classpath to include the jar.
Go to the Jintellitype website, download the source, add it to your download folder and then move the .dll files into the folder with the Jitellitype classes after building the project
I have a class names test.java and another file "log4j.properties" in the same folder but following call
getClass().getResource("log4j.properties")
fails with
ms
Trace:
sun.misc.InvalidJarIndexException: Invalid index
at sun.misc.URLClassPath$JarLoader.getResource(Unknown Source)
at sun.misc.URLClassPath$JarLoader.getResource(Unknown Source)
at sun.misc.URLClassPath$JarLoader.findResource(Unknown Source)
at sun.misc.URLClassPath.findResource(Unknown Source)
at java.net.URLClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findResource(Unknown Source)
at java.lang.ClassLoader.getResource(Unknown Source)
at java.lang.ClassLoader.getResource(Unknown Source)
at java.lang.Class.getResource(Unknown Source)
But getClass().getClassLoader().getResource("log4j.properties") works. What can be the reason?
The InvalidJarIndexException is normally caused by a corrupt INDEX.LIST file in the JAR. So check the JAR for any problems. See http://littletechsecrets.wordpress.com/2008/12/01/why-does-invalidjarindexexception-occur/
The different results you describe are probably related to Class.getResource() resolving a path relative to the classes package, and ClassLoader.getResource() resolving a path relative to the root. So getClass().getResource("/log4j.properties") might fix your problem.
I have the .java, .class, .cpp, .h files: http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html
After reading TotalFrickinRockstarFromMars's comment, I tried setting up classpath.
What's wrong?
Sample1.dll IS there.
Text version:
F:\workspace\JavaJNIProj\src>java Sample1
Exception in thread "main" java.lang.UnsatisfiedLinkError: F:\workspace\JavaJNIProj\src\Sample1.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at Sample1.main(Sample1.java:10)
It looks like you miss some dependency DLLs. You can download DependencyWalker http://www.dependencywalker.com/
This supposed to help you to find it.