I am trying to use deploy an ear with a webapp that uses an osgi bundle and exports some classes. This is in an appserver. the bundle exports class A which derivbes from class B. ClassB is really a 3rd party opensource class, which the bundle has decided to provide. The problem is my ear also has another version of classB in the ear's lib directory.
我试图使用一个使用osgi包的webapp部署一个耳朵并导出一些类。这是在appserver中。 bundle导出从类B派生的类A.ClassB实际上是一个第三方开源类,bundle决定提供它。问题是我的耳朵在ear的lib目录中还有另一个版本的classB。
On attempting to deploy the application, I am getting a strange error, the class A is loaded from osgi bundle jar, but since classB is loaded from the ear's lib directory and not from the osgi bundle, even though its there.
在尝试部署应用程序时,我收到一个奇怪的错误,A类是从osgi bundle jar加载的,但是因为classB是从ear的lib目录加载而不是从osgi bundle加载的,即使它在那里。
This is leading to errors resulting from the classA expecting some behavior to be there in its baseclass, but in reality does not exist because classB is loaded form outside the bundle.
这导致了由于classA期望某些行为存在于其基类中而导致的错误,但实际上不存在,因为classB是从bundle外部加载的。
I am not sure how to fix this- this is my first encounter with osgi and i am a little concerned that this could be worse than classpath hell, especially for apps that require integration with parts of it being osgi and parts of it not.
我不知道如何解决这个问题 - 这是我第一次遇到osgi而且我有点担心这可能比classpath地狱更糟糕,特别是对于那些需要与osgi部分集成的应用程序而且其中的部分不是。
1 个解决方案
#1
0
I know that people are trying to mix Java EE and OSGi stacks, but I think that it's a recipe for problems. They both have their own expectations for how classloaders work and getting them to cooperate can be a problem.
我知道人们正在尝试混合Java EE和OSGi堆栈,但我认为这是问题的一个方法。他们对于类加载器如何工作以及让他们进行合作都有自己的期望可能是一个问题。
If you must do this, you can make life easier for yourself by putting as much as possible of your web app in the osgi container. Alternatively, find the place where the osgi runtime is initialized and change how its parent's classloader is wired in. You can even write a custom filtering classloader that would prevent certain classes from being loaded by OSGi from webapp classloader. Many things are possible, but perhaps you don't really want to go down this path...
如果你必须这样做,你可以通过在osgi容器中尽可能多地放置你的web应用程序来让自己更轻松。或者,找到初始化osgi运行时的位置并更改其父级的类加载器的连接方式。您甚至可以编写一个自定义过滤类加载器,以防止OSGi从webapp类加载器加载某些类。很多事情都有可能,但也许你真的不想走这条道路......
#1
0
I know that people are trying to mix Java EE and OSGi stacks, but I think that it's a recipe for problems. They both have their own expectations for how classloaders work and getting them to cooperate can be a problem.
我知道人们正在尝试混合Java EE和OSGi堆栈,但我认为这是问题的一个方法。他们对于类加载器如何工作以及让他们进行合作都有自己的期望可能是一个问题。
If you must do this, you can make life easier for yourself by putting as much as possible of your web app in the osgi container. Alternatively, find the place where the osgi runtime is initialized and change how its parent's classloader is wired in. You can even write a custom filtering classloader that would prevent certain classes from being loaded by OSGi from webapp classloader. Many things are possible, but perhaps you don't really want to go down this path...
如果你必须这样做,你可以通过在osgi容器中尽可能多地放置你的web应用程序来让自己更轻松。或者,找到初始化osgi运行时的位置并更改其父级的类加载器的连接方式。您甚至可以编写一个自定义过滤类加载器,以防止OSGi从webapp类加载器加载某些类。很多事情都有可能,但也许你真的不想走这条道路......