[英]Grails Service in Production Environment returns Null
I'm using Grails 2.4.3 and I have a service returning null only in the production environment. 我正在使用Grails 2.4.3,并且有一个仅在生产环境中返回null的服务。 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. 即使我使用Development生成了war文件,也可以使用,但是如果我使用生产环境生成了war文件(默认为grails war),则该服务将返回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). --UPDATE--详细说明所涉及的服务:该服务确实执行一些数据库查询并保存(在会话中获取一些信息并保存)。 It is marked with @Transactional on the class. 在类上用@Transactional标记。 It also injects two helper services (including sessionFactory) by convention (def sessionFactory; def otherService;) 它还按约定注入两个帮助程序服务(包括sessionFactory)(def sessionFactory; def otherService;)。
I also tried getting the bean from the application context and I get "Bean not found" 我还尝试从应用程序上下文中获取Bean,但出现“找不到Bean”
From the sounds of things it is related to your injections.. 从事物的声音来看,这与您的注射有关。
grails run-war 战乱
from development - to see if this regenerates the same issue: 从开发中获取-看看是否会重新产生相同的问题:
How to log SQL statements in Grails 如何在Grails中记录SQL语句
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 http://grails-dev.blogspot.co.uk/2012/09/setting-up-log4j-configuration-in.html
conf/spring/resources.groovy conf / spring / resources.groovy
Create an entry for the src/groovy file : In this case GetDownloadConfig Define the injection: 为src / groovy文件创建一个条目:在这种情况下,GetDownloadConfig定义注入:
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? 如何在Grails Geb / Spock测试用例中获得sessionFactory?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.