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

Spring JIRA | Shahid Shahiduzzaman | 3 years ago
  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

    Cloudscape DJBC Driver Error

    Oracle Community | 1 decade ago | 843854
    java.lang.ClassNotFoundException: RmiJdbc.RJDriver
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Run j2ee server

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

    Caused by: java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC - 蕃薯耀 - ITeye技术网站

    iteye.com | 6 months ago
    java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC]

  1. gehel 1 times, last 6 days ago
  2. davidvanlaatum 3 times, last 6 days ago
  3. danleyb2Interintel 1 times, last 1 week ago
  4. malhobayyeb 3 times, last 2 weeks ago
  5. Kialandei 1 times, last 2 weeks ago
49 more registered users
46 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