GlassFish 3.1.1 损坏资源名称,然后抱怨找不到它
根据这篇文章和一些其他文档,JDBC资源是全局部署的(可用服务器-wide) 除非以 java:app/
为前缀。当我将 jdbc/myDataSource
更改为 java:app/jdbc/myDataSource
并将 myConnectionPool
更改为 java:app/myConnectionPool
,部署失败并出现以下异常:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:无效资源:{ ResourceInfo: (jndiName=java:app/jdbc/myDataSource__pm), (applicationName=com.example.web_example_war_1.0-SNAPSHOT) }
它在没有 java:app/
前缀的情况下工作得很好,但是然后资源会在服务器范围内部署。
According to this article and a number of other documents, JDBC resources are deployed globally (available server-wide) unless prefixed with java:app/
. When I change jdbc/myDataSource
to java:app/jdbc/myDataSource
and myConnectionPool
to java:app/myConnectionPool
, deployment fails with this exception:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/myDataSource__pm), (applicationName=com.example.web_example_war_1.0-SNAPSHOT) }
It works just fine without the java:app/
prefixes, but then the resources are deployed server-wide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否正在部署捆绑在 EAR 文件中的 WAR 文件,因为根据链接,您的“java:app/”前缀用于 EAR 部署。
Are you deploying your WAR files bundled in an a EAR file, coz as per the link you have the 'java:app/' prefix is for EAR deployment.
阅读本节后,我意识到我没有使用
java:app/
范围前缀为glassfish-resources.xml
中定义的资源添加前缀。根据该文件:然后它继续说,如果应用程序是 EAR 并且路径是 META-INF/glassfish-resources.xml 或(在我的例子中)它是 WAR 并且路径是
WEB-INF/glassfish-resources.xml
。这也许可以解释为什么 GlassFish 会修改这个名字。很可能发生名称冲突,因为我添加了前缀。
After reading this section, I realised that I don't have to prefix resources defined in
glassfish-resources.xml
with thejava:app/
scope prefix. According to that document:And then it goes on to say the resources are application scoped if the application is an EAR and the path is
META-INF/glassfish-resources.xml
or (in my case) it is a WAR and the path isWEB-INF/glassfish-resources.xml
.This may explain why GlassFish was mangling the name. There was most likely a name collision because I added the prefix.