java - Spring expression cannot resolve type -
i have service method annotated @postauthorize
@postauthorize("haspermission(returnobject, new readuserpermission())") public optional<user> find(string email) { // implementation }
as method gets called, spring throws following exceptions:
caused by: org.springframework.expression.spel.spelevaluationexception: el1003e:(pos 28): problem occurred whilst attempting construct object of type 'readuserpermission' using arguments '()' @ org.springframework.expression.spel.ast.constructorreference.findexecutorforconstructor(constructorreference.java:190) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.ast.constructorreference.createnewinstance(constructorreference.java:151) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.ast.constructorreference.getvalueinternal(constructorreference.java:94) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.ast.methodreference.getarguments(methodreference.java:147) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.ast.methodreference.getvalueinternal(methodreference.java:79) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.ast.spelnodeimpl.gettypedvalue(spelnodeimpl.java:113) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.standard.spelexpression.getvalue(spelexpression.java:105) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.security.access.expression.expressionutils.evaluateasboolean(expressionutils.java:11) ~[spring-security-core-3.1.2.release.jar:3.1.2.release] ... 86 common frames omitted caused by: org.springframework.expression.accessexception: failed resolve constructor @ org.springframework.expression.spel.support.reflectiveconstructorresolver.resolve(reflectiveconstructorresolver.java:121) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.ast.constructorreference.findexecutorforconstructor(constructorreference.java:181) ~[spring-expression-4.0.0.release.jar:4.0.0.release] ... 93 common frames omitted caused by: org.springframework.expression.spel.spelevaluationexception: el1005e:(pos 0): type cannot found 'readuserpermission' @ org.springframework.expression.spel.support.standardtypelocator.findtype(standardtypelocator.java:81) ~[spring-expression-4.0.0.release.jar:4.0.0.release] @ org.springframework.expression.spel.support.reflectiveconstructorresolver.resolve(reflectiveconstructorresolver.java:61) ~[spring-expression-4.0.0.release.jar:4.0.0.release] ... 94 common frames omitted
readuserpermission
looks this:
@component public class readuserpermission implements permission<user> { @override public boolean haspermission(user user, user target) { // implementation } }
at first, neither class readuserpermission
nor interface permission
annotated @component
. thought maybe springs needs annotation find type not matter if annotate interface or class or both. exception same.
i overlooked part of documentation:
constructors can invoked using new operator. fully qualified class name should used primitive type , string (where int, float, etc, can used)
Comments
Post a Comment