Unexpected "IllegalStateException: Ambiguous mappng found" thrown by Spring MVC in standalone tomcat

StackOverflow https://stackoverflow.com/questions/15575839

  •  29-03-2022
  •  | 
  •  

Question

I noticed a weird behavior in my Spring MVC application:

  • My request mappings are all unique and I am positive there are no ambiguous mappings. I can run my app fine in STS's embedded tomcat.
  • However when I drop a jar in a standalone tomcat, I systematically get an ambiguous mapping error as show below.

Stacktrace:

IllegalStateException: Ambiguous mapping found. Cannot map 'preferenceController' bean method 
public java.lang.String com.bignibou.controller.PreferenceController.modifyEmail(com.bignibou.controller.helpers.EmailInfo,org.springframework.validation.BindingResult,org.springframework.ui.Model)
to {[/preferences/email],methods=[POST],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}: There is already 'preferencesController' bean method
public java.lang.String com.bignibou.controller.PreferencesController.modifyEmail(com.bignibou.controller.helpers.EmailInfo,org.springframework.validation.BindingResult,org.springframework.ui.Model) mapped.

Has anyone seen this problem before? FYI, I run tomcat 7.0.35 and spring 3.2.

Was it helpful?

Solution

It looks like you have two different classes: PreferenceController and PreferencesController with the same method. Just delete one of the modifyEmail methods and see if it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top