JAVA - NullPointerException in SelectedValueComparator - jsp file, form with multiple options

I have form with multiple options in jsp. User can choose many options and I can get the full list of chosen options. It’s working ok, I can get the all of them in my getters and setters during debugging.

When I click my action button - generate, the whole logic is going to SelectedValueComparator.class and OptionWriter.class when I’m getting NullPointerException because one of the values there is null. I don’t know why it is happening.

I tried a lot of options but I’m getting tired of it.

\<form:select path="selectedStudents" multiple="true"\>\<form:options items="${studentReportData.availableStudentLabels}" itemLabel="description" itemValue="id"/\>\</form:select\>

My stacktrace:

ERROR:2018-06-1815:29:52,564org.springframework.web.servlet.tags.form.OptionsTag-java.lang.NullPointerExceptionat org.springframework.web.servlet.tags.form.SelectedValueComparator.exhaustiveCollectionCompare(SelectedValueComparator.java:139)  
at org.springframework.web.servlet.tags.form.SelectedValueComparator.collectionCompare(SelectedValueComparator.java:117)  
at org.springframework.web.servlet.tags.form.SelectedValueComparator.isSelected(SelectedValueComparator.java:97)  
at org.springframework.web.servlet.tags.form.OptionWriter.isOptionSelected(OptionWriter.java:253)  
at org.springframework.web.servlet.tags.form.OptionWriter.renderOption(OptionWriter.java:229)  
at org.springframework.web.servlet.tags.form.OptionWriter.doRenderFromCollection(OptionWriter.java:211)  
at org.springframework.web.servlet.tags.form.OptionWriter.renderFromCollection(OptionWriter.java:180)  
at org.springframework.web.servlet.tags.form.OptionWriter.writeOptions(OptionWriter.java:133)  
at org.springframework.web.servlet.tags.form.OptionsTag.writeTagContent(OptionsTag.java:168)  
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)  
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)

Hi @szymonpru,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our Community organized so users can more easily find information.

As you’ll notice, your Topic is now in the Project Development Help board. No action is needed on your part; you can continue the conversation as normal here.

Let me know if you have any other questions or if I can help with anything else.

Cheers!