是否可以在不修改/重新部署 WAR 的情况下向已部署的 WAR 添加依赖项

发布于 2024-12-27 23:05:33 字数 307 浏览 3 评论 0原文

我们有一个向用户显示表单的应用程序 XYZ。我们希望分发此应用程序,并允许外部开发人员创建自己的表单(扩展应用程序 XYZ 提供的接口),并以应用程序 XYZ 无需自行修改即可显示它们的方式部署这些表单。应用程序 XYZ 通过查找列出所有可用表单类的配置文件来了解它可以显示哪些表单(然后以反射方式实例化这些表单类)。

我们使用 Weblogic 10.3 作为应用程序服务器,该应用程序是 GWT / Java 应用程序。

据我所知,我所描述的场景是不可能的,因为应用程序 XYZ 需要重新编译和重新部署,并将新的依赖项添加到类路径中。我希望有人能告诉我另外的情况。

We have an application XYZ that displays forms to a user. We would like to distribute this application and allow external develops to create their own forms (extending interfaces provided by application XYZ) and deploy those forms in a way that application XYZ can display them without having to be modified itself. Application XYZ knows which forms it can display by looking up a config file which lists all of the form classes available (these are then instantiated reflectively).

We are using Weblogic 10.3 as the application server and the application is a GWT / Java app.

As far as I'm aware the scenario I've described would not be possible as application XYZ will need to be recompiled and redeployed with the new dependency added to the classpath. I am hoping that someone can tell me otherwise.

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

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

发布评论

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

评论(1

原谅我要高飞 2025-01-03 23:05:33

Servlet 规范规定每个 WAR 文件都部署在它自己的隔离类加载器上。这可以隔离在同一 servlet 容器实例上运行的多个 Web 应用程序。

tomcat 文档 描述了各种类之间的关系装载机非常好。 (考虑到 Tomcat 是 servlet 的参考实现,Weblogic 应该以类似的方式执行)

因此,重新编译 WAR 的另一种方法是将这些额外的自定义 jar 放入“$CATALINA_BASE/lib”目录(或 Weblogic 的等效目录)中。

不过,我发现有几个需要注意的实现问题:

  1. 您的应用程序需要针对固定的版本进行编译
    界面。这将使用户能够替换运行时实现
    那些课程。
  2. 定制的罐子将在所有人之间共享
    您的应用程序的实例。这可能会排除在同一应用程序服务器实例上运行旧版本应用程序的可能性。
  3. 预期部署问题...考虑您的应用程序对缺少依赖项将如何反应。用户不会理解 Java 堆栈跟踪:-)

The Servlet specification states that each WAR file is deployed on it's own isolated class loader. This enables the isolation of multiple web applications, running on the same servlet container instance.

The tomcat documentation describes the relationship of the various class-loaders very well. (Considering Tomcat was the reference implementation for servlets, Weblogic should execute in a similar manner)

So an alternative to recompiling you WAR would be to place these extra custom jars into the "$CATALINA_BASE/lib" directory (or Weblogic's equivolent).

However I see a couple of implementation issues to be aware of:

  1. Your application would need to be compiled against a fixed
    interface. This would enable users to substitute a run-time implementation of
    those classes.
  2. The custom jars would be shared across all
    instances of your application. This might rule out running older versions of your app on the same appserver instance.
  3. Expect deployment problems... Think about how your application would react to missing dependencies. Users won't understand a Java stacktrace :-)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文