VMware {code} Community
wodge
Enthusiast
Enthusiast

Upgrade to 6.7: Cannot find class [org.springframework.web.servlet.view.json.MappingJackson2JsonView]

Hi,

I've read the FAQs after trying to run my plugin against the 6.7 server (running in my local development environment). I have a problem that I believe is identified in the FAQs, but don't know how to solve it. There is some advice how to solve it, but I really need it to be spelt out so I can apply the fix.

The problem is as follows (from the FAQs):

Issue: MappingJacksonJsonView removed from Spring Framework Symptom: java.lang.ClassNotFoundException: org.springframework.web.servlet.view.json.MappingJacksonJsonView

Explanation: MappingJacksonJsonView has been replaced with a newer class.

Solution: Use org.springframework.web.servlet.view.json.MappingJackson2JsonView in bundle-context.xml file. Note: MappingJackson2JsonView imposes dependencies on additional Spring packages.

I need to know exactly what to add to the bundle-context.xml file please?

I've tried this:

<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"> <property name="contentType" value="application/json"/> </bean>

 

but I still get the same error... Could you please state exactly what code needs to be added?

Many thanks,

Warren

Reply
0 Kudos
4 Replies
Denis_Chorbadzh
VMware Employee
VMware Employee

Hi Warren,

 

Thank you for your feedback.

If your "MappingJacksonJsonView" bean is inside "<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">", you can delete the whole "ContentNegotiatingViewResolver" bean.

Please, try this out and share the outcome.

 

Best Regards,

Denis

Reply
0 Kudos
wodge
Enthusiast
Enthusiast

Hi Denis,

Thank you for your reply.

I'd actually been editing the bundle-context.xml in the server-side of the plugin, rather than the ui code... I solved the problem by following the FAQ guidelines in the section: "Upgrade to use content negotiation based on the "Accept" header of the HTTP request in a backward compatible way". I was then able to upgrade the plugin successfully. I didn't realize it was to be applied in the server-side code before then.

Many thanks,

Warren

Reply
0 Kudos
vaibhav87
Enthusiast
Enthusiast

Can you please share the changes done, I am facing the same issue.

DO we need to add any additional lib for MappingJackson2JsonView.

 

Thanks

Reply
0 Kudos
wodge
Enthusiast
Enthusiast

Hi Vaibhav87,

The changes I carried out are as follows:

1. In the service code, change the MANIFEST.MF file so that in the "Import-Package" sections all versions are removed, except for those libraries I have explicitly added.  Here's my section, below:

Import-Package: com.vmware.vise.data,

com.vmware.vise.data.query,

com.vmware.vise.data.uri,

com.vmware.vise.usersession,

com.vmware.vise.security,

com.vmware.vise.vim.data,

com.google.gson;version="2.3.1",

javax.servlet.http,

javax.net.ssl,

org.springframework.beans.factory.annotation,

org.springframework.beans.factory,

org.springframework.stereotype,

org.springframework.web.client,

org.springframework.http,

org.springframework.web.bind.annotation,

org.springframework.util,

org.springframework.http.client,

org.apache.http.conn.ssl;version="4.3.3",

org.apache.http.client;version="4.3.3",

org.apache.http.impl.client;version="4.3.3",

org.springframework.beans,

org.springframework.beans.factory.config,

org.springframework.web.accept;resolution:=optional

(I introduced com.google.gson and org.apache.http.* so these have their own versions).

2. Followed the instructions in the FAQs:

https://vdc-download.vmware.com/vmwb-repository/dcr-public/5e6f0e2e-1e80-4128-b1b7-fbe3a4f58108/4a82...

Section "Upgrade to use content negotiation based on the "Accept" header of the HTTP request in a backward compatible way"

3. In order to be able to build, I also downloaded the two jar files:

Maven Repository: org.springframework » spring-beans » 4.3.9.RELEASE

Maven Repository: org.springframework » spring-web » 4.3.9.RELEASE

I added these to the libs directory, at: ${VSPHERE_SDK_HOME}/libs/

I updated the build-java.xml file so that within the <classpath> entity, I added two more path elements:

<classpath>

     <pathelement path="${VSPHERE_SDK_HOME}/libs/spring-beans-4.3.9.RELEASE.jar"/>

     <pathelement path="${VSPHERE_SDK_HOME}/libs/spring-web-4.3.9.RELEASE.jar"/>

</classpath>    

... These are the changes that were made and I now it builds from the build-plugin-package.sh script in the tools directory (of the ui code). I don't have the Jackson issue reported. The plugin works for both 6.5 and 6.7 H5 (as well at 6+ Flex).

Hope that helps you to progress.

Wodge

Reply
0 Kudos