Strange class cast exception
Folk, the following code, at the store =() method call, is giving a ClassCastException. What could be wrong?
java.io.FileOutputStream out =new java.io.FileOutputStream("MyProps.properties");
java.util.Properties prop =new java.util.Properties();
//copy Hashtable to properties instance...
prop.putAll(MQMessenger.config);// it is a static hastable contaning some configuration options already loaded from the app load
prop.store(out,null);//store - the application raises the exception here
[750 byte] By [
HenriqueSa] at [2007-11-27 9:48:32]

I checked the constants and they seem to resolve to Strings but you can see clearly that there are two values of Integer....is this the problem? How can I work around this?
config.put(MQC.HOST_NAME_PROPERTY, defaults.getString("mqhost"));
config.put(MQC.CHANNEL_PROPERTY, defaults.getString("mqchannel"));
config.put(MQC.PORT_PROPERTY, new Integer(defaults.getString("mqport")));
config.put("mqcharset", new Integer(defaults.getString("mqcharset")));
config.put("mqcharlength", new Integer(defaults.getString("mqcharlength")));
config.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
void putAll(Properties p, Map < Object, Object > map) {
for( Map.Entry < Object, Object > e : map.entrySet()) {
p.setProperty(e.getKey().toString(), e.getValue().toString());
}
}
Or rewrite your map to be of type Map < String, String> and don't store integers!