Different response when application deployed in jBoss 6.2 vs jBoss 7.3
Asked Answered
S

1

3

We have recently upgraded our jBoss EAP from 6.2 to 7.3.0.

After the upgrade we have observed that the application started behaving weirdly. We are using spring framework version - 4.1.9.RELEASE.

For example:

@RestController
public class CommonController{

@RequestMapping(value = "/rest/report/testResponse", method = RequestMethod.GET)
    public @ResponseBody List<Entry<String, Number>> getData(){
        List<Entry<String, Number>> technologyList = new ArrayList<>();
        SimpleEntry<String, Number> simpleEntry1 = new AbstractMap.SimpleEntry<String,Number>("Java",1);
        SimpleEntry<String, Number> simpleEntry2 = new AbstractMap.SimpleEntry<String,Number>("Spring",2);
        technologyList.add(simpleEntry1);
        technologyList.add(simpleEntry2);
        return technologyList;
    }
}

The response I am getting when application was deployed in jBoss 6.2 is:

[
{
"key": "Java",
"value": 1
},
{
"key": "Spring",
"value": 2
}
]

The response I am getting when application is now deployed in jBoss 7.3 is:

[
{
    "Java": 1
}, 
{
    "Spring": 2
}
]

As you can see there is a subtle difference in above two responses. This is breaking my frontend code where we have used javascript code like below, since now in jBoss7 we are not getting response with key/value prepended :

<ui-select-choices repeat="obj.value as obj in  technologyList |  orderBy:'key'">
   <div class ="small" ng-bind-html="obj.key" title ="{{obj.key}}"></div>
</ui-select-choices>

We can not modify the backend/frontend code because the application is already running in production and it will not be possible to change the code at many places. We just want to upgrade the jBoss version.

Anyone faced the similar issue, please comment/suggest the resolution.

Saddleback answered 14/8, 2021 at 7:54 Comment(4)
If you can't change your code, then the only option would be to use a different jboss version where your code does still work. Not entirely sure what changed between the versions. But I assume that spring (or jboss) used a new jackson version where they explicitly convert Map.Entry to {[key]: [value]} instead of {"key": [key], "value": [value]}Fibre
Also please see this: Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?Fibre
Thanks @Fibre for pointing out what was wrong in the question - there is no need to add "urgent/asap" etc adjectives in question. I will edit my question right away and keep it my mind not to do this in future.Saddleback
Also a related question: Issue when serializing Map.Entry using jackson, if you can adjust the jackson-databind version to the one used previously, then you can maybe stay on jboss 7Fibre
A
1

This was an issue for jackson which is by default used for serialization.

Here is the release when the change was brought to jackson. The problem that you face is also mentioned in compatibility issues for Jackson 2.5

JBoss 7.3 probably comes with an already included library of jackson so this is where you are affected. Check here how to exclude provided Jackson from JBoss 7

Then pack your application with a jackson library earlier than 2.5 and deploy it again.

Aerolite answered 14/8, 2021 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.