I use JAXB 2 to parse an XML file against an XSD schema and the XML tags are automatically unmarshalled during ant build to Java classes. Some enums are created. The code is:
@XmlType(name = "binQuality")
@XmlEnum
public enum BinQuality {
GOOD,
BAD,
UGLY,
NULL;
public String value() {
return name();
}
public static BinQuality fromValue(String v) {
return valueOf(v);
}
}
In my code I call:
BinQuality bq = BinQuality.valueOf(him.getToBinQuality());
in a loop and I get the exception only in the 91st iteration.
******* UPDATED *******
him.getToBinQuality() does return a valid enum (GOOD/BAD/UGLY/NULL). Below is an excerpt of logs.
....
2011-07-18 15:28:09 DEBUG (com.st.mas.wmr.persistence.process.ProcessStifOliBinConversionCompleteImpl:183) -> class com.st.mas.wmr.persistence.process.ProcessStifOliBinConversionCompleteImpl|exportToXml|him.getToBin():89|him.getToBinQuality():BAD
2011-07-18 15:28:09 DEBUG (com.st.mas.wmr.persistence.process.ProcessStifOliBinConversionCompleteImpl:183) -> class com.st.mas.wmr.persistence.process.ProcessStifOliBinConversionCompleteImpl|exportToXml|him.getToBin():90|him.getToBinQuality():UGLY
2011-07-18 15:28:09 DEBUG (com.st.mas.wmr.persistence.process.ProcessStifOliBinConversionCompleteImpl:183) -> class com.st.mas.wmr.persistence.process.ProcessStifOliBinConversionCompleteImpl|exportToXml|him.getToBin():91|him.getToBinQuality():BAD
2011-07-18 15:28:09 WARN (org.apache.struts.action.RequestProcessor:538) -> Unhandled Exception thrown: class java.lang.IllegalArgumentException
This seems really mysterious.
Java version used is 1.5.
Appreciate it.
Will
This is because no enum value could be found for your 91th entry. What is the value of the failed String?