[ 
https://issues.apache.org/jira/browse/WICKET-7005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17691308#comment-17691308
 ] 

Damien Hollis commented on WICKET-7005:
---------------------------------------

[~mgrigorov] - we have hit this issue again with another {{@SpringBean}} that 
references a class rather than interface. I don't think there is anything 
special about the class being imported but here is the original class that we 
had this issue with:

 
{code:java}
public class DefaultDoubleClickPreventionSupportImpl implements 
DoubleClickPreventionSupport {

    @Autowired
    private Environment environment;

    @Override
    public void apply(@NotNull MarkupContainer markupContainer) {
        if (environment.isDoubleClickPreventionEnabled()) {
            doApply(markupContainer);
        }
    }

    void doApply(@NotNull MarkupContainer markupContainer) {
        DisableDoubleClickBehaviour.applyTo(markupContainer);
    }

    @Override
    public void applyToNonForm(@NotNull AbstractLink component, @NotNull 
AjaxRequestAttributes attributes) {
        // UnimarketAjaxLinkDisableDoubleClickListener works only on forms, for 
regular links use the channel
        if (environment.isDoubleClickPreventionEnabled() && 
component.findParent(Form.class) == null) {
            // The ajax call on client side will be discarded if there is an 
active/running request on the same channel
            // The channel is unique for each compoenent, so that we will not 
discard ajax event on the same page from different link
            attributes.setChannel(new AjaxChannel("blockingChannel" + 
component.getMarkupId(), AjaxChannel.Type.ACTIVE));
        }
    }
} {code}
Which is now not a problem because our {{@SpringBean}} now references 
{{DoubleClickPreventionSupport}} but making this change everywhere is a hassle.

This feels like some kind of race condition and I tend to agree it is probably 
in bytebuddy but there does not appear to be any outstanding issue on their 
issue tracker for this kind of thing.

Unfortunately we cannot reproduce this consistently, so it is difficult to tell 
whether a new bytebuddy will help or not (there is nothing in the bytebuddy 
release notes that indicates anything related to this issue has been fixed).

 

> ByteBuddy IllegalStateException: Cannot inject already loaded type
> ------------------------------------------------------------------
>
>                 Key: WICKET-7005
>                 URL: https://issues.apache.org/jira/browse/WICKET-7005
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-ioc
>    Affects Versions: 9.11.0
>            Reporter: Miroslav Silhavy
>            Priority: Major
>
> Sometimes we get following exception in our application. It happens during 
> our regression application tests running on parallel.
> We're running Wicket 9.11.0 with byteBuddy enabled 
> (-Dwicket.ioc.useByteBuddy=true) on Java 17. We applied a workaround by 
> changing this spring component to extend a single interface instead of being 
> sole class. When using cglib there was no issue.
>  
>  
> {code:java}
> Caused by: java.lang.RuntimeException: error while injecting object [[Page 
> class = com.project.core.web.page.login.LoginPage, id = 1, render count = 0]] 
> of type [com.project.core.web.page.login.LoginPage]
>     at org.apache.wicket.injection.Injector.inject(Injector.java:122)
>     at 
> org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
>     at 
> org.apache.wicket.spring.injection.annot.SpringComponentInjector.onInstantiation(SpringComponentInjector.java:130)
>     at 
> org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)
>     at 
> org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)
>     at 
> org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:81)
>     at 
> org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)
>     at org.apache.wicket.Component.<init>(Component.java:691)
>     at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:180)
>     at org.apache.wicket.Page.<init>(Page.java:171)
>     at org.apache.wicket.Page.<init>(Page.java:160)
>     at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:99)
>     at 
> com.project.core.web.page.base.AbstractprojectPage.<init>(AbstractprojectPage.java:64)
>     at 
> com.project.core.web.page.base.AbstractprojectPage.<init>(AbstractprojectPage.java:54)
>     at 
> com.project.core.web.page.base.projectPageImpl.<init>(projectPageImpl.java:66)
>     at 
> com.project.core.web.page.base.projectSimplePage.<init>(projectSimplePage.java:17)
>     at com.project.core.web.page.login.LoginPage.<init>(LoginPage.java:86)
>     at com.project.core.web.page.login.LoginPage.<init>(LoginPage.java:78)
>     ... 151 common frames omitted
> Caused by: java.lang.IllegalArgumentException: Could not create type
>     at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:170)
>     at 
> net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
>     at 
> org.apache.wicket.proxy.bytebuddy.ByteBuddyProxyFactory.createOrGetProxyClass(ByteBuddyProxyFactory.java:105)
>     at 
> org.apache.wicket.proxy.bytebuddy.ByteBuddyProxyFactory.createProxy(ByteBuddyProxyFactory.java:75)
>     at 
> org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:160)
>     at 
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:166)
>     at org.apache.wicket.injection.Injector.inject(Injector.java:111)
>     ... 168 common frames omitted
> Caused by: java.lang.IllegalStateException: Cannot inject already loaded 
> type: class 
> com.project.core.web.page.base.WicketProxy_DoubleClickPreventionSupport
>     at 
> net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.injectRaw(ClassInjector.java:286)
>     at 
> net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:118)
>     at 
> net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:241)
>     at 
> net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:148)
>     at 
> net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
>     at 
> net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6166)
>     at 
> org.apache.wicket.proxy.bytebuddy.ByteBuddyProxyFactory.lambda$createOrGetProxyClass$0(ByteBuddyProxyFactory.java:119)
>     at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
>     ... 174 common frames omitted
>     {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to