You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Maxim Solodovnik <so...@gmail.com> on 2023/01/12 16:05:30 UTC

wicket-10 spring bean injection

Hello All,

It seems "Injector.get().inject(this);" doesn't work for me as expected

The bean annotated with @Inject or @SpringBean is injected
(WicketProxy, via ByteBuddy but it differs from what is being injected
by Spring, and all @Inject/@Autowired fields are null :(((

What can I troubleshoot?

-- 
Best regards,
Maxim

Re: wicket-10 spring bean injection

Posted by Maxim Solodovnik <so...@gmail.com>.
https://issues.apache.org/jira/browse/WICKET-7025

On Sat, 14 Jan 2023 at 12:16, Maxim Solodovnik <so...@gmail.com> wrote:
>
> It seems this line
>
> https://github.com/apache/wicket/blob/master/wicket-ioc/src/main/java/org/apache/wicket/proxy/bytebuddy/ByteBuddyProxyFactory.java#L109
>
> Should be tweaked :)
>
> from mobile (sorry for typos ;)
>
>
> On Fri, Jan 13, 2023, 23:02 Maxim Solodovnik <so...@gmail.com> wrote:
>>
>> Hello Thomas,
>>
>> here it is: https://github.com/solomax/ajax-download
>> `git clone ...`
>> `mvn clean jetty:run`
>>
>> go to http://localhost:8080
>>
>> there are 2 bittons:
>> "Spring package private"
>> "Spring public"
>>
>> One works. another one results NPE (and for whatever reason weird
>> java.lang.NoClassDefFoundError under jetty (no such errors under
>> tomcat)
>>
>> In case you will change true->false
>> https://github.com/solomax/ajax-download/blob/master/src/main/java/org/apache/WicketApplication.java#L42
>>
>> Both buttons will work
>> But there will be serialization errors
>>
>> same code works with wicket 9 (tested with our main app, haven't test
>> this quick start)
>>
>> On Fri, 13 Jan 2023 at 18:52, Thomas Matthijs <li...@selckin.be> wrote:
>> >
>> > If you can make a small project on github that can reproduce it, wouldn't mind taking a look
>> >
>> > Regards
>> >
>> > On Fri, Jan 13, 2023, at 12:37, Maxim Solodovnik wrote:
>> > > How to check why ByteBuddyInterceptor.intercept is not being called
>> > > for method call?
>> > > (the method is package private, not sure if this is important ...)
>> > >
>> > > On Fri, 13 Jan 2023 at 17:30, Maxim Solodovnik <so...@gmail.com> wrote:
>> > >>
>> > >> Lots of "java.io.NotSerializableException" in such case :(((
>> > >> Have to check wrapInProxies code ...
>> > >>
>> > >> On Fri, 13 Jan 2023 at 17:20, Maxim Solodovnik <so...@gmail.com> wrote:
>> > >> >
>> > >> > Thanks a lot!
>> > >> >
>> > >> > The problem was
>> > >> > "getComponentInstantiationListeners().add(new
>> > >> > SpringComponentInjector(this, ctx, true))"
>> > >> >
>> > >> > Works for me after changing to be
>> > >> > "getComponentInstantiationListeners().add(new
>> > >> > SpringComponentInjector(this, ctx, false))"
>> > >> >
>> > >> > investigating :)
>> > >> >
>> > >> > On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org> wrote:
>> > >> > >
>> > >> > > On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:
>> > >> > >
>> > >> > > > Hello All,
>> > >> > > >
>> > >> > > > It seems "Injector.get().inject(this);" doesn't work for me as expected
>> > >> > > >
>> > >> > > > The bean annotated with @Inject or @SpringBean is injected
>> > >> > > >
>> > >> > >
>> > >> > > Here you say @Inject injects the proxy.
>> > >> > >
>> > >> > > (WicketProxy, via ByteBuddy but it differs from what is being injected
>> > >> > > > by Spring, and all @Inject/@Autowired fields are null :(((
>> > >> > > >
>> > >> > >
>> > >> > > Here it is null...
>> > >> > > Which one is correct?
>> > >> > >
>> > >> > > Or you mean the transitive dependencies are null? If this is the case then
>> > >> > > debug in SpringBeanLocator. It uses Spring APIs to load the real bean.
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> > > > What can I troubleshoot?
>> > >> > > >
>> > >> > > > --
>> > >> > > > Best regards,
>> > >> > > > Maxim
>> > >> > > >
>> > >> >
>> > >> >
>> > >> >
>> > >> > --
>> > >> > Best regards,
>> > >> > Maxim
>> > >>
>> > >>
>> > >>
>> > >> --
>> > >> Best regards,
>> > >> Maxim
>> > >
>> > >
>> > >
>> > > --
>> > > Best regards,
>> > > Maxim
>>
>>
>>
>> --
>> Best regards,
>> Maxim



-- 
Best regards,
Maxim

Re: wicket-10 spring bean injection

Posted by Maxim Solodovnik <so...@gmail.com>.
It seems this line

https://github.com/apache/wicket/blob/master/wicket-ioc/src/main/java/org/apache/wicket/proxy/bytebuddy/ByteBuddyProxyFactory.java#L109

Should be tweaked :)

from mobile (sorry for typos ;)


On Fri, Jan 13, 2023, 23:02 Maxim Solodovnik <so...@gmail.com> wrote:

> Hello Thomas,
>
> here it is: https://github.com/solomax/ajax-download
> `git clone ...`
> `mvn clean jetty:run`
>
> go to http://localhost:8080
>
> there are 2 bittons:
> "Spring package private"
> "Spring public"
>
> One works. another one results NPE (and for whatever reason weird
> java.lang.NoClassDefFoundError under jetty (no such errors under
> tomcat)
>
> In case you will change true->false
>
> https://github.com/solomax/ajax-download/blob/master/src/main/java/org/apache/WicketApplication.java#L42
>
> Both buttons will work
> But there will be serialization errors
>
> same code works with wicket 9 (tested with our main app, haven't test
> this quick start)
>
> On Fri, 13 Jan 2023 at 18:52, Thomas Matthijs <li...@selckin.be> wrote:
> >
> > If you can make a small project on github that can reproduce it,
> wouldn't mind taking a look
> >
> > Regards
> >
> > On Fri, Jan 13, 2023, at 12:37, Maxim Solodovnik wrote:
> > > How to check why ByteBuddyInterceptor.intercept is not being called
> > > for method call?
> > > (the method is package private, not sure if this is important ...)
> > >
> > > On Fri, 13 Jan 2023 at 17:30, Maxim Solodovnik <so...@gmail.com>
> wrote:
> > >>
> > >> Lots of "java.io.NotSerializableException" in such case :(((
> > >> Have to check wrapInProxies code ...
> > >>
> > >> On Fri, 13 Jan 2023 at 17:20, Maxim Solodovnik <so...@gmail.com>
> wrote:
> > >> >
> > >> > Thanks a lot!
> > >> >
> > >> > The problem was
> > >> > "getComponentInstantiationListeners().add(new
> > >> > SpringComponentInjector(this, ctx, true))"
> > >> >
> > >> > Works for me after changing to be
> > >> > "getComponentInstantiationListeners().add(new
> > >> > SpringComponentInjector(this, ctx, false))"
> > >> >
> > >> > investigating :)
> > >> >
> > >> > On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org>
> wrote:
> > >> > >
> > >> > > On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <
> solomax666@gmail.com> wrote:
> > >> > >
> > >> > > > Hello All,
> > >> > > >
> > >> > > > It seems "Injector.get().inject(this);" doesn't work for me as
> expected
> > >> > > >
> > >> > > > The bean annotated with @Inject or @SpringBean is injected
> > >> > > >
> > >> > >
> > >> > > Here you say @Inject injects the proxy.
> > >> > >
> > >> > > (WicketProxy, via ByteBuddy but it differs from what is being
> injected
> > >> > > > by Spring, and all @Inject/@Autowired fields are null :(((
> > >> > > >
> > >> > >
> > >> > > Here it is null...
> > >> > > Which one is correct?
> > >> > >
> > >> > > Or you mean the transitive dependencies are null? If this is the
> case then
> > >> > > debug in SpringBeanLocator. It uses Spring APIs to load the real
> bean.
> > >> > >
> > >> > >
> > >> > >
> > >> > > > What can I troubleshoot?
> > >> > > >
> > >> > > > --
> > >> > > > Best regards,
> > >> > > > Maxim
> > >> > > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > Best regards,
> > >> > Maxim
> > >>
> > >>
> > >>
> > >> --
> > >> Best regards,
> > >> Maxim
> > >
> > >
> > >
> > > --
> > > Best regards,
> > > Maxim
>
>
>
> --
> Best regards,
> Maxim
>

Re: wicket-10 spring bean injection

Posted by Maxim Solodovnik <so...@gmail.com>.
Hello Thomas,

here it is: https://github.com/solomax/ajax-download
`git clone ...`
`mvn clean jetty:run`

go to http://localhost:8080

there are 2 bittons:
"Spring package private"
"Spring public"

One works. another one results NPE (and for whatever reason weird
java.lang.NoClassDefFoundError under jetty (no such errors under
tomcat)

In case you will change true->false
https://github.com/solomax/ajax-download/blob/master/src/main/java/org/apache/WicketApplication.java#L42

Both buttons will work
But there will be serialization errors

same code works with wicket 9 (tested with our main app, haven't test
this quick start)

On Fri, 13 Jan 2023 at 18:52, Thomas Matthijs <li...@selckin.be> wrote:
>
> If you can make a small project on github that can reproduce it, wouldn't mind taking a look
>
> Regards
>
> On Fri, Jan 13, 2023, at 12:37, Maxim Solodovnik wrote:
> > How to check why ByteBuddyInterceptor.intercept is not being called
> > for method call?
> > (the method is package private, not sure if this is important ...)
> >
> > On Fri, 13 Jan 2023 at 17:30, Maxim Solodovnik <so...@gmail.com> wrote:
> >>
> >> Lots of "java.io.NotSerializableException" in such case :(((
> >> Have to check wrapInProxies code ...
> >>
> >> On Fri, 13 Jan 2023 at 17:20, Maxim Solodovnik <so...@gmail.com> wrote:
> >> >
> >> > Thanks a lot!
> >> >
> >> > The problem was
> >> > "getComponentInstantiationListeners().add(new
> >> > SpringComponentInjector(this, ctx, true))"
> >> >
> >> > Works for me after changing to be
> >> > "getComponentInstantiationListeners().add(new
> >> > SpringComponentInjector(this, ctx, false))"
> >> >
> >> > investigating :)
> >> >
> >> > On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org> wrote:
> >> > >
> >> > > On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:
> >> > >
> >> > > > Hello All,
> >> > > >
> >> > > > It seems "Injector.get().inject(this);" doesn't work for me as expected
> >> > > >
> >> > > > The bean annotated with @Inject or @SpringBean is injected
> >> > > >
> >> > >
> >> > > Here you say @Inject injects the proxy.
> >> > >
> >> > > (WicketProxy, via ByteBuddy but it differs from what is being injected
> >> > > > by Spring, and all @Inject/@Autowired fields are null :(((
> >> > > >
> >> > >
> >> > > Here it is null...
> >> > > Which one is correct?
> >> > >
> >> > > Or you mean the transitive dependencies are null? If this is the case then
> >> > > debug in SpringBeanLocator. It uses Spring APIs to load the real bean.
> >> > >
> >> > >
> >> > >
> >> > > > What can I troubleshoot?
> >> > > >
> >> > > > --
> >> > > > Best regards,
> >> > > > Maxim
> >> > > >
> >> >
> >> >
> >> >
> >> > --
> >> > Best regards,
> >> > Maxim
> >>
> >>
> >>
> >> --
> >> Best regards,
> >> Maxim
> >
> >
> >
> > --
> > Best regards,
> > Maxim



-- 
Best regards,
Maxim

Re: wicket-10 spring bean injection

Posted by Thomas Matthijs <li...@selckin.be>.
If you can make a small project on github that can reproduce it, wouldn't mind taking a look

Regards

On Fri, Jan 13, 2023, at 12:37, Maxim Solodovnik wrote:
> How to check why ByteBuddyInterceptor.intercept is not being called
> for method call?
> (the method is package private, not sure if this is important ...)
>
> On Fri, 13 Jan 2023 at 17:30, Maxim Solodovnik <so...@gmail.com> wrote:
>>
>> Lots of "java.io.NotSerializableException" in such case :(((
>> Have to check wrapInProxies code ...
>>
>> On Fri, 13 Jan 2023 at 17:20, Maxim Solodovnik <so...@gmail.com> wrote:
>> >
>> > Thanks a lot!
>> >
>> > The problem was
>> > "getComponentInstantiationListeners().add(new
>> > SpringComponentInjector(this, ctx, true))"
>> >
>> > Works for me after changing to be
>> > "getComponentInstantiationListeners().add(new
>> > SpringComponentInjector(this, ctx, false))"
>> >
>> > investigating :)
>> >
>> > On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org> wrote:
>> > >
>> > > On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:
>> > >
>> > > > Hello All,
>> > > >
>> > > > It seems "Injector.get().inject(this);" doesn't work for me as expected
>> > > >
>> > > > The bean annotated with @Inject or @SpringBean is injected
>> > > >
>> > >
>> > > Here you say @Inject injects the proxy.
>> > >
>> > > (WicketProxy, via ByteBuddy but it differs from what is being injected
>> > > > by Spring, and all @Inject/@Autowired fields are null :(((
>> > > >
>> > >
>> > > Here it is null...
>> > > Which one is correct?
>> > >
>> > > Or you mean the transitive dependencies are null? If this is the case then
>> > > debug in SpringBeanLocator. It uses Spring APIs to load the real bean.
>> > >
>> > >
>> > >
>> > > > What can I troubleshoot?
>> > > >
>> > > > --
>> > > > Best regards,
>> > > > Maxim
>> > > >
>> >
>> >
>> >
>> > --
>> > Best regards,
>> > Maxim
>>
>>
>>
>> --
>> Best regards,
>> Maxim
>
>
>
> -- 
> Best regards,
> Maxim

Re: wicket-10 spring bean injection

Posted by Maxim Solodovnik <so...@gmail.com>.
How to check why ByteBuddyInterceptor.intercept is not being called
for method call?
(the method is package private, not sure if this is important ...)

On Fri, 13 Jan 2023 at 17:30, Maxim Solodovnik <so...@gmail.com> wrote:
>
> Lots of "java.io.NotSerializableException" in such case :(((
> Have to check wrapInProxies code ...
>
> On Fri, 13 Jan 2023 at 17:20, Maxim Solodovnik <so...@gmail.com> wrote:
> >
> > Thanks a lot!
> >
> > The problem was
> > "getComponentInstantiationListeners().add(new
> > SpringComponentInjector(this, ctx, true))"
> >
> > Works for me after changing to be
> > "getComponentInstantiationListeners().add(new
> > SpringComponentInjector(this, ctx, false))"
> >
> > investigating :)
> >
> > On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org> wrote:
> > >
> > > On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:
> > >
> > > > Hello All,
> > > >
> > > > It seems "Injector.get().inject(this);" doesn't work for me as expected
> > > >
> > > > The bean annotated with @Inject or @SpringBean is injected
> > > >
> > >
> > > Here you say @Inject injects the proxy.
> > >
> > > (WicketProxy, via ByteBuddy but it differs from what is being injected
> > > > by Spring, and all @Inject/@Autowired fields are null :(((
> > > >
> > >
> > > Here it is null...
> > > Which one is correct?
> > >
> > > Or you mean the transitive dependencies are null? If this is the case then
> > > debug in SpringBeanLocator. It uses Spring APIs to load the real bean.
> > >
> > >
> > >
> > > > What can I troubleshoot?
> > > >
> > > > --
> > > > Best regards,
> > > > Maxim
> > > >
> >
> >
> >
> > --
> > Best regards,
> > Maxim
>
>
>
> --
> Best regards,
> Maxim



-- 
Best regards,
Maxim

Re: wicket-10 spring bean injection

Posted by Maxim Solodovnik <so...@gmail.com>.
Lots of "java.io.NotSerializableException" in such case :(((
Have to check wrapInProxies code ...

On Fri, 13 Jan 2023 at 17:20, Maxim Solodovnik <so...@gmail.com> wrote:
>
> Thanks a lot!
>
> The problem was
> "getComponentInstantiationListeners().add(new
> SpringComponentInjector(this, ctx, true))"
>
> Works for me after changing to be
> "getComponentInstantiationListeners().add(new
> SpringComponentInjector(this, ctx, false))"
>
> investigating :)
>
> On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org> wrote:
> >
> > On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:
> >
> > > Hello All,
> > >
> > > It seems "Injector.get().inject(this);" doesn't work for me as expected
> > >
> > > The bean annotated with @Inject or @SpringBean is injected
> > >
> >
> > Here you say @Inject injects the proxy.
> >
> > (WicketProxy, via ByteBuddy but it differs from what is being injected
> > > by Spring, and all @Inject/@Autowired fields are null :(((
> > >
> >
> > Here it is null...
> > Which one is correct?
> >
> > Or you mean the transitive dependencies are null? If this is the case then
> > debug in SpringBeanLocator. It uses Spring APIs to load the real bean.
> >
> >
> >
> > > What can I troubleshoot?
> > >
> > > --
> > > Best regards,
> > > Maxim
> > >
>
>
>
> --
> Best regards,
> Maxim



-- 
Best regards,
Maxim

Re: wicket-10 spring bean injection

Posted by Maxim Solodovnik <so...@gmail.com>.
Thanks a lot!

The problem was
"getComponentInstantiationListeners().add(new
SpringComponentInjector(this, ctx, true))"

Works for me after changing to be
"getComponentInstantiationListeners().add(new
SpringComponentInjector(this, ctx, false))"

investigating :)

On Thu, 12 Jan 2023 at 23:46, Martin Grigorov <mg...@apache.org> wrote:
>
> On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:
>
> > Hello All,
> >
> > It seems "Injector.get().inject(this);" doesn't work for me as expected
> >
> > The bean annotated with @Inject or @SpringBean is injected
> >
>
> Here you say @Inject injects the proxy.
>
> (WicketProxy, via ByteBuddy but it differs from what is being injected
> > by Spring, and all @Inject/@Autowired fields are null :(((
> >
>
> Here it is null...
> Which one is correct?
>
> Or you mean the transitive dependencies are null? If this is the case then
> debug in SpringBeanLocator. It uses Spring APIs to load the real bean.
>
>
>
> > What can I troubleshoot?
> >
> > --
> > Best regards,
> > Maxim
> >



-- 
Best regards,
Maxim

Re: wicket-10 spring bean injection

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Jan 12, 2023, 18:06 Maxim Solodovnik <so...@gmail.com> wrote:

> Hello All,
>
> It seems "Injector.get().inject(this);" doesn't work for me as expected
>
> The bean annotated with @Inject or @SpringBean is injected
>

Here you say @Inject injects the proxy.

(WicketProxy, via ByteBuddy but it differs from what is being injected
> by Spring, and all @Inject/@Autowired fields are null :(((
>

Here it is null...
Which one is correct?

Or you mean the transitive dependencies are null? If this is the case then
debug in SpringBeanLocator. It uses Spring APIs to load the real bean.



> What can I troubleshoot?
>
> --
> Best regards,
> Maxim
>