Announcement Announcement Module
Collapse
No announcement yet.
CommandLineJobRunner Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CommandLineJobRunner

    Hi All

    I Deployed the application in JBOSS and Batch is throwing a Exception .

    The Same Application is running fine In Tomcat6.x

    I am using customized CommandLineRunner the start method gets invoked from a Spring Controller Class

    4010Jobreader is placed in the Src folder of the application : so i guess it should not be a classpath problem



    MyCommandLine Snippet
    Code:
    	log.info("Start of startJob");
    		log.info("[MyCommandLine]-startJob Free Memory is ::"
    				+ Runtime.getRuntime().freeMemory());
    		currentDate = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss ");
    		// currentDate.
    
    		//ClassPathXmlApplicationContext context = null;
    		ConfigurableApplicationContext context = null;
    	  
    
    		try {
    		
    		
    		
    	context = new ClassPathXmlApplicationContext("4010Jobreader.xml");
    		
    		
    			context.getAutowireCapableBeanFactory().autowireBeanProperties(
    					this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
    
    			Job job;
    			if (jobLocator != null) {
    
    				job = jobLocator.getJob(jobName);
    			} else {
    
    				job = (Job) context.getBean(jobName);
    
    			}
    			// Start FTP download
    			try {
    
    				ftpDownloadProcess.startFtpSftp(Integer.parseInt(NIdNbr));
    
    			} catch (Exception ex) {
    				log.error("Exception due to" + ex.getMessage());
    				ex.printStackTrace();
    			}

    Please have a look 2 the stack trace :
    Code:
    12:48:02,058 INFO  [ClassPathXmlApplicationContext] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@11ff5d1: startup date [Wed Jul 20 12:48:02 IST 2011]; root of context hierarchy
    12:48:02,058 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [4010Jobreader.xml]
    12:48:02,058 ERROR [STDERR] org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [4010Jobreader.xml]; nested exception is java.io.FileNotFoundException: class path resource [4010Jobreader.xml] cannot be opened because it does not exist
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:458)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:388)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    12:48:02,058 ERROR [STDERR] 	at com.abcbs.EDI837.common.MyCommandLine.startJob(MyCommandLine.java:337)
    12:48:02,058 ERROR [STDERR] 	at com.abcbs.EDI837.common.MyCommandLine.main(MyCommandLine.java:975)
    12:48:02,058 ERROR [STDERR] 	at com.abcbs.EDI837.common.QuartzSample.execute(QuartzSample.java:25)
    12:48:02,058 ERROR [STDERR] 	at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
    12:48:02,058 ERROR [STDERR] 	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
    12:48:02,058 ERROR [STDERR] Caused by: java.io.FileNotFoundException: class path resource [4010Jobreader.xml] cannot be opened because it does not exist
    12:48:02,058 ERROR [STDERR] 	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
    12:48:02,058 ERROR [STDERR] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
    12:48:02,058 ERROR [STDERR] 	... 17 more




    Can some one please guide me to solve the problem
    Last edited by sansun2111; Jul 20th, 2011, 02:59 AM.

  • #2
    For starters don't do it this way, unless you want to run out of resources... You are creating a new application context on each invocation of this method why? Simply load the xml at container startup and have the dependencies injected on started (your current solution would even break in a concurrent environment). Also why isn't the download part of the job?

    However that doesn't really solve your problem... Make sure that everything is deployed how are you deploying/building the war. Check what you have deployed to JBoss and check if the file is there (judging from the stacktrace it isn't).

    Comment


    • #3
      Marten,
      Thanks for the reply ...

      Regarding loading the context @ container start up , hmm i need to look into it ...

      Make sure that everything is deployed how are you deploying/building the war. Check what you have deployed to JBoss and check if the file is there (judging from the stacktrace it isn't).

      I happen to see the WAR , the file is very much there in the classes folder ..

      Comment


      • #4
        Try prefixing it with a leading /. Due to loading rules it might be that (for some reason) JBoss tries to load it from the current directory.

        Comment


        • #5
          i did , still i am facing the same old exception

          Comment

          Working...
          X