Exception NoClassDefFoundError: org/slf4j/LoggerFactory

bzark5 years ago

When I build and run traccar 4.5 it doesn't start and I see the syslog file entries below. I am using MVN to do the build. Any idea on this? This is from a git clone of the 4.5 branch. I doing this on Ubuntu 18.04

May 23 09:33:29 ip-172-31-18-204 traccar[1834]: Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
May 23 09:33:29 ip-172-31-18-204 traccar[1834]: #011at org.traccar.Main.<clinit>(Main.java:35)
May 23 09:33:29 ip-172-31-18-204 traccar[1834]: Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
May 23 09:33:29 ip-172-31-18-204 traccar[1834]: #011at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
May 23 09:33:29 ip-172-31-18-204 traccar[1834]: #011at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
May 23 09:33:29 ip-172-31-18-204 traccar[1834]: #011at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
May 23 09:33:29 ip-172-31-18-204 traccar[1834]: #011... 1 more
May 23 09:33:29 ip-172-31-18-204 systemd[1]: traccar.service: Main process exited, code=exited, status=1/FAILURE
May 23 09:33:29 ip-172-31-18-204 systemd[1]: traccar.service: Failed with result 'exit-code'.

The syslog entries below are running traccar 4.5 downloaded from the traccar website. I included this just because of the multiple bindings message, not sure if it provides any value.

May 23 10:57:46 ip-172-31-18-204 systemd[1]: Started traccar.
May 23 10:57:47 ip-172-31-18-204 traccar[2771]: SLF4J: Class path contains multiple SLF4J bindings.
May 23 10:57:47 ip-172-31-18-204 traccar[2771]: SLF4J: Found binding in [jar:file:/opt/traccar/lib/slf4j-jdk14-1.7.26.jar!/org/slf4j/impl/StaticLoggerBinder.class]
May 23 10:57:47 ip-172-31-18-204 traccar[2771]: SLF4J: Found binding in [jar:file:/opt/traccar/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
May 23 10:57:47 ip-172-31-18-204 traccar[2771]: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
May 23 10:57:47 ip-172-31-18-204 traccar[2771]: SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
May 23 10:57:56 ip-172-31-18-204 traccar[2771]: WARNING: An illegal reflective access operation has occurred
May 23 10:57:56 ip-172-31-18-204 traccar[2771]: WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/opt/traccar/lib/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
May 23 10:57:56 ip-172-31-18-204 traccar[2771]: WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
May 23 10:57:56 ip-172-31-18-204 traccar[2771]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
May 23 10:57:56 ip-172-31-18-204 traccar[2771]: WARNING: All illegal access operations will be denied in a future release
bzark5 years ago

SOLUTION

I was using Maven build system, I switched to Gradle and it worked just fine.

Sumit5 years ago

Can you tell me how I can do in NetBeans? I am having this issue with 4.5 version. I am not familiar with Java.

bzark5 years ago

@Sumit I never used NetBeans so cannot provide any help.

Sumit5 years ago

So what are you using, @bzark? Can you help me to share some screenshots here how to remove this slf4j error if you are using Eclipse?

bzark5 years ago

Just use the Gradle script. gradlew on Linux.

Sumit5 years ago
bzark5 years ago

No need to, just execute the gradlew script in the current traccar directory.

Sumit5 years ago

@bzark, thank you. I try to reinstall the traccar and if there is any again problem in the traccar, I'll try to execute the gradle.

Sumit5 years ago

Thank @bzark. It helped me. I have installed the gradlew from this link: https://linuxize.com/post/how-to-install-gradle-on-ubuntu-18-04/

Sumit5 years ago

But how did you get this error, @bzark?

Sumit5 years ago

You told - Just use the Gradle script. gradlew on Linux.
How can I do this way because traccar does not contain gradlew on the remote server?

bzark5 years ago

The original error I got was using Maven build system. If you are trying to build from source code you have to download the traccar server source code from Github.

https://github.com/traccar/traccar

Sumit5 years ago

Thanks for the response. I know this gradle is in the traccar repository but I have a linux server on AWS and there there is no gradle (installing through this link https://www.traccar.org/install-digitalocean/ ). So before uploading jar file, either I need to run gradle on local server or install the gradle library on the remote AWS linux server.

Anton Tananaev5 years ago

You don't need to install anything. Read about gradle wrapper.