0

I have one app which I want to dockerize. But first, I need to run it via console(cmd or bash). When I run it from Eclipse everything is okay, but when I run it from bash(java -jar project-18.5.0-SNAPSHOT.jar) I get this error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at com.hp.spacecat.util.PropertyUtil.<clinit>(PropertyUtil.java:35)
        at com.hp.spacecat.SpaceCat.main(SpaceCat.java:76)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 2 more

I have that jar in m2 and he has this LogFactory class. Mvn clean install is success. But for some reason I can't run it via console. I don't know is there some way to get that classpath from Eclipse or there is another way to solve this. Similar questions about this logging exception didn't help me.

  • How are you building the jar? Are you using Maven? – Amongalen Feb 27 '20 at 10:37
  • you could export your project as executable jar in eclipse or build a jar including dependencies with maven assembly plugin – Turo Feb 27 '20 at 10:39
  • @Amongalen Yes I use maven, Clean install is success but I want to run that executable jar, I get that error for LogFactory. –  Feb 27 '20 at 10:42
  • @Amongalen java -jar project-18.5.0-SNAPSHOT.jar that is a command which I run –  Feb 27 '20 at 10:46
  • You can't easily access the Eclipse classpath outside of Eclipse. You need to use some other way to set up the classpath or build a jar containing the other jars. – greg-449 Feb 27 '20 at 11:27

0 Answers0