Weblogic 10.3.1 重新部署重载类

发布于 2024-10-10 08:16:30 字数 237 浏览 2 评论 0原文

我们有一个类 Foo,它是一个单例并且继承自 Thread。重新部署后,我们遇到了一些问题,其中似乎有 2 个线程可能正在运行。我添加了一些打印语句来在每次 Foo 从睡眠中醒来时检索 ClassLoader。打印结果表明实际上该类的另一个实例已使用不同的类加载器创建。

我不知道它是否相关,但 Foo 总是通过会话 Bean 第一次通过 Foo::instance 创建。 Foo 旨在作为一项服务运行来负责数据库清理。

谢谢

We have a class, Foo, which is a singleton and inherits from Thread. We were having some issues after redeploy where it seemed like 2 of these threads might be running. I added some print statements to retrieve the ClassLoader every time Foo woke up from sleep. The prints indicate that in fact another instance of the class has been created with a different ClassLoader.

I don't know if it is relevant, but Foo always gets created via Foo::instance for the first time via a Session Bean. Foo is meant to run as a service to take care of DB sanitization.

Thanks

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

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

发布评论

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

评论(1

魔法少女 2024-10-17 08:16:30

显然有两种重新部署方法。看来它们都将继续让旧应用程序运行,直到它不再为请求提供服务。这两种方法仅在删除应用程序的方式上有所不同。我们使用的方法使旧应用程序保持完全运行,并使用不同的类加载器来加载新应用程序。我们的旧应用程序没有被取消部署。话虽这么说,如果您在某个未显式终止的地方运行一个线程(事实证明是这种情况),则可能会同时执行通过不同类加载器加载的同一个类的 2 个实例。运行 Weblogic 没有严格控制的线程被认为是不好的做法并且不安全。现在我知道为什么了。

Apparently there are 2 redeploy methods. It seems that both of them will continue to let the old application run until it is no longer servicing requests. The 2 methods vary only in how they go about removing the application. The method we're using keeps the old application running completely and uses different class loaders to load the new app. Our old application was not being undeployed. That being said, if you are running a thread somewhere that wasn't explicitly terminated (which turned out to be the case), you will potentially have 2 instances of the same class loaded via different class loaders executing simultaneously. Running threads that Weblogic doesn't have a death-grip on is considered bad practice and unsafe. Now I know why.

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