GlassFish 3.1,如何在服务器根目录中部署带有 WAR 的 EAR?

发布于 2024-12-10 07:06:45 字数 500 浏览 0 评论 0原文

我有一个带有 WAR 的 EAR,正在 GlassFish 3.1 上部署

目前,该应用程序在 localhost:8080/myapp/index.jsf 上运行

我希望它在 localhost:8080/index.jsf 上运行

为了实现此目的,我更改了EAR 中的 application.xml 从 contextRoot "myapp" 到 contextRoot="/"

当我使用 GlassFish 管理 UI 部署 EAR 时,它会出现部署错误,然后当我尝试浏览到管理 UI,它显示了默认的 GlassFish 主页。要恢复,我必须从命令行使用 asadmin 取消部署 EAR,然后执行 restart-domain 来重新启动服务器。

我的理论是我的应用程序和 GlassFish 管理 UI 都在根“/”上运行。

问题:在 GlassFish 3.1 的根目录中部署 Web 应用程序的正确方法是什么?或者这是不好的做法?

谢谢!

I have an EAR with a WAR that I'm deploying on GlassFish 3.1

Currently, the application runs at localhost:8080/myapp/index.jsf

I want it to run on localhost:8080/index.jsf

To accomplish this, I changed the application.xml in the EAR from contextRoot "myapp" to contextRoot="/"

When I deploy my EAR using the GlassFish admin UI, it gives me a deployment error, then when I try to browse to the admin UI, it shows me the default GlassFish home page. To recover I have to undeploy my EAR using asadmin from the command line and then do a restart-domain to restart the server.

My theory is that my application and the GlassFish admin UI are both running on root "/".

QUESTION: What is the correct way to deploy my web app in root of GlassFish 3.1? Or is this bad practice?

Thanks!

Rob

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

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

发布评论

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

评论(2

寒尘 2024-12-17 07:06:45

Rob,

如果您从命令行进行部署,您可以使用 asadmin 的参数来选择上下文根。这从来没有给我带来你所描述的问题。

$ASADMIN deploy --contextroot "/" your.war

您的另一个选择是在虚拟服务器设置下选择默认 Web 模块,但我个人更喜欢仅将一个应用程序设置为 /。

凯文

Rob,

If your deploying from the command line you can use an argument to asadmin to choose the context root. This has never given me the issue you describe.

$ASADMIN deploy --contextroot "/" your.war

Your other option is to under the Virtual Server settings to choose a default web module, but personally I prefer just setting one application to /.

Kevin

以可爱出名 2024-12-17 07:06:45

最简单的方法是使用 glassfish-web.xml。

这是我的配置,位于 WEB-INF 目录中。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
   <context-root>/myapplication</context-root>
</glassfish-web-app>

请注意,您应该考虑使用战争而不是耳朵。 Glassfish 3.x 是 JavaEE6 的参考实现,具有与 EJB 一起使用 war 的功能。也就是说,您可以轻松地使用您的ejb进行战争,而无需耳塞。它不仅会显着减少您的应用程序大小,而且还可以让您在类加载问题、内存占用等方面有一个良好的实践......

The easisest way is having a glassfish-web.xml.

This is my configuration which is located at my WEB-INF directory.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
   <context-root>/myapplication</context-root>
</glassfish-web-app>

As a note, you should consider to use war instead of ear. Glassfish 3.x which is reference implementation for the JavaEE6 has a feature to use war with EJB's. That is to say you can easily use your war with your ejb without ear bundle. It will not only decrease your application size significantly but also lets you to have a good practice in terms of class loading issues, memory footprint etc...

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