java - CQ5. configure classloading. Why does CQ loses class metainformation (annotations)? -
itemprop = "text">
We have 2 separate OSG bundles.
The class in the first bundle that has the JSON string MyClass
. MyClass
is annotated by GSN annotation. I have a lot of problem with MyClass
is in the second bundle, and finally in debug mode I have seen that
MyClass.class.getDeclaredField ("fieldName"). Millation (annotation type.clus)
return empty.
Therefore CQ5 has opened annotations somewhere.
I made it a brand new project, copy pasteor class and myclass. This code really works normally.
Finally, we have understood that 'Myclus' and GSN were loaded by various classloaders and we have cured the classloader and the problem only after loading the GSN. But this is a very strange solution.
What do you think about it?
How does this fix it more beautiful?
There are two places where your bundle can import the GSON dependency:
- It can be placed in the OSGI container as a standalone bundle,
- It can be embedded.
To find out which is true in your case, open the bundle in Apache Felix Console and in the imported package section com.google.gson < / Code>. If it does:
com.google.gson, version = 2.2.4 com.google.gson (343)
This means that your The bundle imports from the GSON Standalone Bundle 343 (Case 1). On the other hand, if there is no such entry, you can find the name of the GSON Jar:
GSN-2.2.4.jar
in < Em> Bundle Cells , that means you are embedting GSOn in your bundle (Case 2).
You came to know that the cause of the problem is that loaded by the different class loaders of the GSOn library in bundle 1 and bundle 2 means that the embedded version of the library instead of at least one bundle standalone (case 1) (Case 2). To fix this, you will need to review the Mewen-bundle-plugin
in the instructions of pom.xml
and remove GSN from there. You can also go to & lt; Dependencies & gt;
section. In provided
in the
Comments
Post a Comment