2

hI am getting an error saying

serverError: class java.lang.ClassCastException java.lang.Integer cannot be cast to java.lang.String

This happens when I select something from a <h:selectOneMenu> component.

What are the possible reasons for this error ? I haven't written any JavaScript code to produce the alert.

The <h:selectOneMenu> component does not deal with Integer at all.

Sometimes I also get an ArrayIndexOutOfBoundException 1 as an alert, too.

<h:selectOneMenu id="vehiclenames" value="#{bean.selectedVehicle}">
    <f:selectItem itemLabel="select one" itemValue=""/>
    <f:selectItems   value="#{vehicles}" />
    <f:ajax event="change" listener="#{bean.catchValue}" render= "panel" />
</h:selectOneMenu>
user19999111
  • 170
  • 1
  • 3
  • 10
  • 2
    fyi: this is a java exception. it has nothing to do with javascript – Philipp Sander Dec 13 '13 at 17:17
  • _"This happens when I select something from a component."_ Show us the code of your listener method. –  Dec 13 '13 at 18:36
  • maybe [this link](http://stackoverflow.com/questions/4734580/jsf-2-selection-combo-box-with-without-conversion-strategy/4735322#4735322) can help you – danRod Dec 13 '13 at 19:40

1 Answers1

3

This alert will show up when an exception is thrown during an ajax request while you're using Mojarra with javax.faces.PROJECT_STAGE context parameter set to Development. This alert is intented to inform the web developer that something has seriously failed.

You should see the exception and the full stack trace in the server logs. Usually, it's caused by a bug in your own code. The stack trace should give sufficient clues to that.

As to the "weird" exception handling, you may want to consider OmniFaces FullAjaxExceptionHandler. This will let JSF ajax exceptions utilize the standard web.xml error page mechanisms. See also What is the correct way to deal with JSF 2.0 exceptions for AJAXified components?

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • hi, i checked the server logs but i am not able to find any exception there, Also this error message gets thrown in the 3rd selection. .. when i choose element from the dropdown the third time. I have debug points in my buisness logic but the control does not reach there , the exception gets thrown first – user19999111 Dec 16 '13 at 10:27