-
Dec 13th, 2012, 10:10 PM
#1
Spring Batch in tomcat : Permgen OutOfMemoryError
I am launching spring Batch jobs within a tomcat servlet container. Every time i launch a job i start the spring batch appcontext and finally i close it. Most of my beans i am loading are singletons. By starting and closing context every time i run a job am i creating lot of proxy classes that are not being garbage collected or stored in Permgen.
After running multiple batch jobs i got java.lang.OutOfMemoryError: PermGen space errors
Below is the code i am using to start and close my appcontext
I would like to know if i am doing anything wrong, and if there is an efficient way to accomplish the same
public void runJobLauncher( String jobPath, String jobIdentifier, String... parameters ) throws Exception{
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( jobPath );
try{
context.getAutowireCapableBeanFactory().autowireBe anProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
Job job = (Job) context.getBean( jobIdentifier );
JobParameters jobParameters = new DefaultJobParametersConverter().getJobParameters( StringUtils.splitArrayElementsIntoProperties( parameters, "=" ) );
JobExecution jobExecution = jobLauncher.run(job, jobParameters);
ExitStatus exitStatus = jobExecution.getExitStatus();
}finally{
context.close();
}
}
Last edited by dgiridhar; Dec 13th, 2012 at 10:14 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules