6.3.0.RC2 Group Hierachie Import Error

Hi, i found a problem with the import & export of a Group with a hierachie.

Attached you’ll find the zip file that described a group hierachie. It got created through the UI of the Groups entity. When importing it, the error occurs: “Import Error: null”
The stacktrace is as follows:


2016-10-11 11:06:28.750 ERROR [http-nio-8080-exec-18/app-core/admin] com.haulmont.cuba.core.sys.ServiceInterceptor - Exception: 
java.lang.RuntimeException: java.lang.NullPointerException
 at com.haulmont.cuba.core.sys.TransactionImpl.commit(TransactionImpl.java:101) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.app.importexport.EntityImportExport.importEntities(EntityImportExport.java:184) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.app.importexport.EntityImportExport.importEntities(EntityImportExport.java:130) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.app.importexport.EntityImportExportServiceBean.importEntities(EntityImportExportServiceBean.java:45) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
 at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:74) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at sun.reflect.GeneratedMethodAccessor121.invoke(Unknown Source) ~[na:na]
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
 at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) [spring-aop-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at com.sun.proxy.$Proxy204.importEntities(Unknown Source) [na:na]
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
 at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
 at com.haulmont.cuba.core.sys.remoting.LocalServiceInvokerImpl.invoke(LocalServiceInvokerImpl.java:95) [cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:146) [cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.sun.proxy.$Proxy46.importEntities(Unknown Source) [na:na]
 at com.haulmont.cuba.gui.app.security.group.browse.GroupBrowser.lambda$init$75(GroupBrowser.java:259) [cuba-gui-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.gui.components.WebFileUploadField.fireFileUploadSucceed(WebFileUploadField.java:436) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.gui.components.WebFileUploadField.lambda$initUploadButton$982e378a$1(WebFileUploadField.java:240) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
 at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
 at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1030) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.haulmont.cuba.web.toolkit.ui.CubaFileUpload.fireUploadSuccess(CubaFileUpload.java:481) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.toolkit.ui.CubaFileUpload$1.fileUploaded(CubaFileUpload.java:73) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
 at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
 at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:414) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:79) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.haulmont.cuba.web.sys.CubaVaadinServletService$CubaUidlRequestHandler.lambda$synchronizedHandleRequest$107(CubaVaadinServletService.java:314) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.sys.CubaVaadinServletService.withUserSession(CubaVaadinServletService.java:196) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.sys.CubaVaadinServletService$CubaUidlRequestHandler.synchronizedHandleRequest(CubaVaadinServletService.java:314) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:369) ~[vaadin-server-7.6.8.cuba.8.jar:7.6.8.cuba.8]
 at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:278) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:187) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[servlet-api.jar:na]
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.35]
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.0.35]
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.35]
 at com.haulmont.cuba.web.sys.CubaHttpFilter.handleNotFiltered(CubaHttpFilter.java:108) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:95) ~[cuba-web-6.3.0.RC2.jar:6.3.0.RC2]
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) ~[catalina.jar:8.0.35]
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) ~[catalina.jar:8.0.35]
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) ~[catalina.jar:8.0.35]
 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) ~[catalina.jar:8.0.35]
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) ~[catalina.jar:8.0.35]
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) ~[catalina.jar:8.0.35]
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) ~[tomcat-coyote.jar:8.0.35]
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) ~[tomcat-coyote.jar:8.0.35]
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) ~[tomcat-coyote.jar:8.0.35]
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) ~[tomcat-coyote.jar:8.0.35]
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_66]
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_66]
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:8.0.35]
 at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_66]
Caused by: java.lang.NullPointerException: null
 at com.haulmont.cuba.security.listener.GroupEntityListener.createNewHierarchy(GroupEntityListener.java:72) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.security.listener.GroupEntityListener.onBeforeInsert(GroupEntityListener.java:47) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.security.listener.GroupEntityListener.onBeforeInsert(GroupEntityListener.java:34) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.sys.listener.EntityListenerManager.fireListener(EntityListenerManager.java:203) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.sys.persistence.PersistenceImplSupport$OnCommitEntityVisitor.visit(PersistenceImplSupport.java:306) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.sys.persistence.PersistenceImplSupport.beforeStore(PersistenceImplSupport.java:167) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.sys.persistence.PersistenceImplSupport.traverseEntities(PersistenceImplSupport.java:154) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at com.haulmont.cuba.core.sys.persistence.PersistenceImplSupport$ContainerResourceSynchronization.beforeCommit(PersistenceImplSupport.java:247) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95) ~[spring-tx-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:932) ~[spring-tx-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:744) ~[spring-tx-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) ~[spring-tx-4.3.1.RELEASE.jar:4.3.1.RELEASE]
 at com.haulmont.cuba.core.sys.TransactionImpl.commit(TransactionImpl.java:98) ~[cuba-core-6.3.0.RC2.jar:6.3.0.RC2]
 ... 86 common frames omitted

The exceptions occurs in this line:

It seems parent.getHierarchyList() returns null, which is hard to iterate. Im not sure, why this problem occurs.

Perhaps you can have a look at it.

Bye,
Mario

wrong-group-export-file.zip (1.1K)

Thanks for finding the issue, Mario!
It is already fixed. In the next release everything should work.

Hi Max,

thanks for the info. Will there be a RC3 where it’s fixed, or will it be included in the final release?

Bye,
Mario

It will be in the final release

Hi Max,

ok, great. In the meantime, since it seems that in the master branch this line is the same: https://github.com/cuba-platform/cuba/blob/8836668c2fd0ffa88f2e91b9df6f64565c28b983/modules/core/src/com/haulmont/cuba/security/listener/GroupEntityListener.java#L72 i could imagine, that the generated JSON is wrong, right? If yes, can you tell me what i have to change in the zip file from above so that the import will work?

Bye
Mario

The problem was not in the JSON export but in the import. For now you can try to create a separate ZIP for each group and import it one by one. It should work.