[BLOSSOM-88] Annotations are not found when using cglib proxies Created: 04/May/12 Updated: 23/Aug/12 Resolved: 09/May/12 |
|
| Status: | Closed |
| Project: | Blossom |
| Component/s: | None |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | 1.2.4, 2.0.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Angel Gerdzhikov | Assignee: | Tobias Mattsson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | CGLIB, blossom, security, spring | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OS X 10.7.3, JRE 1.6.0_31-b04-415-11M3635, Tomcat 6.0.32 |
||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Date of First Response: |
| Description |
|
If you have something like this: ContentSection.java @Controller @Paragraph("ContentSection") @ParagraphDescription("Displays substructure of a section and enables creating and deleting pages and folders") public class ContentSection { @PreAuthorize("hasPermission('nodeUUID', 'uuid', T(info.magnolia.cms.security.Permission).WRITE)") @RequestMapping("/contentSection") public ModelAndView handleRequest(Content page, Content paragraph) throws RepositoryException { ... } } and Spring Security is activated, the Blossom-Paragraph is not registered and can't be found. The reason is, that the Spring Security creates a CGLIB proxy and the Paragraph annotation is not inherited. The problem is in info.magnolia.module.blossom.paragraph.ParagraphExporter.postProcessHandler(). I guess I'll have the same problem when I use the Template annotation and Spring security. Is there any workaround to handle this issue? |
| Comments |
| Comment by Angel Gerdzhikov [ 04/May/12 ] |
|
Is this a solution for the problem: http://noobjuggler.blogspot.de/2011/12/cglib-and-annotations.html |
| Comment by Tobias Mattsson [ 09/May/12 ] |
|
The problem realtes to cglib proxies, the way cglib adds its proxies is by generating a subclass and overrides all non-final methods. Many of the annotations in blossom does not have @Inherited, this is by design, so the annotation isn't found when inspecting a proxy. Furthermore the semantics for many of the method-level annotations are such that if they're overriden and the overriding method is not annotated then the annotations in the super class have no effect. This is also by design. The solution to both these problem is to expect that there might be a proxy and make sure the introspection works on the right class. This needs to be done for pararaphs, templates, dialog factories and virtual uri mappers. |