wicket 9: Caused by: java.io.NotSerializableException: com.my.gui.event.MyEvent - wicket
I'm using event to indicate to other parts of a system that an action needs to be
performed.
public class MyEvent {
private final AjaxRequestTarget target;
private final LoadableDetachableModel<MyItem> item;
private final LoadableDetachableModel<ToolbarModel> myToolbar;
public MyEvent(AjaxRequestTarget target, MyItem item,
MyToolbar myToolbar) {
this.target = target;
this.item = LoadableDetachableModel.of(() -> item);
this.myToolbar = LoadableDetachableModel.of(() -> myToolbar);
}
public LoadableDetachableModel<MyToolbar> getMyToolbar() {
return myToolbar;
}
public AjaxRequestTarget getTarget() {
return target;
}
public LoadableDetachableModel<MyItem> getItem() {
return item;
}
}
I send this event using a piece of code
...
send(component, Broadcast.EXACT,new MyEvent(target, item, myToolbar));
...
and I catch this event using
#Override
public void onEvent(IEvent<?> event) {
super.onEvent(event);
if (event.getPayload() instanceof MyEvent) {
performAction((MyEvent) event.getPayload());
}
}
However, I'm experiencing an error / exception
java.lang.IllegalArgumentException: Argument 'data' may not be null.
at org.apache.wicket.util.lang.Args.notNull(Args.java:41) ~[wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.SerializedPage.<init>(SerializedPage.java:64) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.SerializingPageStore.addPage(SerializingPageStore.java:80) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.CachingPageStore.addPage(CachingPageStore.java:73) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.RequestPageStore.detach(RequestPageStore.java:114) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.page.PageManager.detach(PageManager.java:91) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.Application$2.onDetach(Application.java:1582) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:105) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:101) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.util.listener.ListenerCollection$1.notify(ListenerCollection.java:120) [wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.util.listener.ListenerCollection.reversedNotify(ListenerCollection.java:144) [wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.util.listener.ListenerCollection.reversedNotifyIgnoringExceptions(ListenerCollection.java:113) [wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycleListenerCollection.onDetach(RequestCycleListenerCollection.java:100) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycle.onDetach(RequestCycle.java:670) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycle.detach(RequestCycle.java:625) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:285) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:208) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:307) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:121) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) [spring-boot-actuator-2.5.0.jar:2.5.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.46.jar:9.0.46]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.46.jar:9.0.46]
at java.lang.Thread.run(Thread.java:834) [?:?]
and
org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream$ObjectCheckException: The object type is not Serializable!
A problem occurred while checking object with type: com.my.gui.event.MyEvent
Field hierarchy is:
0 [class=com.my.gui.my.page, path=0]
private java.lang.Object org.apache.wicket.MarkupContainer.children [class=java.util.ArrayList]
private java.lang.Object org.apache.wicket.MarkupContainer.children[write:20][write:21] [class=com.my.gui.event.pagePanel, path=0:tablePanel]
java.lang.Object org.apache.wicket.Component.data [class=[Ljava.lang.Object;]
java.lang.Object org.apache.wicket.Component.data[0] [class=org.apache.wicket.model.LoadableDetachableModel]
final org.danekja.java.util.function.serializable.SerializableSupplier org.apache.wicket.model.LoadableDetachableModel$1.val$getter [class=com.my.gui.my.page$$Lambda$1236/0x0000000800c56c40]
private final java.lang.Object[] java.lang.invoke.SerializedLambda.capturedArgs [class=[Ljava.lang.Object;]
private final java.lang.Object[] java.lang.invoke.SerializedLambda.capturedArgs[0] [class=com.my.gui.event.MyEvent] <----- field that is causing the problem
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:371) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:413) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.checkFields(CheckingObjectOutputStream.java:607) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:545) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.checkFields(CheckingObjectOutputStream.java:607) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:545) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:413) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.checkFields(CheckingObjectOutputStream.java:607) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:545) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream$1InterceptingObjectOutputStream.replaceObject(CheckingObjectOutputStream.java:501) ~[wicket-core-9.4.0.jar:9.4.0]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1145) ~[?:?]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349) ~[?:?]
at java.util.ArrayList.writeObject(ArrayList.java:897) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor56.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1145) ~[?:?]
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1497) ~[?:?]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1433) ~[?:?]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1179) ~[?:?]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349) ~[?:?]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:509) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.checkFields(CheckingObjectOutputStream.java:607) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:545) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.check(CheckingObjectOutputStream.java:354) ~[wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.writeObjectOverride(CheckingObjectOutputStream.java:711) ~[wicket-core-9.4.0.jar:9.4.0]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345) ~[?:?]
at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:394) ~[wicket-core-9.4.0.jar:9.4.0]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345) ~[?:?]
at org.apache.wicket.serialize.java.JavaSerializer.serialize(JavaSerializer.java:97) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.SerializingPageStore.addPage(SerializingPageStore.java:80) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.CachingPageStore.addPage(CachingPageStore.java:73) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.pageStore.RequestPageStore.detach(RequestPageStore.java:114) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.page.PageManager.detach(PageManager.java:91) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.Application$2.onDetach(Application.java:1582) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:105) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:101) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.util.listener.ListenerCollection$1.notify(ListenerCollection.java:120) [wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.util.listener.ListenerCollection.reversedNotify(ListenerCollection.java:144) [wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.util.listener.ListenerCollection.reversedNotifyIgnoringExceptions(ListenerCollection.java:113) [wicket-util-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycleListenerCollection.onDetach(RequestCycleListenerCollection.java:100) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycle.onDetach(RequestCycle.java:670) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.request.cycle.RequestCycle.detach(RequestCycle.java:625) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:285) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:208) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:307) [wicket-core-9.4.0.jar:9.4.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:121) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) [spring-security-web-5.5.0.jar:5.5.0]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) [spring-web-5.3.7.jar:5.3.7]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.3.7.jar:5.3.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) [spring-boot-actuator-2.5.0.jar:2.5.0]
at
org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:383) ~[wicket-core-9.4.0.jar:9.4.0]
... 87 more
As I understand I do get this error / exception, because myEvent is not serializable, do I have to make events serializable? To me it makes no sense to serialize events. Is there a wicket way to avoid these two issues (see stacktraces)? What to do?
Since your event keeps LoadableDetachable models, I assume that some of your listening components will use them as their own model:
public void performAction(MyEvent event) {
setModel(event.getItem());
}
As the stacktrace clearly shows, it is the SerializableSupplier lambda you give to LoadableDetachableModel.of(), that keeps a reference to the surrounding event class.
Drop the LoadableDetachableModels. They don't make sense, since the objects inside them are already there and won't be 'loaded' anyways.
Related
FLUTTER Error: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
I got this problem when I use NoSQL Hive and in the pubspec.yaml file I set upped the path_provider package. I ran the flutter pub get and tried to reinstall all packages and flutter clean but it's still got this error. Error: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider) C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_ packages/flutter/src/services/platform_channel.dart 313:7 _invokeMethod C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn> C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1660:54 runUnary C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 147:18 handleValue C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 767:44 handleValueCallback C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 796:13 _propagateToListeners C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 567:5 [_completeWithValue] C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 640:7 callback C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15 <fn> This is my main file: void main() async { WidgetsFlutterBinding.ensureInitialized(); var directory = await getApplicationDocumentsDirectory(); Hive.init(directory.path); runApp( DevicePreview( enabled: !kReleaseMode, builder: (context) => MyApp(), // Wrap your app ), ); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. #override Widget build(BuildContext context) { return MaterialApp( useInheritedMediaQuery: true, locale: DevicePreview.locale(context), builder: DevicePreview.appBuilder, home: HomeScreen(), ); } }
Google SignIn Flutter Error: Assertion Failed
I am creating a fLutter app and I am trying to login using Firebase google_sign_in. But I am getting some error: Assertion Failed That's my function: void signInWithGoogle() async { final GoogleSignIn _googleSignIn = GoogleSignIn(); try { GoogleSignInAccount? account = await _googleSignIn.signIn(); if (account != null) { final GoogleSignInAuthentication _authAccount = await account.authentication; final AuthCredential _credential = GoogleAuthProvider.credential( idToken: _authAccount.idToken, accessToken: _authAccount.accessToken, ); UserCredential userCredential = await _auth.signInWithCredential(_credential); userCredential.user; await saveUser(account); } } on Exception catch (error) { AppLogger.e(error); } } saveUser(GoogleSignInAccount account) { userRf.doc(account.email).set({ "email": account.email, "name": account.displayName, "profilepic": account.photoUrl, }); } Error: Assertion failed: ..\…\lib\google_sign_in_web.dart:89 C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_ C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed packages/google_sign_in_web/google_sign_in_web.dart 89:20 initWithParams C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/google_sign_in_web/google_sign_in_web.dart 86:30 initWithParams packages/google_sign_in/google_sign_in.dart 290:39 [_ensureInitialized] packages/google_sign_in/google_sign_in.dart 271:11 _callMethod C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody _addMethodCall <fn> C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/pointer_binding.dart 594:14 <fn> C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/pointer_binding.dart 288:16 loggedHandler C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/pointer_binding.dart 179:80 <fn> C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14 _checkAndCall C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39 dcall I am new to Flutter. Please help me out.
Google Mobile Ads Throwing MissingPluginException
RewardedAd doesn't work on google_mobile_ads: 2.0.1 I've already searched everywhere and the fixes don't work. This is the Error on The Logs. E/DartMessenger( 5002): Uncaught exception in binary message listener E/DartMessenger( 5002): java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map E/DartMessenger( 5002): at io.flutter.plugins.googlemobileads.AdMessageCodec.readValueOfType(AdMessageCodec.java:231) E/DartMessenger( 5002): at io.flutter.plugin.common.StandardMessageCodec.readValue(StandardMessageCodec.java:340) E/DartMessenger( 5002): at io.flutter.plugin.common.StandardMessageCodec.readValueOfType(StandardMessageCodec.java:434) E/DartMessenger( 5002): at io.flutter.plugins.googlemobileads.AdMessageCodec.readValueOfType(AdMessageCodec.java:319) E/DartMessenger( 5002): at io.flutter.plugin.common.StandardMessageCodec.readValue(StandardMessageCodec.java:340) E/DartMessenger( 5002): at io.flutter.plugin.common.StandardMethodCodec.decodeMethodCall(StandardMethodCodec.java:51) E/DartMessenger( 5002): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:260) E/DartMessenger( 5002): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/DartMessenger( 5002): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:319) E/DartMessenger( 5002): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12) E/DartMessenger( 5002): at android.os.Handler.handleCallback(Handler.java:883) E/DartMessenger( 5002): at android.os.Handler.dispatchMessage(Handler.java:100) E/DartMessenger( 5002): at android.os.Looper.loop(Looper.java:237) E/DartMessenger( 5002): at android.app.ActivityThread.main(ActivityThread.java:7830) E/DartMessenger( 5002): at java.lang.reflect.Method.invoke(Native Method) E/DartMessenger( 5002): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E/DartMessenger( 5002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1040) E/flutter ( 5002): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method loadRewardedAd on channel plugins.flutter.io/google_mobile_ads) E/flutter ( 5002): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7) E/flutter ( 5002): <asynchronous suspension> E/flutter ( 5002): #1 RewardedAd.load (package:google_mobile_ads/src/ad_containers.dart:1154:5) E/flutter ( 5002): <asynchronous suspension> E/flutter ( 5002): I already Ad this code on MainActivity override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); } I made sure also to put this on build.gradle implementation 'com.google.android.gms:play-services-ads:21.1.0' I also add this to manifest file <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713" /> This is my implementation I added this on my main final initFuture = MobileAds.instance.initialize(); final adState = AdState(initFuture); And Created another File for AdState static String get rewardedAdUnitId { if (Platform.isAndroid) { return "ca-app-pub-3940256099942544/5224354917"; } else if (Platform.isIOS) { return "ca-app-pub-3940256099942544/1712485313"; } else { throw new UnsupportedError("Unsupported platform"); } } Future initialization; AdState(this.initialization); On my Implementation void loadRewardedAd(BuildContext context) { RewardedAd.load( adUnitId: AdState.rewardedAdUnitId, request: const AdRequest(), rewardedAdLoadCallback: RewardedAdLoadCallback(onAdLoaded: (ad) { ad.show( onUserEarnedReward: (ad,rewardPoints){ CommonTools.showMessage(context, 'Energy Received : '); } ); ad.fullScreenContentCallback = FullScreenContentCallback( onAdShowedFullScreenContent: (ad){ }, onAdFailedToShowFullScreenContent: (ad,error){ CommonTools.showMessage(context, 'Ads Not Available For Now'); ad.dispose(); }, onAdDismissedFullScreenContent: (ad){ CommonTools.showMessage(context, 'Ads Not Available For Now'); ad.dispose(); } ); }, onAdFailedToLoad: (er) { CommonTools.showMessage(context, 'Ads Not Available For Now'); })); }
After making this issue traumatize me I managed to make it work. What I did is wrap everything in MaterialApp and put routes on my main Widget. runApp( MaterialApp( routes: <String, WidgetBuilder>{ '/': (BuildContext context) => MyApp() }, ), ); As for how this works, I don't know how it fix everything but it might help you if you encounter this issue.
The above Main Activity code is for kotlin. Make sure your Main Activity is also in Kotlin.
Flutter test , stubbing a method that uses dartz fails
Here's the implicated methods of the cubit I'm testing: void authCheck() { if (_authUser != null) { emit(AuthState.authenticated(_authUser!)); if (kDebugMode) { // ignore: avoid_print print(_authUser!); } } else { emit(const AuthState.unauthenticated()); signInAnonymously(); } } Future<void> signInAnonymously() async { final either = await _authRepository.signInAnonymously(); either.fold( (failure) => _showFailureToast(failure), (auth) => emit(AuthState.authenticated(_authUser!)), ); } I'm testing the unauthenticated part of authCheck, here's the test: blocTest('should emit [Unauthenticated] when user is not authenticated', build: () { when(authCubit.signInAnonymously()) .thenAnswer((_) => Future.value(null)); when(mockIAuthRepository.getSignedInUser()).thenReturn(null); return authCubit; }, act: (AuthCubit authcubit) { authcubit.authCheck(); }, expect: () => [const AuthState.unauthenticated()]); But when stubbing authCubit.signInAnonymously to return a Future<void> I get this error: UnimplementedError: fold package:test_api Fake.noSuchMethod package:dartz/src/either.dart 8:5 _FakeEither_0.fold package:mage_duel/application/auth/auth_cubit.dart 38:12 AuthCubit.signInAnonymously ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper test/application/auth/auth_cubit_test.dart 51:26 main.<fn>.<fn> package:bloc_test/src/bloc_test.dart 196:29 testBloc.<fn>.<fn> ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:bloc_test/src/bloc_test.dart testBloc.<fn>.<fn> dart:async runZonedGuarded package:bloc_test/src/bloc_test.dart 192:13 testBloc.<fn> package:bloc_test/src/bloc_test.dart 191:5 testBloc.<fn> dart:async runZoned package:bloc/src/bloc_overrides.dart 46:26 BlocOverrides.runZoned package:bloc_test/src/bloc_test.dart 190:23 testBloc package:bloc_test/src/bloc_test.dart 156:13 blocTest.<fn> package:bloc_test/src/bloc_test.dart 155:5 blocTest.<fn> type 'Future<void>' is not a subtype of type 'Future<Either<AuthFailure, Unit>>' in type cast test/application/auth/auth_cubit_test.mocks.dart 50:11 MockIAuthRepository.signInAnonymously package:mage_duel/application/auth/auth_cubit.dart 37:42 AuthCubit.signInAnonymously package:mage_duel/application/auth/auth_cubit.dart 32:7 AuthCubit.authCheck test/application/auth/auth_cubit_test.dart 57:21 main.<fn>.<fn> package:bloc_test/src/bloc_test.dart 201:24 testBloc.<fn>.<fn> ===== asynchronous gap =========================== dart:async _completeOnAsyncError package:mage_duel/application/auth/auth_cubit.dart AuthCubit.signInAnonymously package:mage_duel/application/auth/auth_cubit.dart 32:7 AuthCubit.authCheck test/application/auth/auth_cubit_test.dart 57:21 main.<fn>.<fn> package:bloc_test/src/bloc_test.dart 201:24 testBloc.<fn>.<fn> ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:bloc_test/src/bloc_test.dart testBloc.<fn>.<fn> dart:async runZonedGuarded package:bloc_test/src/bloc_test.dart 192:13 testBloc.<fn> package:bloc_test/src/bloc_test.dart 191:5 testBloc.<fn> dart:async runZoned package:bloc/src/bloc_overrides.dart 46:26 BlocOverrides.runZoned package:bloc_test/src/bloc_test.dart 190:23 testBloc package:bloc_test/src/bloc_test.dart 156:13 blocTest.<fn> package:bloc_test/src/bloc_test.dart 155:5 blocTest.<fn>
Can't play sound in Flutter Android using just_audio
So, I'm trying to have this sound from Flutter assets when I click the button. And I've tried many different packages by this moment and none of them seems to work for me. I'm constantly getting this: D/ViewRootImpl( 8796): enqueueInputEventMotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=582.0, y[0]=1570.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=48512196, downTime=48512196, deviceId=-1, source=0x1002, displayId=0 } D/ViewRootImpl[MainActivity]( 8796): processMotionEvent MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=582.0, y[0]=1570.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=48512196, downTime=48512196, deviceId=-1, source=0x1002, displayId=0 } D/ViewRootImpl[MainActivity]( 8796): dispatchPointerEvent handled=true, event=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=582.0, y[0]=1570.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=48512196, downTime=48512196, deviceId=-1, source=0x1002, displayId=0 } W/Choreographer( 8796): Frame time is 0.144734 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. D/ViewRootImpl[MainActivity]( 8796): processMotionEvent MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=582.0, y[0]=1570.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=48512312, downTime=48512196, deviceId=-1, source=0x1002, displayId=0 } D/ViewRootImpl[MainActivity]( 8796): dispatchPointerEvent handled=true, event=MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=582.0, y[0]=1570.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=48512312, downTime=48512196, deviceId=-1, source=0x1002, displayId=0 } I/ExoPlayerImpl( 8796): Init e31da6b [ExoPlayerLib/2.13.1] [RMX2025CN, RMX2025, realme, 30] D/AudioManager( 8796): getStreamVolume packageName=com.example.dicee_v2_red, index=14, streamType=3 E/ExoPlayerImplInternal( 8796): Playback error E/ExoPlayerImplInternal( 8796): com.google.android.exoplayer2.ExoPlaybackException: Source error E/ExoPlayerImplInternal( 8796): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:579) E/ExoPlayerImplInternal( 8796): at android.os.Handler.dispatchMessage(Handler.java:102) E/ExoPlayerImplInternal( 8796): at android.os.Looper.loop(Looper.java:260) E/ExoPlayerImplInternal( 8796): at android.os.HandlerThread.run(HandlerThread.java:67) E/ExoPlayerImplInternal( 8796): Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (Mp3Extractor, FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, JpegExtractor) could read the stream. E/ExoPlayerImplInternal( 8796): at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92) E/ExoPlayerImplInternal( 8796): at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1026) E/ExoPlayerImplInternal( 8796): at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415) E/ExoPlayerImplInternal( 8796): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/ExoPlayerImplInternal( 8796): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/ExoPlayerImplInternal( 8796): at java.lang.Thread.run(Thread.java:923) E/AudioPlayer( 8796): TYPE_SOURCE: None of the available extractors (Mp3Extractor, FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, JpegExtractor) could read the stream. E/flutter ( 8796): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: (0) Source error E/flutter ( 8796): #0 AudioPlayer._load (package:just_audio/just_audio.dart:716:9) E/flutter ( 8796): <asynchronous suspension> E/flutter ( 8796): #1 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1096:28) E/flutter ( 8796): <asynchronous suspension> E/flutter ( 8796): I/ExoPlayerImpl( 8796): Release e31da6b [ExoPlayerLib/2.13.1] [RMX2025CN, RMX2025, realme, 30] [goog.exo.core] But when I load my app in Web, it works perfectly fine. Why? My code: import 'package:flutter/material.dart'; import 'dart:math'; import 'package:flutter/services.dart'; import 'package:just_audio/just_audio.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) .then((_) { runApp( MaterialApp( home: Scaffold( backgroundColor: Colors.red, appBar: AppBar( title: Text('Dicee'), backgroundColor: Colors.blue.shade300, ), body: NewDice(), ), ), ); }); } class NewDice extends StatefulWidget { #override _NewDiceState createState() => _NewDiceState(); } class _NewDiceState extends State<NewDice> { late AudioPlayer player; #override void initState() { super.initState(); player = AudioPlayer(); } #override void dispose() { player.dispose(); super.dispose(); } int leftDiceNumber = 1; int rightDiceNumber = 1; #override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( children: [ Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: Image.asset('assets/dice$leftDiceNumber.png'), ), ), Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: Image.asset('assets/dice$rightDiceNumber.png'), ), ), ], ), ElevatedButton( onPressed: () async { await player.setAsset('audio/roll.mp3'); player.play(); setState(() { rightDiceNumber = Random().nextInt(6) + 1; leftDiceNumber = Random().nextInt(6) + 1; }); }, style: ElevatedButton.styleFrom( primary: Colors.blue.shade300, ), child: Text('Roll the dice!', style: TextStyle( fontSize: 18, )), ), ], ); } } Please help :) I have also tried flutter_audio_player 0.1.2 and many other packages... none seems to work... tried audiofileplayer 2.0.1, another bug now... I/AudiofileplayerPlugin(11305): onMethodCall: method = load I/AudiofileplayerPlugin(11305): onMethodCall: method = play E/MethodChannel#audiofileplayer(11305): Failed to handle method call E/MethodChannel#audiofileplayer(11305): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.flutter.plugins.audiofileplayer.ManagedMediaPlayer.play(boolean, int)' on a null object reference E/MethodChannel#audiofileplayer(11305): at com.google.flutter.plugins.audiofileplayer.AudiofileplayerPlugin.onMethodCall(AudiofileplayerPlugin.java:256) E/MethodChannel#audiofileplayer(11305): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/MethodChannel#audiofileplayer(11305): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/MethodChannel#audiofileplayer(11305): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) E/MethodChannel#audiofileplayer(11305): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#audiofileplayer(11305): at android.os.MessageQueue.next(MessageQueue.java:335) E/MethodChannel#audiofileplayer(11305): at android.os.Looper.loop(Looper.java:183) E/MethodChannel#audiofileplayer(11305): at android.app.ActivityThread.main(ActivityThread.java:7656) E/MethodChannel#audiofileplayer(11305): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#audiofileplayer(11305): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/MethodChannel#audiofileplayer(11305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/DartMessenger(11305): Uncaught exception in binary message listener E/DartMessenger(11305): java.lang.IllegalStateException: Reply already submitted E/DartMessenger(11305): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155) E/DartMessenger(11305): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:253) E/DartMessenger(11305): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/DartMessenger(11305): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) E/DartMessenger(11305): at android.os.MessageQueue.nativePollOnce(Native Method) E/DartMessenger(11305): at android.os.MessageQueue.next(MessageQueue.java:335) E/DartMessenger(11305): at android.os.Looper.loop(Looper.java:183) E/DartMessenger(11305): at android.app.ActivityThread.main(ActivityThread.java:7656) E/DartMessenger(11305): at java.lang.reflect.Method.invoke(Native Method) E/DartMessenger(11305): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/DartMessenger(11305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/flutter (11305): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(AudioPluginError, Could not create ManagedMediaPlayer:flutter_assets/assets/audio/roll2.wav, null, null) E/flutter (11305): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7) E/flutter (11305): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) E/flutter (11305): <asynchronous suspension> E/flutter (11305): #2 Audio._sendMethodCall (package:audiofileplayer/audiofileplayer.dart:751:7) E/flutter (11305): <asynchronous suspension> E/flutter (11305): #3 Audio._load (package:audiofileplayer/audiofileplayer.dart:433:7) E/flutter (11305): <asynchronous suspension> E/flutter (11305): E/flutter (11305): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(AudioPluginError, Called play on an unloaded player: 8dbbdf54-e262-4c2a-af1c-e6cbff1ac399, null, null) E/flutter (11305): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7) E/flutter (11305): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) E/flutter (11305): <asynchronous suspension> E/flutter (11305): #2 Audio._sendMethodCall (package:audiofileplayer/audiofileplayer.dart:751:7) E/flutter (11305): <asynchronous suspension> E/flutter (11305): #3 Audio._playNative (package:audiofileplayer/audiofileplayer.dart:661:7) E/flutter (11305): <asynchronous suspension> E/flutter (11305): #4 Audio._playHelper (package:audiofileplayer/audiofileplayer.dart:556:5) E/flutter (11305): <asynchronous suspension> E/flutter (11305): #5 Audio.play (package:audiofileplayer/audiofileplayer.dart:517:5) E/flutter (11305): <asynchronous suspension> E/flutter (11305):
I had this issue and it was due to a bad MP3 file (that apparently Chrome knows how to play but ExoPlayer does not). I verified this by swapping in a known good MP3: flutter.github.io/samples/game_template/assets/sfx/dsht1.mp3 . Try replacing your file with that and see if it works.
just_audio package has some issues with some emulators. You can create another emulator and probably it will work.