Issue
I'm going back to some code I wrote back in 2016, running it now when the following controller method is invoked, it fails on the last line
@RequestMapping(value = "", method = RequestMethod.GET, produces = "text/html")
public String getCharacterSheet(@PathVariable("author") String author, @PathVariable("game") String game, @PathVariable("version") String version, Model model, HttpServletRequest request, @AuthenticationPrincipal String currentUser) {
try {
PluginDescription description = new PluginDescription(URLDecoder.decode(author, "UTF-8"),
URLDecoder.decode(game, "UTF-8"),
URLDecoder.decode(version, "UTF-8"));
Optional<GamePlugin<Character>> plugin = plugins.getPlugin(description);
if (!plugin.isPresent()) {
throw new MissingPluginException(description);
}
CharacterDataWrapper wrapper;
if (model.containsAttribute("character-wrapper")) {
The exception which occurrs is
java.lang.IllegalArgumentException: Invoked method public abstract boolean org.springframework.ui.Model.containsAttribute(java.lang.String) is no accessor method!
org.springframework.util.Assert.notNull(Assert.java:115)
org.springframework.data.projection.MapAccessingMethodInterceptor$Accessor.<init>(MapAccessingMethodInterceptor.java:97)
org.springframework.data.projection.MapAccessingMethodInterceptor.invoke(MapAccessingMethodInterceptor.java:62)
org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:75)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.data.projection.ProxyProjectionFactory$TargetAwareMethodInterceptor.invoke(ProxyProjectionFactory.java:218)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
com.sun.proxy.$Proxy134.containsAttribute(Unknown Source)
io.github.thisisnozaku.charactercreator.controllers.games.GamePagesController.getCharacterSheet(GamePagesController.java:77)
One thing I don't understand, why model is what appears to be a proxy wrapping a Map
, instead of an implementation of Model
.
Solution
I was unable to determine the real cause of this. However, when examining my Gradle dependencies, I noticed that there were multiple versions of Spring expected.
Upgrading my version of Spring Boot to the latest 1.5.x version resolved the issue.
Answered By - ThisIsNoZaku