Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to fix: 'java.lang.String' to required type 'java.util.Collection'
    text
    copied!<p>I'm getting this error when I submit my form and cannot figure out why this is happening. I believe the taglib should be handling this. I've tried changing the value passed in my jsp to <code>itemValue="id"</code> but it has no affect.</p> <pre><code>org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object 'content' on field 'stateCollection': rejected value [com.myapp.cmt.model.State[ id=3 ]]; codes [typeMismatch.content.stateCollection,typeMismatch.stateCollection,typeMismatch.java.util.Collection,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [content.stateCollection,stateCollection]; arguments []; default message [stateCollection]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Collection' for property 'stateCollection'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.myapp.cmt.model.State] for property 'stateCollection[0]': no matching editors or conversion strategy found] </code></pre> <p><strong>My jsp</strong></p> <pre><code>&lt;strong&gt;State&lt;/strong&gt;&lt;br/&gt; &lt;form:checkboxes path="stateCollection" items="${states}" itemLabel="name"/&gt; </code></pre> <p><strong>My Content</strong></p> <pre><code>public class Content implements Serializable { ....... @JoinTable(name = "content_to_state", joinColumns = { @JoinColumn(name = "content_id", referencedColumnName = "id")}, inverseJoinColumns = { @JoinColumn(name = "state_id", referencedColumnName = "id")}) @ManyToMany private Collection&lt;State&gt; stateCollection; ..... @XmlTransient public Collection&lt;State&gt; getStateCollection() { return stateCollection; } public void setStateCollection(Collection&lt;State&gt; stateCollection) { this.stateCollection = stateCollection; } ..... </code></pre> <p><strong>My Controller</strong></p> <pre><code>... @RequestMapping(value = "/{guid}/save", method = RequestMethod.POST) public ModelAndView saveContent(@ModelAttribute("content") Content content, @PathVariable("guid") String guid) { try { // Save the modified object contentService.save(content); } catch (IllegalOrphanException ex) { ... </code></pre> <p><strong>My content service</strong></p> <pre><code>... @Transactional public void save(Content content) throws IllegalOrphanException, NonexistentEntityException, RollbackFailureException, Exception { try { utx.begin(); em.merge(content); utx.commit(); } catch (Exception ex) { } finally { if (em != null) { em.close(); } } } ... </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload