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(JSON.java:111)
    at org.json.JSONObject.<init>(JSONObject.java:159)
    at org.json.JSONObject.<init>(JSONObject.java:172)
    at com.vaadin.server.communication.ServerRpcHandler$RpcRequest.<init>(ServerRpcHandler.java:79)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:160)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:93)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1405)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1721)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1679)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

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!

Martin
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,

Martin