在 Glassfish 下运行多个 Grails 应用程序时出错

发布于 2024-12-25 23:25:12 字数 1637 浏览 1 评论 0原文

我已经使用 Grails (V2.0.0.RC1) 编写了两个小 hello world 应用程序,并且我想使用 Glassfish (v3.1) 部署它们。

如果我将它单独部署在 Glassfish 上的应用程序之一,该应用程序就可以正常工作,并且我可以通过 http://t1-0.1http:// 访问它t2-0.1。但是,如果我部署其中一个应用程序,然后部署另一个应用程序(以便访问我的网站的人都可以使用这两个应用程序),那么第二个部署命令会显示以下错误消息:

c:>asadmin 部署 t2-0.1.war

远程失败:部署期间发生错误:异常 加载应用程序:java.lang.IllegalStateException: ContainerBase.addChild:启动:org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException:错误 创建名称为“transactionManagerPostProcessor”的 bean: bean 初始化失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“transactionManager”的 bean:无法解析引用 设置 bean 属性“sessionFactory”时为 bean“sessionFactory”; 嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“sessionFactory”的 bean:无法解析对的引用 设置 bean 属性时 bean 'hibernateProperties' '休眠属性';嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建时出错 名称为“hibernateProperties”的 bean:无法解析对的引用 bean'dialectDetector'同时设置bean属性'properties' 键[hibernate.dialect];嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“dialectDetector”的 bean:调用 init 方法失败;嵌套异常是 org.springframework.jdbc.support.MetaDataAccessException:错误 提取数据库元数据;嵌套异常是 org.apache.commons.dbcp.SQLNestedException:无法创建 PoolableConnectionFactory(数据库可能已在使用中:“由 另一个进程”。可能的解决方案:关闭所有其他连接; 使用服务器模式; SQL 声明:空/1349c415392c6dc06a3e7086cd1bb075c7881fc0650 [90020-147])。请参阅 server.log 了解更多详细信息。

这是怎么回事?我认为 Grails 及其对 Hibernate 的使用有一些特殊之处(否则 Glassfish 不会抱怨允许我拥有两个可以一起工作的应用程序)。但也许我误读了错误消息?有人有什么建议吗?

I have written two little hello world applications using Grails (V2.0.0.RC1), and I want to deploy them using Glassfish (v3.1).

If I deploy it either one of the applications all by itself on Glassfish the application works just fine, and I can access it either at http://t1-0.1 or at http://t2-0.1. If instead, however, I deploy one of the applications, and then deploy the other (so that both are available to people visiting my web site), then the second deployment command gives me the following error message:

c:>asadmin deploy t2-0.1.war

remote failure: Error occurred during deployment: Exception while
loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManagerPostProcessor':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': Cannot resolve reference
to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to
bean 'hibernateProperties' while setting bean property
'hibernateProperties'; nested exception is
org.springframework.beans.factory.BeanCreationException: Errorcreating
bean with name 'hibernateProperties': Cannot resolve reference to
bean'dialectDetector' while setting bean property 'properties' with
key [hibernate.dialect]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dialectDetector': Invocation of init
methodfailed; nested exception is
org.springframework.jdbc.support.MetaDataAccessException: Error while
extracting DatabaseMetaData; nested exception is
org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Database may be already in use: "Locked by
another process". Possible solutions: closeall other connection(s);
use the server mode; SQL
statement:null/1349c415392c6dc06a3e7086cd1bb075c7881fc0650
[90020-147]). Please see server.log for more details.

What's going on here? I presume that there is something peculiar about Grails and its use of Hibernate (since otherwise Glassfish wouldn't complain about allowing me to have two applications that work together). But maybe I'm misreading the error message? Does anybody have any recommendations?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2025-01-01 23:25:12

事实证明,问题在于我滥用了 Grails 提供的默认配置。在文件 DataSource.groovy 中,每个应用程序都被赋予一个指向数据库的指针,默认情况下该指针如下所示:

development {
    dataSource {
        dbCreate = "create-drop" 
        url = "jdbc:h2:mem:devDb;MVCC=TRUE"
    }
}

问题是多个应用程序将被赋予相同的配置,并且多个应用程序之间的底层基于内存的 h2 数据库引用冲突。因此,几个“hello world”示例应用程序的解决方案是更改其中一个引用。例如:

development {
    dataSource {
        dbCreate = "create-drop" 
        url = "jdbc:h2:mem:devDb2;MVCC=TRUE"
    }
}

当然,在生产代码中,您可能最终会引用真实的数据库,然后您的应用程序自然会在其数据库引用中进行协作。

It turns out that the problem lay in my misuse of the default configuration provided by Grails. In the file DataSource.groovy each application is given a pointer to a database, and by default that pointer looks like this:

development {
    dataSource {
        dbCreate = "create-drop" 
        url = "jdbc:h2:mem:devDb;MVCC=TRUE"
    }
}

The problem is that multiple applications will be given identical configurations, and the underlying memory-based h2 database references between the multiple applications conflict. Therefore, the solution for a couple of "hello world" example applications is to change one of those references. For example:

development {
    dataSource {
        dbCreate = "create-drop" 
        url = "jdbc:h2:mem:devDb2;MVCC=TRUE"
    }
}

Of course, in production code you will likely end up referencing a real database, and then your applications will naturally cooperate in their database references.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文