Classpath of my shell script failed to find a particular jar

Asked

Viewed 62 times

1

I have a shell script that executes the following instructions:

#!/bin/bash
java -Dcom.sun.management.jmxremote -classpath .:lib/* br.com.governa.admin.sincronizador.negocio.Sincronizador config/sincronizacao-espec-transparencia.xml

Time I run my script it is presenting the following error:

java.lang.Classnotfoundexception: com.microsoft.sqlserver.jdbc.Sqlserverdriver

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at br.com.governa.admin.sincronizador.persistencia.BancoConexao.<init>(BancoConexao.java:39)
at br.com.governa.admin.sincronizador.negocio.Sincronizador.run(Sincronizador.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

But the sqlserver jar is in the lib folder

inserir a descrição da imagem aqui

I’ve tried everything. Someone can give me a light there??

  • The path to the folder lib is relative. This folder is actually located as a current directory subdirectory when you run the script?

  • is yes @utluiz my script is a directory up on the lib... I am using a class(br.com.governa.admin.synchronizer.business.Synchronizer) of this jar (governa-admin-synchronizer-1.10-SNAPSHOT.jar) which is in the same lib folder

  • Even if you are running from another directory what counts is the current directory and not where the script is located. Have you tried switching to an absolute path?

  • I’ll try here... thanks

  • @utluiz moved the script to the lib folder and executed it from within continued with the error : java.lang.Classnotfoundexception: com.microsoft.sqlserver.jdbc.Sqlserverdriver

  • By class name, it should be contained in the file sqljdbc4-4.0.jar. Make sure the jar is not corrupted and the class really is in this jar. I also noticed that you have the JTDS driver, which is an alternative opensource to the official Microsoft. There is some reason to have both drivers in the classpath?

Show 1 more comment

1 answer

0

For some reason I specified in linux the line where I was with the information that uses this driver to access the database, had blank space due to I had format with the shortcut CTRL + SHIFT + F and in windows it ignores the space and works correctly, just took out the white space worked beauty!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.