Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:07:40+00:00 2026-06-09T21:07:40+00:00

I am coding a spring application. I have a scheduled job like this. @Async

  • 0

I am coding a spring application. I have a scheduled job like this.

@Async
@Scheduled(cron = "0 0 16 * * ?")
public void createReport()
{
    // argJasperPath = /WEB-INF/jasperFiles/myreport.jasper
    JasperPrint jasperPrint = JasperFillManager.fillReport(argJasperPath, argReportParams, argDataSource);
    JasperExportManager.exportReportToPdfFile(jasperPrint, argOutputPath);
}

This runs at 16:00 every day and create a report. I am using JasperReports for generating reports. I have myreport.jasper file under /WEB-INF/jasperFiles/myreport.jasper, when I run my job while generating report I get FileNotFound exception.

How can I reach my jasper files in my scheduled method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:07:41+00:00Added an answer on June 9, 2026 at 9:07 pm
    @Autowired
    ServletContext context;
    
    @Async
    @Scheduled(cron = "0 0 16 * * ?")
    public void createReport()
    {
        // argJasperPath = /WEB-INF/jasperFiles/myreport.jasper
        JasperPrint jasperPrint = JasperFillManager.fillReport(context.getRealPath(argJasperPath), argReportParams, argDataSource);
        JasperExportManager.exportReportToPdfFile(jasperPrint, argOutputPath);
    }
    

    If we autowire ServletContext we can reach directory like this: (context.getRealPath(argJasperPath)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Spring Web MVC for my application. I have 1 dropdown list
I have a normal Java class in a Spring MVC 3.06 web application. In
I'm coding a web application in GWT. I have a class that handles all
I have a web application in Spring that has a functional requirement for generating
I have an issue with the Spring and GWT application I am working on.
We have an application deployed on Tomcat 6. It's built on Spring/Struts 2, and
I am coding an application and I would like to give the admin a
We have a very large JavaScript application, where after many months of coding there
I have to write this produce consumer application using multithreading. I wrote the following
This is a question regarding best coding practices. I would like to know the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.