0

I'm using Grails 2.4.3 and I have a service returning null only in the production environment. If I run it in the Dev environment, the service responds correctly. Even if I generate a war file using Development it will work, but if I generate a war file using the production environment (the default grails war), the service will return null. I'm not sure what could be causing this to happen where the environment affects the service... ?

I've only found the issue with one specific service responding this way. All other services in the project appear to be working correctly in all environments.

--UPDATE-- To elaborate on the service in question: The service does do some database queries and saves (takes some information in the session and saves it). It is marked with @Transactional on the class. It also injects two helper services (including sessionFactory) by convention (def sessionFactory; def otherService;)

I also tried getting the bean from the application context and I get "Bean not found"

Brandon Wagner
  • 893
  • 9
  • 27

1 Answers1

0

From the sounds of things it is related to your injections..

  1. I would run

grails run-war

from development - to see if this regenerates the same issue:

  1. Put application db in debug mode to see if it is DB related:

How to log SQL statements in Grails

If this does not solve the issue, the next attempt would be to put actual application in debug mode

http://grails-dev.blogspot.co.uk/2012/09/setting-up-log4j-configuration-in.html

  1. This is certainly a service and not a groovy src file or something, in order to inject services into other calls you could try :

conf/spring/resources.groovy

Create an entry for the src/groovy file : In this case GetDownloadConfig Define the injection:

getDownloadConfig(GetDownloadConfig) {
                grailsApplication = ref('grailsApplication')
                dnsService = ref('dnsService')
                jobReplaceService= ref('jobReplaceService')
                jenkinsService= ref('jenkinsService')
            }

Then in

class GetDownloadConfig {
    def jenkinsService
    def dnsService
    def jobReplaceService
    def grailsApplication


     // Or alternative method using holders - 
    //def grailsApplication = Holders.grailsApplication.mainContext.getBean 'grailsApplication'
    //def dnsService = Holders.grailsApplication.mainContext.getBean 'dnsService'
    //def jobReplaceService= Holders.grailsApplication.mainContext.getBean 'jobReplaceService'
    //def jenkinsService= Holders.grailsApplication.mainContext.getBean 'jenkinsService'

This may be of help too

How do you get the sessionFactory in a Grails Geb/Spock test case?

Community
  • 1
  • 1
V H
  • 8,382
  • 2
  • 28
  • 48