Hello, I am migrating a large CUBA project to Jmix and I’m currently getting an error whenever I try to load a page with a cubaFilter component on it. If I remove the cubaFilter or change the component to be a Jmix filter (and also convert properties to conditions, etc.) the page will work normally. Any ideas on what the issue might be?
The error:
java.lang.IllegalStateException: 'context' must implement io.jmix.ui.xml.layout.ComponentLoader.ComponentContext
at com.google.common.base.Preconditions.checkState(Preconditions.java:502)
at com.haulmont.cuba.gui.xml.layout.loaders.AbstractComponentLoader.getComponentContext(AbstractComponentLoader.java:32)
at com.haulmont.cuba.gui.xml.layout.loaders.CubaFilterLoader.loadComponent(CubaFilterLoader.java:102)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponents(ContainerLoader.java:36)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:74)
at io.jmix.ui.xml.layout.loader.AbstractBoxLoader.loadComponent(AbstractBoxLoader.java:49)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponents(ContainerLoader.java:36)
at io.jmix.ui.xml.layout.loader.ScrollBoxLayoutLoader.loadComponent(ScrollBoxLayoutLoader.java:62)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponents(ContainerLoader.java:36)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:74)
at io.jmix.ui.xml.layout.loader.GroupBoxLayoutLoader.loadComponent(GroupBoxLayoutLoader.java:64)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponents(ContainerLoader.java:36)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:74)
at io.jmix.ui.xml.layout.loader.FragmentLoader.loadComponent(FragmentLoader.java:86)
at io.jmix.ui.xml.layout.loader.FragmentComponentLoader.loadComponent(FragmentComponentLoader.java:176)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponents(ContainerLoader.java:36)
at io.jmix.ui.xml.layout.loader.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:74)
at io.jmix.ui.xml.layout.loader.WindowLoader.loadComponent(WindowLoader.java:85)
at io.jmix.ui.sys.ScreensImpl.loadWindowFromXml(ScreensImpl.java:323)
at com.haulmont.cuba.web.sys.CubaScreens.loadWindowFromXml(CubaScreens.java:555)
at io.jmix.ui.sys.ScreensImpl.createScreen(ScreensImpl.java:204)
at io.jmix.ui.sys.ScreensImpl.create(ScreensImpl.java:145)
at io.jmix.ui.menu.MenuItemCommands$ScreenCommand.createScreen(MenuItemCommands.java:230)
at com.haulmont.cuba.web.sys.CubaMenuItemCommands$CubaScreenCommand.createScreen(CubaMenuItemCommands.java:158)
at io.jmix.ui.menu.MenuItemCommands$ScreenCommand.run(MenuItemCommands.java:169)
at io.jmix.ui.menu.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:272)
at io.jmix.ui.menu.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:257)
at io.jmix.ui.component.mainwindow.impl.SideMenuImpl$MenuItemImpl.menuSelected(SideMenuImpl.java:587)
at io.jmix.ui.widget.JmixSideMenu$1.menuItemTriggered(JmixSideMenu.java:91)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:442)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:407)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:275)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:83)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1636)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:465)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at io.jmix.core.impl.logging.LogMdcFilter.doFilterInternal(LogMdcFilter.java:28)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:337)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:106)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:97)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:147)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1794)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
EvidenceFragment.java
package com.cgs.gemsra.web.screens.companyevidence;
import com.cgs.gemsra.entity.company.Company;
import com.cgs.gemsra.entity.evidence.Evidence;
import com.cgs.gemsra.web.mixins.ButtonsPanelHelper;
import com.cgs.gemsra.web.mixins.FilterHelper;
import com.cgs.gemsra.web.mixins.HasOptionalCompany;
import com.cgs.gemsra.web.screens.help.HelpScreen;
import com.haulmont.cuba.core.global.DataManager;
import com.haulmont.cuba.core.global.View;
import com.haulmont.cuba.gui.components.Filter;
import io.jmix.ui.ScreenBuilders;
import io.jmix.ui.action.BaseAction;
import io.jmix.ui.builder.ScreenBuilder;
import io.jmix.ui.component.Button;
import io.jmix.ui.component.GroupTable;
import io.jmix.ui.model.CollectionLoader;
import io.jmix.ui.screen.OpenMode;
import io.jmix.ui.screen.ScreenFragment;
import io.jmix.ui.screen.Subscribe;
import io.jmix.ui.screen.UiController;
import io.jmix.ui.screen.UiDescriptor;
import javax.inject.Inject;
import java.util.Objects;
@UiController("cgs_EvidenceFragment_main")
@UiDescriptor("evidence-fragment.xml")
public class EvidenceFragment extends ScreenFragment {
@Inject
private CollectionLoader<Evidence> companyEvidenceDl;
@Inject
private GroupTable<Evidence> groupTable;
@Inject
private ScreenBuilders screenBuilders;
private Company company;
@Inject
private DataManager dataManager;
@Subscribe
public void onInit(InitEvent event) {
// FilterHelper.collapse(filter);
}
@Subscribe
public void onAttach(AttachEvent event) {
groupTable.setItemClickAction(new BaseAction("openEditorAction")
.withHandler(actionPerformedEvent -> {
EvidenceEditModalDialog screen = screenBuilders.editor(groupTable)
.withScreenClass(EvidenceEditModalDialog.class)
.withOpenMode(OpenMode.DIALOG)
.build();
Evidence evidence = groupTable.getSingleSelected();
if (Objects.nonNull(evidence) && Objects.nonNull(evidence.getCompany())) {
Company selectedCompany = dataManager.reload(evidence.getCompany(), View.LOCAL);
screen.setCaption(selectedCompany.getName());
}
screen.show();
}));
}
}
evidence-fragment.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<fragment xmlns="http://jmix.io/schema/ui/fragment" xmlns:cuba="http://schemas.haulmont.com/cuba/screen/compatibility">
<data>
<collection id="companyEvidenceDc"
class="com.cgs.gemsra.entity.evidence.Evidence">
<fetchPlan extends="_local">
<property name="company" fetchPlan="_local"/>
</fetchPlan>
<loader id="companyEvidenceDl"/>
</collection>
</data>
<layout height="100%">
<groupBox>
<scrollBox>
<vbox id="lookupBox" margin="false,true,false,false">
<cuba:cubaFilter id="filter" dataLoader="companyEvidenceDl">
<properties include=".*"
excludeProperties="version,createTs,createdBy,updateTs,updatedBy,deleteTs,deletedBy,company,id,tenantId,externalDbId,attachment,order"
excludeRecursively="true"/>
</cuba:cubaFilter>
<groupTable id="groupTable"
width="100%"
height="440px"
dataContainer="companyEvidenceDc" textSelectionEnabled="true">
<actions>
<action id="excel" type="excelExport"/>
</actions>
<columns>
<column id="company" collapsed="true"/>
<column id="entityName"/>
<column id="jurisdiction"/>
<column id="evidenceType"/>
<column id="postedDate"/>
</columns>
<simplePagination/>
<buttonsPanel>
<button id="groupTableExcelBtn" action="groupTable.excel" stylename="gemsra-btn-border gemsra-uppercase"/>
</buttonsPanel>
</groupTable>
</vbox>
</scrollBox>
</groupBox>
</layout>
</fragment>