java.lang.UnsupportedOperationException: Unsupported format specifier "R" for format string "" at agi.foundation.compatibility.FormatHelper.buildFormat(Unknown Source) at agi.foundation.compatibility.FormatHelper.buildFormat(Unknown Source) at agi.foundation.compatibility.DoubleHelper.toString(Unknown Source) at cesiumlanguagewriter.CesiumOutputStream.writeValue(CesiumOutputStream.java:175) at cesiumlanguagewriter.advanced.CesiumWritingHelper.writeCartographicList(CesiumWritingHelper.java:515) at cesiumlanguagewriter.PositionListCesiumWriter.writeCartographicDegrees(PositionListCesiumWriter.java:188) at cesiumlanguagewriter.PolygonCesiumWriter.writePositionsPropertyCartographicDegrees(PolygonCesiumWriter.java:266)
When I try using the Java czml-writer in a servlet, I get the following error:
My code, mostly copied from the CesiumLanguageWriterTests project:
StringWriter sw = new StringWriter();
CesiumOutputStream output = new CesiumOutputStream(sw);
output.setPrettyFormatting(true);
CesiumStreamWriter stream = new CesiumStreamWriter();
PacketCesiumWriter packet = stream.openPacket(output);
packet.writeId("Test");
packet.writeName("Hello world");
PositionCesiumWriter position = packet.openPositionProperty();
position.writeCartographicDegrees(new Cartographic(-75.0, 45.0, 100.0));
position.close();
packet.close();
sw.close();
``
If I comment out the Position lines, it works as expected.
Where does the unsupported format specifier come from? Is the simple fact I'm trying to do this in a servlet or on an app server enough to cause this problem?
I don’t know what the problem is, but I can provide some context that might help.
The Java code looks roughly like this (simplified).
String pattern = “R”;
if (Character.isLetter(pattern.charAt(0))) {
// we do enter this code block
char firstChar = pattern.charAt(0);
char upperCaseFirstChar = Character.toUpperCase(firstChar);
if (upperCaseFirstChar == ‘R’) {
// we do not enter this code block, which eventually causes an exception.
}
}
I suspect this has to be related to locales somehow, but I’m not aware of a locale where the first character of the String “R”, converted to upper case, would not be equal to the character ‘R’.
Can you determine what locale the server is running under?
Here are my stats:
Weblogic 12.1.2
Java 1.7.0_71, OpenJDK build 24.65-b04
Oracle Linux Server 6.6, 64-bit
The Linux locale is set to en_US.UTF-8, and the servlet verifies this with Locale.getDefault().getDisplayName() == English (United States)
The only difference between running the tests project versus my servlet is that the test project was run as a JUnit test, and my servlet runs on the server.
BTW, this happens with the Position, Polygon, and Polyline writers.
I ran some more tests, and it looks like the problem is with Weblogic:
- Windows 8.1/Tomcat 7 works fine
- Same Linux box with Tomcat 7 works fine
I changed the servlet’s Locale in Weblogic to US, FRANCE, and KOREA, and they all had the same problem.