如何在 glassfish 3.1 中设置 jndi 数据源?

发布于 2024-12-24 16:32:44 字数 348 浏览 1 评论 0 原文

我需要在部署在 glassfish 服务器上的 Web 应用程序中设置 jndi 数据源。我不想使用 glassfish 管理控制台来创建连接池和 jndi 数据源。 (但这确实有效。)

我想使用一些 xml 文件,例如 context.xml (在 tomcat 中使用)来指定将与应用程序 war 文件捆绑在一起的 jndi 数据源详细信息。

这样,如果我部署应用程序 war 文件,我就不必从管理控制台对 glassfish 进行任何更改。

请帮忙。

附言。我尝试将 context.xml 放入 war META-INF 中,但它不起作用。当我在 glassfish 上部署战争时,它说找不到 jndi 名称。

I need to setup jndi datasource in my web application deployed on the glassfish server. I don't want to use glassfish admin console for creating connection pool and jndi datasource. (This works though.)

I would want to use some xml files like context.xml (used in tomcat) to specify the jndi datasource details which will be bundled with the application war file.

This way if I deploy my app war file I would not have to do any changes in the glassfish from the admin console.

Please help.

PS. I tried putting context.xml in war META-INF, but its not working. When I deploy my war on glassfish it says jndi name not found.

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

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

发布评论

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

评论(1

Hello爱情风 2024-12-31 16:32:44

您无法从企业应用程序内部在 Glassfish 应用程序服务器上设置资源;我什至会说对于任何兼容 Java EE 的应用程序服务器都是如此。这完全违背了 EJB 的角色分离:准备应用程序是Enterprise Bean Provider应用程序组装者的角色,而将其安装到服务器上则属于部署者< /em> (请参阅 EJB 3.1 规范,第 2.2 章)。

不过,您当然不必手动设置所有内容。 Glassfish 有一个命令行工具 asadmin,借助它,您可以编写可从 GUI 管理控制台访问的所有操作的脚本 - 请查看 Glassfish 管理指南

You can't set up resources on Glassfish application server from within an enterprise application; I would even say it's true for any Java EE-compliant application server. It's simply against EJB separation of roles: preparing the application is the role of Enterprise Bean Provider and Application Assembler, and installing it on the server belongs to the Deployer (see EJB 3.1 spec, chapter 2.2).

You surely don't have to set up everything manually, though. Glassfish has a command line tool asadmin, with the help of which you can script all operations accessible from the GUI admin console — take a look at the Glassfish Admin Guide.

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