java.lang.ClassNotFoundException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

This might be an issue with the file location in the Spark submit command. Try it with "spark-submit --master spark://master:7077 hello_world_from_pyspark.py {file location}"

tip

Check if you've set a name in Application -> Run. If you didn't, the generated XML is gonna have missing information and then this exception will be thrown.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Creating this improvement request on behalf of the customer: I have a improvement request for Spring Batch as follows - 【Product & Version】 Spring Batch 3.0.0.M2 【Class】 org.springframework.batch.core.launch.support.CommandLineJobRunner 【Source Code (current)】 {code} int start(String jobPath, String jobIdentifier, String[] parameters, Set<String> opts) { ConfigurableApplicationContext context = null; try { try { context = new ClassPathXmlApplicationContext(jobPath); } catch (BeansException e) { logger.info("No XML-based context named " + jobPath + ". Trying class-based configuration."); context = new AnnotationConfigApplicationContext(Class.forName(jobPath)); } }    ・・・ {code} --------------------------------------------------------------------------- Currently, the “start” method tries to load the configuration given by parameter “jobPath” as an “XML Configuration“ by parsing the XML file of “jobPath”, at first. In case an exception occurs while loading “XML Configuration”, the configuration is loaded as a “Java Configuration”. 【Problems】 “Java Configuration” loading is necessary only when an XML file given by “jobPath” does not exist. In other cases (such as a case that an XML file is not parsable), I want the exception to be re-thrown to let us know the real reason of it. (It is also appreciated to load “Java Configuration” only when the jobPath represents a classpath, or a file of “jobPath” is not an XML file.) In my case, I gave a path of “job-launcher-context.xml” to “jobPath”, and got an exception below, which does not explain the real reason of the exception. So it is so difficult to troubleshoot without debugging.   ----------------------------------------------------------------------------- java.lang.ClassNotFoundException: job-launcher-context.xml at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at jp.co.nssol.sample.batch.common.CommandLineLauncher.start(CommandLineLauncher.java:195) at jp.co.nssol.sample.batch.common.CommandLineLauncher.main(CommandLineLauncher.java:478) --------------------------------------------------------------------------- 【Source Code (proposed)】 {code} int start(String jobPath, String jobIdentifier, String[] parameters, Set<String> opts) { ConfigurableApplicationContext context = null; try { try { context = new ClassPathXmlApplicationContext(jobPath); } catch (BeansException e) { if (org.apache.commons.lang.exception.ExceptionUtils.indexOfType(e, FileNotFoundException.class) >= 0) { // in case FileNotFoundException, load as a “Java Configuration” LOGGER.warn("No XML-based context named " + jobPath + ". Trying class-based configuration."); context = new AnnotationConfigApplicationContext(Class.forName(jobPath)); } else { throw e; // <- re-throw the exception } } {code}
    via by Shahid Shahiduzzaman,
  • Creating this improvement request on behalf of the customer: I have a improvement request for Spring Batch as follows - 【Product & Version】 Spring Batch 3.0.0.M2 【Class】 org.springframework.batch.core.launch.support.CommandLineJobRunner 【Source Code (current)】 {code} int start(String jobPath, String jobIdentifier, String[] parameters, Set<String> opts) { ConfigurableApplicationContext context = null; try { try { context = new ClassPathXmlApplicationContext(jobPath); } catch (BeansException e) { logger.info("No XML-based context named " + jobPath + ". Trying class-based configuration."); context = new AnnotationConfigApplicationContext(Class.forName(jobPath)); } }    ・・・ {code} --------------------------------------------------------------------------- Currently, the “start” method tries to load the configuration given by parameter “jobPath” as an “XML Configuration“ by parsing the XML file of “jobPath”, at first. In case an exception occurs while loading “XML Configuration”, the configuration is loaded as a “Java Configuration”. 【Problems】 “Java Configuration” loading is necessary only when an XML file given by “jobPath” does not exist. In other cases (such as a case that an XML file is not parsable), I want the exception to be re-thrown to let us know the real reason of it. (It is also appreciated to load “Java Configuration” only when the jobPath represents a classpath, or a file of “jobPath” is not an XML file.) In my case, I gave a path of “job-launcher-context.xml” to “jobPath”, and got an exception below, which does not explain the real reason of the exception. So it is so difficult to troubleshoot without debugging.   ----------------------------------------------------------------------------- java.lang.ClassNotFoundException: job-launcher-context.xml at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at jp.co.nssol.sample.batch.common.CommandLineLauncher.start(CommandLineLauncher.java:195) at jp.co.nssol.sample.batch.common.CommandLineLauncher.main(CommandLineLauncher.java:478) --------------------------------------------------------------------------- 【Source Code (proposed)】 {code} int start(String jobPath, String jobIdentifier, String[] parameters, Set<String> opts) { ConfigurableApplicationContext context = null; try { try { context = new ClassPathXmlApplicationContext(jobPath); } catch (BeansException e) { if (org.apache.commons.lang.exception.ExceptionUtils.indexOfType(e, FileNotFoundException.class) >= 0) { // in case FileNotFoundException, load as a “Java Configuration” LOGGER.warn("No XML-based context named " + jobPath + ". Trying class-based configuration."); context = new AnnotationConfigApplicationContext(Class.forName(jobPath)); } else { throw e; // <- re-throw the exception } } {code}
    via by Shahid Shahiduzzaman,
  • Cloudscape DJBC Driver Error
    via by 843854,
  • Run j2ee server
    via by 807592,
  • ClassNotFoundException
    via GitHub by TomPiXX
    ,
  • Empty ClassNotFoundException
    via GitHub by hetzge
    ,
  • Error on startup.
    via GitHub by tehfrithzor
    ,
  • Connection lost
    via GitHub by JusticeOF666
    ,
    • java.lang.ClassNotFoundException: job-launcher-context.xml at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at jp.co.nssol.sample.batch.common.CommandLineLauncher.start(CommandLineLauncher.java:195) at jp.co.nssol.sample.batch.common.CommandLineLauncher.main(CommandLineLauncher.java:478)

    Users with the same issue

    Unknown visitor1 times, last one,
    zsamboki
    1 times, last one,
    Pilleo
    2 times, last one,
    kimihanif
    1 times, last one,
    Unknown visitor1 times, last one,
    308 more bugmates