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(  
at org.springframework.web.servlet.tags.form.SelectedValueComparator.collectionCompare(  
at org.springframework.web.servlet.tags.form.SelectedValueComparator.isSelected(  
at org.springframework.web.servlet.tags.form.OptionWriter.isOptionSelected(  
at org.springframework.web.servlet.tags.form.OptionWriter.renderOption(  
at org.springframework.web.servlet.tags.form.OptionWriter.doRenderFromCollection(  
at org.springframework.web.servlet.tags.form.OptionWriter.renderFromCollection(  
at org.springframework.web.servlet.tags.form.OptionWriter.writeOptions(  
at org.springframework.web.servlet.tags.form.OptionsTag.writeTagContent(  
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(  
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(

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.