0

I have a program running successfully in ECLIPSE. But when generate the .jar file and try to run it generates an error.

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/batch/core/JobExecutionException 
            at java.lang.Class.getDeclaredMethods0(Native Method)
            at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
            at java.lang.Class.privateGetMethodRecursive(Unknown Source)
            at java.lang.Class.getMethod0(Unknown Source)
            at java.lang.Class.getMethod(Unknown Source)
            at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
            at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: org.springframework.batch.core.JobExecutionException
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            ... 7 more

The class information org/springframework/batch/core/ it is referenced in the project.

enter image description here

Any idea how to solve?

Revolver_Ocelot
  • 8,609
  • 3
  • 30
  • 48
user3661384
  • 524
  • 7
  • 18
  • check your classapth of jar file. There are multiple options while creating a jar file through eclipse – Shriram Feb 23 '16 at 10:53

1 Answers1

0

I'm pretty sure you need to use spring-boot-maven-plugin and possibly execute the spring-boot:repackage goal. You might do Okay just making it a .war file, since that has worked for me with a Spring Boot application. The problem with executable jar files Spring style is that java can't load jars from a jar file. There are other non-spring solutions, see, e.g., Classpath including JAR within a JAR, but you should look through the spring docs to figure it out.

Reference: Packaging executable jar and war files

Community
  • 1
  • 1
K.Nicholas
  • 10,956
  • 4
  • 46
  • 66
  • Thank you. I managed to solve. I put the lib in the root of the jar and informed by command and worked beautiful. – user3661384 Feb 24 '16 at 11:13