Weblogic 10.3.1 重新部署重载类
我们有一个类 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然有两种重新部署方法。看来它们都将继续让旧应用程序运行,直到它不再为请求提供服务。这两种方法仅在删除应用程序的方式上有所不同。我们使用的方法使旧应用程序保持完全运行,并使用不同的类加载器来加载新应用程序。我们的旧应用程序没有被取消部署。话虽这么说,如果您在某个未显式终止的地方运行一个线程(事实证明是这种情况),则可能会同时执行通过不同类加载器加载的同一个类的 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.