部署到jboss时,“IllegalArgumentException:Name不能为null”

时间:2016-09-07 16:25:51

标签: jboss grails-3.0

(我已经解决了这个问题,但是在这里发布以帮助其他人。)

我最近从Grails 2.4.4升级到Grails 3.当部署到JBoss EAP 6.4(Wildfly 7)时,我在服务器日志中收到以下错误,并且应用程序无法启动:

09-06 20:46:18,463 ERROR [org.jboss.as.web.deployment.JBossContextConfig] (ServerService Thread Pool -- 90) JBAS018202: Error calling onStartup for servlet container initializer: org.springframework.web.SpringServletContainerInitializer: java.lang.IllegalArgumentException: Name must not be null
    at org.springframework.util.Assert.notNull(Assert.java:115) [spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:214) [spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:284) [spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.grails.transaction.ChainedTransactionManagerPostProcessor.resolveTransactionManagerClass(ChainedTransactionManagerPostProcessor.java:158) [grails-core-3.1.5.jar:3.1.5]
    at org.grails.transaction.ChainedTransactionManagerPostProcessor.hasJtaOrChainedTransactionManager(ChainedTransactionManagerPostProcessor.java:143) [grails-core-3.1.5.jar:3.1.5]
    at org.grails.transaction.ChainedTransactionManagerPostProcessor.postProcessBeanDefinitionRegistry(ChainedTransactionManagerPostProcessor.java:119) [grails-core-3.1.5.jar:3.1.5]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:123) [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678) [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520) [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55) [grails-core-3.1.5.jar:3.1.5]

我在应用程序中有两个不同的数据源,这两个数据源都在JNDI中注册。

运行调试器后,我看到transactionManagerBeanDefinition.getBeanClassName()返回null,但我不确定原因。

为什么会发生这种错误,我将如何解决?

1 个答案:

答案 0 :(得分:0)

This link让我得到答案。

问题似乎是由于我的应用程序中存在多个数据源,导致Spring / JBoss在设置事务管理器时感到困惑。

解决方案是在transactional: false中为第二个数据源设置application.yml。这对我来说非常完美,因为无论如何第二个数据源都是只读的。

<强> application.yml:

dataSources:
    dataSource:
        dialect: "..."
    otherDataSource:
        dialect: "..."
        transactional: false  <------ add this line