Import Chart of Accounts with Web Services

Hello everyone ! I’m trying to import a chart of accounts for a Company that I succesfully created through Postman. I used the following request :

POST http://############/axelor-erp-5.0.1/ws/action   HTTP/1.1
{
	"action": "com.axelor.apps.account.web.AccountChartController:installChart",
	"data":{
		"context": {
			"accountConfig":{
				"id":3,
				"company":{
					"id":32
					},
				"accountChart":{
					"id":1
					}
				}
			}
		}
}

But i’m getting a NullPointerException, with the following trace in catalina.out :

2020-07-15 07:47:38.705 DEBUG 1222 --- [nio-8080-exec-7] c.a.meta.schema.actions.ActionGroup      : action: com.axelor.apps.account.web.AccountChartController:installChart
2020-07-15 07:47:38.706 ERROR 1222 --- [nio-8080-exec-7] com.axelor.meta.ActionHandler            : null
java.lang.reflect.InvocationTargetException: null
        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.axelor.meta.ActionHandler.call(ActionHandler.java:185)
        at com.axelor.meta.schema.actions.ActionMethod.evaluate(ActionMethod.java:76)
        at com.axelor.meta.schema.actions.Action.execute(Action.java:98)
        at com.axelor.meta.schema.actions.Action.wrap(Action.java:107)
        at com.axelor.meta.schema.actions.ActionGroup.evaluate(ActionGroup.java:230)
        at com.axelor.meta.schema.actions.Action.execute(Action.java:95)
        at com.axelor.meta.schema.actions.Action.wrap(Action.java:107)
        at com.axelor.meta.ActionHandler.execute(ActionHandler.java:453)
        at com.axelor.meta.ActionExecutor.execute(ActionExecutor.java:43)
        at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$61db7276.CGLIB$execute$3(<generated>)
        at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$61db7276$$FastClassByGuice$$b356b8c3.invoke(<generated>)
        at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:76)
        at com.axelor.rpc.ResponseInterceptor.invoke(ResponseInterceptor.java:56)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:78)
        at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:54)
        at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$61db7276.execute(<generated>)
        at com.axelor.web.service.ActionService.execute(ActionService.java:96)
        at com.axelor.web.service.ActionService$$EnhancerByGuice$$9f77eda4.CGLIB$execute$2(<generated>)
        at com.axelor.web.service.ActionService$$EnhancerByGuice$$9f77eda4$$FastClassByGuice$$7976f235.invoke(<generated>)
        at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:76)
        at com.axelor.rpc.RequestFilter.invoke(RequestFilter.java:55)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:78)
        at com.axelor.rpc.ResponseInterceptor.invoke(ResponseInterceptor.java:65)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:78)
        at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:54)
        at com.axelor.web.service.ActionService$$EnhancerByGuice$$9f77eda4.execute(<generated>)
        at sun.reflect.GeneratedMethodAccessor320.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:294)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:248)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:235)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:398)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:205)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:89)
        at com.axelor.db.tenants.AbstractTenantFilter.doFilter(AbstractTenantFilter.java:67)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at org.apache.shiro.guice.web.SimpleFilterChain.doFilter(SimpleFilterChain.java:44)
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
        at com.axelor.auth.AuthFilter.doFilterInternal(AuthFilter.java:121)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at org.apache.shiro.guice.web.SimpleFilterChain.doFilter(SimpleFilterChain.java:41)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.axelor.app.internal.AppFilter.doFilter(AppFilter.java:93)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.inject.persist.PersistFilter.doFilter(PersistFilter.java:94)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.axelor.db.tenants.AbstractTenantFilter.doFilter(AbstractTenantFilter.java:67)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.axelor.web.servlet.CorsFilter.doFilter(CorsFilter.java:132)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1627)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        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)
Caused by: java.lang.NullPointerException: null
        at com.axelor.apps.account.web.AccountChartController.installChart(AccountChartController.java:42)

I’m obviously doing something wrong but I don’t know exactly what. Thank you in advance for your help !

Here there is your problem! I think you must send something more, or some configuration missing!
Reverse engineer the issue the try to provide the data he wants!

I finally managed to correctly use the Import Chart action with advanced web services :
the correct form of the body of the request is :

POST http://############/axelor-erp-5.0.1/ws/action   HTTP/1.1
{
	"action": "action-method-account-config-install-chart",
	"data":{
		"context": {
			"_model":"com.axelor.apps.account.db.AccountConfig",
			"id":3
			}
		}
}

with id, the id of the AccountConfig object from which you’re importing the chart of accounts.

1 Like