[ 
https://issues.apache.org/jira/browse/CXF-2345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732471#action_12732471
 ] 

Sergey Beryozkin commented on CXF-2345:
---------------------------------------

Hi,

turns out it's a bug in SpringAopClassHelper which actually prevents the 
subresource locator method "getSubResources" from being invoked. 
<lookupMethod/> causes a double Cglib proxy being created, with the top one 
being recognized as AopProxy and the next one being not. So the fix will go in 
now.

In meantine you may want to try :

1. ensure 'getSubResources' is actually an interface method so your resource 
class just implements it
2. given that in your case you just want to apply global permissions, you might 
want just to add @RolesAllowed on the subresource method itself

thanks for stressing CXF JAX-RS so well...

> Returning AOP/CGLIB proxy as Subresource throws Fault "object is not an 
> instance of declaring class"
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2345
>                 URL: https://issues.apache.org/jira/browse/CXF-2345
>             Project: CXF
>          Issue Type: Bug
>          Components: REST
>    Affects Versions: 2.2.2
>            Reporter: Hendy Irawan
>
> Test case:
> RootResource.java :
> public class RootResource {
>   @Path("subresource")
>   public abstract SubResource getSubResource();
> }
> In spring-beans.xml:
> <bean class="RootResource">
>   <lookup-method name="getSubResource" bean="subResource" />
> </bean>
> <bean id="subResource" class="SubResource" />
> Then the AOP proxied SubResource:
> @RolesAllowed({"ROLE_USER"}) // activate Spring Security global method 
> annotations
> public class SubResource {
> }
> Getting the /subresource will throw exception:
> org.apache.cxf.interceptor.Fault: object is not an instance of declaring 
> class while invoking
> Tried this workaround but not working: Make SubResource implement an 
> interface then on RootResource.getSubResource() use interface as the return 
> type, not the class

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to