Hello,
I have strange issue. I am currently using Camunda Spring Boot Version <3.3.1>
I have exposed few services along with the core engine services.
The problem here is my REST service json response is coming in UPPER_CAMEL_CASE
Ex:
{
“Name” :“Djonny”,
“Age”: 32
}
Expected:
{
“name” :“Djonny”,
“age”: 32
}
When i removed camunda-bpm-spring-boot-starter-rest it is working fine. When i put it back again response is coming in UPPER_CAMEL_CASE.
I tried updating the property below but no luck.
spring:
jackson:
property-naming-strategy: LOWER_CAMEL_CASE
Thanks,
Vamshi
@vamsin20 how does your pom.xml file looks like?
Here is my pom looks like
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<groupId>com.demo.wf</groupId>
<artifactId>DemoWorkFlowWs</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Demo WorkFlow WS</name>
<description>Demo WorkFlow WS</description>
<properties>
<camunda.version>7.11.0</camunda.version>
<!--
Adjust if you want to use Camunda Enterprise Edition (EE):
<camunda.version>7.11.0-ee</camunda.version>
Make sure you also switch to the ee webapp dependency
and EE repository below
-->
<camundaSpringBoot.version>3.3.1</camundaSpringBoot.version>
<springBoot.version>2.1.8.RELEASE</springBoot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>camunda-bpm-nexus</id>
<name>Camunda Maven Repository</name>
<url>https://app.camunda.com/nexus/content/groups/public</url>
</repository>
</repositories>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy.modules.http-builder/http-builder -->
<dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.7.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${project.basedir}/src/main/script/update_component.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>report</id>
<build>
<plugins>
<!-- https://www.owasp.org/index.php/OWASP_Dependency_Check -->
<!-- https://jeremylong.github.io/DependencyCheck/ -->
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>3.3.2</version>
<configuration>
<retireJsAnalyzerEnabled>false</retireJsAnalyzerEnabled>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<!-- Important to set the version else release not working with GIT -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bom</artifactId>
<version>${camunda.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.camunda.bpm.dmn</groupId>
<artifactId>camunda-engine-dmn-bom</artifactId>
<version>${camunda.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springBoot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
<version>${camundaSpringBoot.version}</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
<version>${camundaSpringBoot.version}</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
<version>${camundaSpringBoot.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- required to use H2 as a file based database (Otherwise it's In-Memory) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- Required to use Spin dataformat support -->
<dependency>
<groupId>org.camunda.spin</groupId>
<artifactId>camunda-spin-dataformat-all</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-spin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<artifactId>camunda-bpm-assert-scenario</artifactId>
<version>0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.assert</groupId>
<artifactId>camunda-bpm-assert</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<artifactId>camunda-bpm-process-test-coverage</artifactId>
<version>0.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
My JAXB LOOKs likes this
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = “PersonType”,
propOrder = {“name”, “age”}
)
public class PersonType{
@XmlElement(name = "Name")
String name;
@XmlElement(name = "Age")
Integer age;
public Integer getAge() {
return this.age;
}
public void setAge(Integer value) {
this.age= value;
}
public String getName() {
return this.name;
}
public void setName(String value) {
this.name = value;
}
}
Hello @aravindhrs please find the above data
@vamsin20, Your PersonType model has annotation like below. Fixing this might be your problem will be solved.
@XmlElement(name = "Name")
String name;
@XmlElement(name = "Age")
Integer age;
Change the above annotation values to like this:
@XmlElement(name = "name")
String name;
@XmlElement(name = "age")
Integer age;
@aravindhrs it is not so easy as we use xsd’s and wsdl for creating this pojo components. It will impact other components as well.
I am not sure why this issue is happening only when we include camunda.rest jar. when we exclude that it is working normally.
Need to figure out what changes camunda.rest brings with normal XML and JSON conversion.
@vamsin20, if you are using camunda rest api’s, then only the camunda-bpm-spring-boot-starter-rest dependency is required.
with your JAXBContext
you’re overriding the default behaviour. The problem is in the PersonType.class. you’re requesting the engine to generate the field names as uppercase, @XmlElement(name = “Name”) and @XmlElement(name = “Age”), so the engine does. you need to handle these things when UnMarshaller
.
I can provide a workaround for this, but which needs additional implementation:
You can serialize the model using XmlAttributeOverrides like:
XmlSerializer serializer = new XmlSerializer(objectType, xmlOverrides);
Refer this example:
https://www.codeproject.com/Articles/808268/OverrideXml-control-XML-serialization-of-classes-y
@aravindhrs Thanks for your help. Finally i figured out one solution.
In this way we may need to ignore the JAXB annotations when we serialize and de-serialize JAXB to Json. By putting the Jackson Mapper to Ignore annotations.
We can do this by putting below property to false
spring . Jackson . mapper . use_annotations : false
@vamsin20 great you found the solution
. Thanks for sharing
. Disabling Jackson annotations will impact the entire application if Jackson annotations needed in other classes, if it’s not a problem for you then you can proceed