cancel
Showing results for 
Search instead for 
Did you mean: 

Smarteditwebservices retruns configuration in an XML instead of JSON

Hi

SAP Commerce version 1811.18

We have installed Smartedit on our SAP Commerce and we can see the login screen our domains /smartedit. When entering credentials and trying to log in we see error in fetching the Smartedit Configurations.

ERROR [hybrisHTTP38] [RestHandlerExceptionResolver] com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

at [Source: (String)"<?xml version='1.0' encoding='UTF-8'?><configurationDataListWsDto><configurations><key>applications.cmssmartedit</key><value>{"smartEditLocation":"/cmssmartedit/cmssmartedit/js/cmssmartedit.js"}</value></configurations><configurations><key>applications.cmssmarteditContainer</key><value>{"smartEditContainerLocation":"/cmssmartedit/cmssmartedit/js/cmssmarteditContainer.js"}</value></configurations><configurations><key>previewTicketURI</key><value>"/previewwebservices/v1/preview"</value></configura"[truncated 203 chars]; line: 1, column: 2]

at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)

at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:693)

at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:591)

at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1902)

at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:757)

at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4142)

at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3005)

at de.hybris.smartedit.controllers.ConfigurationController.getConfiguration(ConfigurationController.java:89)

Configurations are requested from smarteditwebservices extensions which should return JSON and does, when we curl the configuration address:

{
   "configurations" : [ {
      "key" : "applications.cmssmartedit",
      "value" : "{\"smartEditLocation\":\"/cmssmartedit/cmssmartedit/js/cmssmartedit.js\"}"
   }, {
      "key" : "applications.cmssmarteditContainer",
      "value" : "{\"smartEditContainerLocation\":\"/cmssmartedit/cmssmartedit/js/cmssmarteditContainer.js\"}"
   }, {
      "key" : "previewTicketURI",
      "value" : "\"/previewwebservices/v1/preview\""
   }, {
      "key" : "defaultToolingLanguage",
      "value" : "\"en\""
   }, {
      "key" : "whiteListedStorefronts",
      "value" : "[]"
   } ]
}

Somehow smartedit extension receives these configurations in XML like this:

<?xml version='1.0' encoding='UTF-8'?>
    <configurationDataListWsDto>
        <configurations>
            <key>applications.cmssmartedit</key>
            <value>{"smartEditLocation":"/cmssmartedit/cmssmartedit/js/cmssmartedit.js"}</value>
        </configurations>
        <configurations>
            <key>applications.cmssmarteditContainer</key>
            <value>{"smartEditContainerLocation":"/cmssmartedit/cmssmartedit/js/cmssmarteditContainer.js"}</value>
            </configurations>
        <configurations>
            <key>previewTicketURI</key>
            <value>"/previewwebservices/v1/preview"</value>
        </configurations>
        <configurations>
            <key>defaultToolingLanguage</key>
            <value>"en"</value>
        </configurations>
        <configurations>
            <key>whiteListedStorefronts</key>
            <value>[]</value>
        </configurations>
    </configurationDataListWsDto>

In de.hybris.smartedit.controllers.ConfigurationController.getConfiguration this XML data is passed to a mapper which expects JSON and the error in the start of the question arises.

Why does smarteditwebservices return XML although it's says in every documentation that it produces JSON? What can we do to fix this?

Accepted Solutions (1)

Accepted Solutions (1)

janbu
Explorer
0 Kudos

We had the same Issue with Hybris 2005. The problem was a jackson-dataformat-xml-x.xx.x.jar Library we had in one of our custom extensions. This causes problems with the Smartedit extension. After removing this library, the problem was solved.

SAP KB Note of this problem: https://launchpad.support.sap.com/#/notes/3002061

Answers (3)

Answers (3)

alexander_medina
Explorer
0 Kudos

This bug happens in 2211 when jackson-dataformat-xml-x.xx.x.jar is in a custom extension because sap has changed the ignoreAcceptHeader from true to false and the jackson library is adding application/xml to the Accept Header that is send in the request from smartedit ConfigurationController to smarteditwebservices ConfigurationController. The solution proposed on 10-13-2023 works but is only a temparary workaround imho.

A simpler solution would be to change the smartedit-integration-config.xml from the smartedit extension. Here the request that is sent to smarteditwebservices is configured. Just change the httpGETGateway definition to this:

<int:gateway id="httpGETGateway" service-interface="de.hybris.smartedit.controllers.HttpGETGateway"
default-request-channel="httpGETRequestChannel">
  <int:method name="loadAll">

     <int:header name="Accept" value="application/json"/>

</int:method>
</int:gateway>

This manually sets the Accept header to "application/json" (and removing application/xml) from the internal request that is sent between the 2 ConfigurationControllers and guarantees that json is returned in any way.

Anyway, this has to be done by SAP.

 

0 Kudos

Hi

We encountered this issue as well but could not simply remove the conflicting library. Use this in any buildcallbacks.xml to fix it:

<xmltask report="true"
        source="${ext.cmssmarteditwebservices.path}/web/webroot/WEB-INF/cmssmarteditwebservices-web-spring.xml"
        dest="${ext.cmssmarteditwebservices.path}/web/webroot/WEB-INF/cmssmarteditwebservices-web-spring.xml">
    <attr path="//*[@name='ignoreAcceptHeader']"
          attr="value" value="true"  />
</xmltask>
<xmltask report="true"
         source="${ext.cmswebservices.path}/web/webroot/WEB-INF/cmswebservices-web-spring.xml"
         dest="${ext.cmswebservices.path}/web/webroot/WEB-INF/cmswebservices-web-spring.xml">
    <attr path="//*[@name='ignoreAcceptHeader']"
          attr="value" value="true"  />
</xmltask>
<xmltask report="true"
         source="${ext.smarteditwebservices.path}/web/webroot/WEB-INF/smarteditwebservices-web-spring.xml"
         dest="${ext.smarteditwebservices.path}/web/webroot/WEB-INF/smarteditwebservices-web-spring.xml">
    <attr path="//*[@name='ignoreAcceptHeader']"
          attr="value" value="true"  />
</xmltask>

BR

0 Kudos

Hi @tieto_karklale2

Did you get solution for the above issue ?

We are facing the same issue with hybris 2005 version.

Thanks

Jeevan

0 Kudos

Hi jeevan.lobo,

Sorry to say but we did not find a solution. Eventually our project was scrapped and development was discontinued so we never really got into fixing the issue.

BR

Aleksi Kärkkäinen