This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Spring security - Need to secure methods - getting error

 
Ranch Hand
Posts: 79
Eclipse IDE Spring Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to use spring security only for authorization. I am creating an object of Authentication & setting it to context:

After which - i am able to fetch same to various jsp pages in the application. Below is my security context file content - which is quite basic:

which gives compile error as:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'global-method-security'. One of '{"http://www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/ schema/beans"]}' is expected.

if I use append security tag in above (i.e. <security:global-method-security pre-post-annotations="enabled" /> ) I get runtime error as :

org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'security:global-method-security'.

Am stuck here - what I am doing wrong!
I just need to secure methods - something like:

@PreAuthorize("hasRole('ROLE_SPITTER')")
or
@Secured( {"ROLE-ADMIN"} )

Thanks for your help.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use



with the "security" before because the root namespace is not security. the error you are getting is generally because there's something missing. in my case, I was having the same error when in xsi:schemaLocation I had not included the following:


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!