Hi Peter
Thanks for the reply. I am actually testing the code of chapter 5 of your book on Spring Security 3.
I do remember @PreAuthorize("hasRole('ROLE_ADMIN')") working from Interface IUserService.java when i tested it first but now when I am testing it again, it doesnt seem to be working the way it is supposed to, i.e. @PreAuthorize is not being detected either.
If I use the security namespace from dogstore-security.xml, I am being shown an error saying:
Code:
Referenced file contains errors (http://www.springframework.org/schema/security/spring-security-3.0.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
, which on further look up says
Code:
XML document structure must start and end within the same entity on line number 517
where number of lines in my dogstore-security.xml file is 80 only.
But if use the namespace as below:
Code:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
...
</beans:beans>
.. it gives me an error
Code:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You cannot use a spring-security-2.0.xsd schema with Spring Security 3.0. Please update your schema declarations to the 3.0 schema.
The code that I am using is the code that came with the book Spring Security 3 only, so..
1> Do you have any other annotations that _are_ working?
-- I did see @PreAuthorize("hasRole('ROLE_ADMIN')") from Interface IUserService.java working earlier from chapter 5 but even this one doesnt seem to work anymore.
2> Are you making a call to this interface from another method in the same class?
-- No, I am calling it from the method getCategories() in HomeController.java
3> Are you instantiating this bean using Spring DI?
--Yes, the bean is being instantiated using DI only.
4> Have you enabled DEBUG logging for org.springframework.security?
-- It has been configured in the log4j.xml file you provided with the code.
Could this be cause of the error that I am getting in the security config file? The application runs but it is not detecting the annotations for security.
I wonder what was making @PreAuthorize work earlier?
I wonder what am I missing here?
Thanks