I’ve setup a project with spring security. My Users table is modified to include a column titled fullname. I want to use fullname when displaying information on who is logged in.
I’ve added the column to the queries in the security-content.xml
<beans:property name=”usersByUsernameQuery” value=”SELECT username,password,enabled,fullname FROM Users WHERE username = ?”/>
<beans:property name=”authoritiesByUsernameQuery” value=”SELECT u.username, u.fullname, a.authorityname FROM Users u JOIN Users_Authorities ua on u.id = ua.user_id JOIN Authorities a on ua.authorities_id = a.id WHERE u.username = ?”/>
I’ve also added setter/getter to the Users.java that security created. If I then use the following command –
<sec:authentication property=”principal.fullname”/>
I then get this message –
org.apache.jasper.JasperException: org.apache.jasper.JasperException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.springframework.beans.NotReadablePropertyException: Invalid property ‘principal.fullname’ of bean class [org.springframework.security.authentication.UsernamePasswordAuthenticationToken]: Bean property ‘principal.fullname’ is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
Am I even going down the right path with this? What throws me is that the classes generated for User, UserDAO and UserDAOImpl do not show any query statements. Are they even used? Or are they placeholders in case I want to use them – and if so then I need to add the @NameQueries statements and supporting methods.