martedì 20 marzo 2012

JAXB-XJC: java.lang.IllegalArgumentException: Illegal pattern character 'o' at java.text.SimpleDateFormat.compile

When using xjc compiler (jaxb version 2.2.5) to generate java classes from xsd files class generation may fail with some error like this:

 Illegal pattern character 'o' at java.text.SimpleDateFormat.compile( at java.text.SimpleDateFormat.initialize( .....
(characted may be different - es. 'g' or other).
What is the problem?
Problem seems to be your locale setting because jaxb-xcj doen't support  locale different from US.

Generate your classes with ant and introduce a javascript function to change your locale to US.

Sample ant file 

name="xjc" classname="">
<fileset dir="${basedir}/lib">
<include name="jaxb*.jar" />
<include name="xjc-*.jar" />
actualDefault = Locale.getDefault();
project.setProperty("actual-default-locale", actualDefault);
name="setLocale" language="javascript"><![CDATA[

<target name="gen-oci-as" description="generates java classes from the OCISchemaAS.xsd">
<setLocale />
<xjc schema="${basedir}/xsd/OCISchemaAS.xsd" destdir="${basedir}/src" extension="true" removeOldOutput="true">
<produces dir="${basedir}/src" includes="**/*.java" />
<arg value="-verbose" />
<arg value="-npa" />

Nessun commento:

Posta un commento