Vaadin4Spring: Value of type java.lang.String cannot be converted to JSONOb

Hello everyone,

I’m currently trying to set up a Vaadin4Spring project. The project compiles fine and I’m able to start it simply by running the “Application.main(…)” method generated by Spring Boot. However, when I enter a value into a text field at runtime, I always get the following error:

org.json.JSONException: Value 814417d1-3b6b-4434-97e1-073d07e94929 of type java.lang.String cannot be converted to JSONObject
    at org.json.JSON.typeMismatch(
    at org.json.JSONObject.<init>(
    at org.json.JSONObject.<init>(
    at com.vaadin.server.communication.ServerRpcHandler$RpcRequest.<init>(
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(
    at com.vaadin.server.VaadinService.handleRequest(
    at com.vaadin.server.VaadinServlet.service(
    at javax.servlet.http.HttpServlet.service(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
    at org.apache.catalina.valves.RemoteIpValve.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.http11.AbstractHttp11Processor.process(
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$

It’s very odd that none of my own classes show up in the stack trace. I’m completely puzzled where this comes from and I must admit that I have no idea how to solve it.

I have attached my pom.xml file that I’m using. I have done a web search on this, and there have been cases where the same error has happened, but I am NOT using OSGi (I do need to include EMF libraries, though), nor am I doing any kind of Android development. Basically I just want a plain spring-enabled Vaadin application…

Any help would be much appreciated!

14212.xml (2.8 KB)

Hello again,

I got frustrated by this issue so I decided to start ‘fresh’ and try it again. Here’s what I did:

  1. Installed Spring Tool Suite (a variation of Eclipse that comes with some Spring-specific extensions)
  2. Used STS to create a maven-controlled spring web project (as advised by the Vaadin4Spring GitHub project readme) - I will refer to this as project M (for maven)
  3. Installed the Vaadin Eclipse plugin
  4. Used the Vaadin Eclipse plugin to create a new Vaadin 7 project. I will refer to this project as project V (for vaadin)
  5. Let Ivy resolve all the dependencies
  6. Checked out the vaadin4spring projects at GitHub into the STS workspace
  7. Right-click on the main vaadin4spring project, then “Run As → Maven Clean”, followed by “Run As → Maven Install”
  8. Right-click on project V and select “Configure → Convert to Maven Project”
  9. Copy the pom.xml file from project M and paste it into project V, overriding the file created in the previous step
  10. In project V, update the pom.xml with the dependencies found on the Vaadin4Spring GitHub project
  11. Copy the “Application” class from project M to project V (IMPORTANT: it must reside in the base package!)
  12. Attach the “VaadinUI” annotation to the main UI of project V
  13. Use the Vaadin Eclipse Plugin to generate the widgetset and the theme for project V. Do NOT skip this step, otherwise you will get the error described in the initial post! Unfortunately, this seems to work only on ivy-managed Vaadin projects, and does NOT work for Spring Boot projects (which is why we did all the copy-pasting before)
  14. In order to make your Spring Boot “Application” class work, you need to use the “WebContent” folder as a source folder, otherwise Vaadin will not find its theme files. Do this simply by right-clicking on the folder in your project explorer and select “Build Path → Use as Source Folder”.
  15. You should now be able to start your new Vaadin Application by right-clicking on the Spring Boot generated “Application” class in your root package and selecting the usual “Run As → Java Application”

This is a fairly lengthy procedure. It would be very nice if the next iteration of the Vaadin Eclipse plugin could include an option to create a Vaadin4Spring application that is already set up with maven.

Kind regards,