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 8509239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:22:50+00:00 2026-06-11T03:22:50+00:00

I added cronjobs to spring app using quartz. inside these jobs, I would like

  • 0

I added cronjobs to spring app using quartz.

inside these jobs, I would like to access spring-security secured bean methods from another app.

This is my application structure.

| – core
| – webapp
| – jobs-app

both the webapp and jobsapp use core services. jobsapp is not a web application. It just has quartz jobs in it.

Inside a job if I try to access a bean that is secured using SpringSecurity global-method-security I get an exception {org.springframework.security.AuthenticationCredentialsNotFoundException}"org.springframework.security.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext"

If I set the context using SecurityContextHolder.getContext().setAuthentication to a power user, it works.

But, I have to do this for all the jobs.

Is there a way I can make all the jobs runas a particular user? may be some configuration somewhere?

  • 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-11T03:22:52+00:00Added an answer on June 11, 2026 at 3:22 am

    You have two choices:

    • move @Secured annotation up, from service to web layer. If I understand correctly your Quartz jobs access service beans directly (bypassing the web layer) so you’ll bypass the security as well

    • implement Run-As functionality, just like you described. It doesn’t have to be that manual. Try template method pattern or some AOP + annotations. It’ll turn out to be rather clean.

    We tried both approaches and moving security to web layer worked slightly better. This was possible because service layer was mapping nicely to Spring MVC controller methods.

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

Sidebar

Related Questions

Added Database Source Bean to Spring.xml and getting error. why can't I make my
ADDED INFO: I'm using the inside of a square as an arena. On start
Added an image from android market. I would like to know how can we
I added to my system-wide /etc/security/limits.conf the following two rows: * soft rtprio 55
UPDATE: Added doGet function. I have a web app that is used for a
I added a private framework to my project using link binary with libraries, but
Added: thanks to user @grapkulec, I am using using Microsoft.Exchange.WebServices.Data; I am trying to
added f:ajax tag to my jsf page, with the hopes of using ajax <td
I added a GoogleAdMobAdsSdkiOS-6.1.4 SDK to my cocos2d app in order to integrate AdWhirl.
I added a wav file to my Windows Mobile app and I want to

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.