Error when filtering available entity records in Dynamic Attribute field

When applying a constraint filter to an entity type attribute a Null Pointer Exception is thrown from the instance when selecting the category. The error is not thrown when the constraint is removed from the attribute. I have attached a sample project demonstrating the problem.

Thank you,

Corey Amoruso

Hi Corey,

I couldn’t reproduce the error. I tried to create a category with Customer entity attribute. A customer entity has security in-memory constraint. The error is not thrown when selecting the category for the product.

Could you provide exception stack trace? Does the category attribute have a default value?
The configuration of category and category attribute will help with the reproduction of the error.

Thanks,
Andrey

I created two Categories, “Outsourced” on Product and “Vendor” on Customer. I then created an attribute called “Type” on Vendor (Customer) which is an integer and another attribute called “Vendor” on the Outsourced (Product) Category which is a reference to the Customer entity.

I added a constraint to the “Vendor” attribute to only allow Vendor’s (Customers) where the “Type” = 1. I did this via the Constraint Wizard.

The stack trace is as follows:

java.lang.NullPointerException: MetaClass for PickerField is not set
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:228)
	at com.haulmont.cuba.gui.dynamicattributes.FilteringLookupAction.<init>(FilteringLookupAction.java:60)
	at com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools.createLookupAction(DynamicAttributesGuiTools.java:275)
	at com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools.initEntityPickerField(DynamicAttributesGuiTools.java:219)
	at com.haulmont.cuba.gui.components.RuntimePropertiesFrame$1.generateField(RuntimePropertiesFrame.java:290)
	at com.haulmont.cuba.web.gui.components.WebFieldGroup.addCustomField(WebFieldGroup.java:444)
	at com.haulmont.cuba.web.gui.components.WebFieldGroup.addCustomField(WebFieldGroup.java:432)
	at com.haulmont.cuba.gui.components.RuntimePropertiesFrame.initCustomFields(RuntimePropertiesFrame.java:270)
	at com.haulmont.cuba.gui.components.RuntimePropertiesFrame.createRuntimeFieldGroup(RuntimePropertiesFrame.java:171)
	at com.haulmont.cuba.gui.components.RuntimePropertiesFrame.lambda$loadComponent$0(RuntimePropertiesFrame.java:140)
	at com.haulmont.bali.events.EventRouter.fireEvent(EventRouter.java:45)
	at com.haulmont.cuba.gui.data.impl.AbstractDatasource.fireStateChanged(AbstractDatasource.java:289)
	at com.haulmont.cuba.gui.data.impl.RuntimePropsDatasourceImpl.valid(RuntimePropsDatasourceImpl.java:177)
	at com.haulmont.cuba.gui.data.impl.RuntimePropsDatasourceImpl.initMetaClass(RuntimePropsDatasourceImpl.java:297)
	at com.haulmont.cuba.gui.data.impl.RuntimePropsDatasourceImpl$1.valueChanged(RuntimePropsDatasourceImpl.java:247)
	at com.haulmont.cuba.gui.data.impl.DsListenerAdapter.valueChanged(DsListenerAdapter.java:34)
	at com.haulmont.cuba.gui.data.impl.compatibility.CompatibleDatasourceListenerWrapper.itemPropertyChanged(CompatibleDatasourceListenerWrapper.java:44)
	at com.haulmont.bali.events.EventRouter.fireEvent(EventRouter.java:45)
	at com.haulmont.cuba.gui.data.impl.AbstractDatasource$ItemListener.propertyChanged(AbstractDatasource.java:307)
	at com.haulmont.chile.core.model.impl.AbstractInstance.propertyChanged(AbstractInstance.java:51)
	at com.haulmont.cuba.core.entity.CategorizedEntity.setCategory(CategorizedEntity.java:52)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.haulmont.chile.core.model.utils.MethodsCache.invokeSetter(MethodsCache.java:59)
	at com.haulmont.chile.core.model.impl.AbstractInstance.setValue(AbstractInstance.java:133)
	at com.haulmont.cuba.core.entity.BaseGenericIdEntity.setValue(BaseGenericIdEntity.java:120)
	at com.haulmont.chile.core.model.impl.AbstractInstance.setValue(AbstractInstance.java:117)
	at com.haulmont.chile.core.model.utils.InstanceUtils.setValueEx(InstanceUtils.java:179)
	at com.haulmont.cuba.web.gui.data.PropertyWrapper.setValue(PropertyWrapper.java:97)
	at com.haulmont.cuba.web.gui.components.WebLookupField$LookupPropertyAdapter.setValue(WebLookupField.java:835)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:564)
	at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:738)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:494)
	at com.vaadin.ui.ComboBox.changeVariables(ComboBox.java:750)
	at com.haulmont.cuba.web.toolkit.ui.CubaComboBox.changeVariables(CubaComboBox.java:162)
	at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:623)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:470)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:413)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1435)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:361)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:301)
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:192)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.handleNotFiltered(CubaHttpFilter.java:116)
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:103)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

Hi Corey,

Thank you for reporting the problem. We have created YouTrack issue: https://youtrack.cuba-platform.com/issue/PL-10549