我需要在部署在 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.
发布评论
评论(1)
您无法从企业应用程序内部在 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.