[英]How to share an instance between multiple applications (web or ejb) running in the same JVM?
I have to design a way to be able to share the same object between multiple applications. 我必须设计一种能够在多个应用程序之间共享同一对象的方法。 All applications will be on same JVM. 所有应用程序都将在同一JVM上。 They can be different war sides or jar sides. 他们可以是不同的战争方面或罐子方面。 The problem that I am trying to fix is as follows. 我要解决的问题如下。 I have a jar side and in a web application, i create stubs to be used in the war side for ejb invocations. 我有一个jar端,并且在Web应用程序中,我创建了要在war端用于ejb调用的存根。 I have another application and want to be able to use to inspect the same object (which is being referenced by the first web app using stubs). 我有另一个应用程序,希望能够用来检查相同的对象(第一个Web应用程序使用存根引用了该对象)。 Is there a way to achieve this. 有没有办法实现这一目标。
Amogh. 阿莫
I ran into a similar issue once that took a week to debug, it ended up being a classpath issue. 我花了一个星期的时间进行调试,遇到了类似的问题,最终成为类路径问题。 When you are building your app, you will need to create a jar that will hold the classes that you want to share between apps. 在构建应用程序时,您将需要创建一个jar,其中包含要在应用程序之间共享的类。
So you would end up building the 3 ( or N ) projects in the following order: 因此,您将按照以下顺序构建3个(或N)项目:
shared.jar shared.jar
And then put the shared.jar on the path of the other war and ear files when you compile. 然后在编译时将shared.jar放在另一个war和ear文件的路径上。
app.war ejb.jar app.ear etc... app.war ejb.jar app.ear等...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.