java.lang.ClassNotFoundException: job-launcher-context.xml

Spring JIRA | Shahid Shahiduzzaman | 3 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    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}

    Spring JIRA | 3 years ago | Shahid Shahiduzzaman
    java.lang.ClassNotFoundException: job-launcher-context.xml
  2. 0

    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}

    Spring JIRA | 3 years ago | Shahid Shahiduzzaman
    java.lang.ClassNotFoundException: job-launcher-context.xml
  3. 0
    samebug 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}"
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Cloudscape DJBC Driver Error

    Oracle Community | 1 decade ago | 843854
    java.lang.ClassNotFoundException: RmiJdbc.RJDriver
  6. 0

    Run j2ee server

    Oracle Community | 2 decades ago | 807592
    java.lang.ClassNotFoundException: RmiJdbc.RJDriver

  1. jokester 2 times, last 1 week ago
  2. Andreas Häber 1 times, last 2 weeks ago
  3. Bugger 5 times, last 3 weeks ago
  4. marcbouvierdav 2 times, last 3 weeks ago
  5. jf-ast 2 times, last 3 weeks ago
60 more registered users
35 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassNotFoundException

    job-launcher-context.xml

    at java.lang.Class.forName0()
  2. Java RT
    Class.forName
    1. java.lang.Class.forName0(Native Method)
    2. java.lang.Class.forName(Unknown Source)
    2 frames
  3. jp.co.nssol
    CommandLineLauncher.main
    1. jp.co.nssol.sample.batch.common.CommandLineLauncher.start(CommandLineLauncher.java:195)
    2. jp.co.nssol.sample.batch.common.CommandLineLauncher.main(CommandLineLauncher.java:478)
    2 frames