Malformed JSON when sending empty form fields in Flowable

Hi,
I have implemented with the Flowable Modeler a process that obtains data from a form and sends it through an HTTP request to an Apache Tomcat server. However, if I don’t field all the fields (and I leave empty any of the ones that are not required), it is detected as malformation and throws the next error:

<!doctype html>HTTP Status 500 – Internal Server Errorh1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a a.name .line {height:1px;background-color:#525D76;border:none;}

HTTP Status 500 – Internal Server Error


Type Exception Report

Message com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unexpected value at line 3 column 17 path .type</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>javax.servlet.ServletException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unexpected value at line 3 column 17 path .type org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:423) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Root Cause

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unexpected value at line 3 column 17 path $.type com.google.gson.Gson.fromJson(Gson.java:902) com.google.gson.Gson.fromJson(Gson.java:852) com.kta.b2a.b2a.util.GsonMessageBodyHandler.readFrom(GsonMessageBodyHandler.java:55) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:260) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:236) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156) org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:74) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156) org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085) org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:853) org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:270) org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider$EntityValueFactory.provide(EntityParamValueFactoryProvider.java:96) org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81) org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:127) org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:308) org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) org.glassfish.jersey.internal.Errors.process(Errors.java:315) org.glassfish.jersey.internal.Errors.process(Errors.java:297) org.glassfish.jersey.internal.Errors.process(Errors.java:267) org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291) org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140) org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:403) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 

Root Cause

com.google.gson.stream.MalformedJsonException: Unexpected value at line 3 column 17 path $.type com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559) com.google.gson.stream.JsonReader.doPeek(JsonReader.java:564) com.google.gson.stream.JsonReader.peek(JsonReader.java:425) com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:409) com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:406) com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) com.google.gson.Gson.fromJson(Gson.java:887) com.google.gson.Gson.fromJson(Gson.java:852) com.kta.b2a.b2a.util.GsonMessageBodyHandler.readFrom(GsonMessageBodyHandler.java:55) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:260) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:236) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156) org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:74) org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156) org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085) org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:853) org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:270) org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider$EntityValueFactory.provide(EntityParamValueFactoryProvider.java:96) org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81) org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:127) org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:308) org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) org.glassfish.jersey.internal.Errors.process(Errors.java:315) org.glassfish.jersey.internal.Errors.process(Errors.java:297) org.glassfish.jersey.internal.Errors.process(Errors.java:267) org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291) org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140) org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:403) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334) org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 

Note The full stack trace of the root cause is available in the server logs.


Apache Tomcat/9.0.27

Does anyone know how to solve this issue? Thanks in advance.

Hey @Pau,

You will have to show how your body looks like for the HTTP Task. Flowable is not doing anything special. It gets the request body and sends it over the wire.

Cheers,
Filip

As I have understood, the Modeler doesn’t allow to send empty fields in forms rendered by Flowable, that was the problem. I’ll send the form from the frontend and check empty fields there. Thanks!