Wicket @SpringBean doesn't create serializable proxy

梦想与她 提交于 2019-12-05 20:46:44

Do you know how the bean is being injected?

  1. Through component initialization (i.e. a Component and being filled in by the SpringComponentInjector)
  2. Some other object using InjectorHolder.getInjector().inject(this)?
  3. Injected directly by spring (i.e. this is a spring bean where the property is being set by Spring configuration)

Cases 1 and 2 would use wicket-spring integration and would wrap the bean with a wicket proxy which is serializable. Case 3 would only provide you whatever spring passes to you without wrapping.

First, make sure your bean is really proxied. By default spring does not create proxies.

Second, check your proxying strategy - whether it is proxy-target-class="true" or not. If it is false, (afaik) a reference to your object is stored in the invocation handler of the JDK proxy, and is attempted to be serialized.

So you'll need to make your class Serializable as well, if you need it to be.

Eelco

Can you double check that the instantiation listener is added in your application class:

addComponentInstantiationListener(new SpringComponentInjector(this));

Also, this only works for fields in Wicket components, not arbitrary classes.

See also wicket @SpringBean can not create bean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!