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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:05:16+00:00 2026-05-23T18:05:16+00:00

In grails 1.3.7, I access some external properties via the ConfigurationHolder in my controller.

  • 0

In grails 1.3.7, I access some external properties via the ConfigurationHolder in my controller. Googling around suggests I can use the following in the setup of my unit test:

    mockConfig '''
        sys.admin.username = "username"
        sys.admin.password = "password"
    '''

when my unit tests run ConfigruationHolder.config is null. So more googling lead me to try this in the setup:

    def mockedConfig = new ConfigObject()
    mockedConfig.sys.admin.username = "username"
    mockedConfig.sys.admin.password = "password"
    ConfigurationHolder.config = mockedConfig

still getting a null config object in the unit test. I also tried the hiearctical syntax for this first style and it didn’t work either:

    mockConfig('''
        sys { admin {
            username = 'username'
            password = 'password'
        } }
    ''')

I am new to grails so I am stumbling my way through this and would like to get my controller unit tested. How do I get around a null config object?

  • 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-05-23T18:05:16+00:00Added an answer on May 23, 2026 at 6:05 pm

    Alas, it was a timing issue. I held a reference to the configurationholder in my controller class:

    def config = ConfigurationHolder.config
    

    Moving that inside the method where it was needed worked.

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

Sidebar

Related Questions

How can I access Hibernate properties from a Grails Service? In this instance I
In Grails, one can 'bindData' in controller: Book b = new Book() bindData(b, params)
I have two grails servers: Server - has read/write access to the database Web
I want a grails service to be able to access Domain static methods, for
while trying to deploy a Grails application into tomcat6 I ran into some problems:
I'm working on a Grails web app that would be similar in access patterns
after updating my grails app's security plugins, i get the following error when deploying
Hi am just started working on grails.. developed my first application in grails can
I'm using Spring Security in Grails to restrict access to my controllers. I have
I'm trying to access servletContextin a controller like so, but keep getting null pointer

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.