Hello Tauseef, The issue you're encountering is due to the fact that the Properties class in Java stores both keys and values as Strings. When you are trying to cast the value directly to Double, it throws a ClassCastException because values from the properties file are loaded as String and cannot be directly cast to Double.
To resolve this, you need to manually parse the String value to a Double. Here's how you can modify your code to do this: Map<String, Double> rules = alerts.entrySet().stream() .collect(Collectors.toMap( e -> (String) e.getKey(), e -> Double.parseDouble((String) e.getValue()) )); Best, Junrui Tauseef Janvekar <tauseefjanve...@gmail.com> 于2023年12月5日周二 16:30写道: > Dear Team, > > I am getting cast exception in flink. > Caused by: org.apache.flink.client.program.ProgramInvocationException: The > main method caused an error: class java.lang.String cannot be cast to class > java.lang.Double (java.lang.String and java.lang.Double are in module > java.base of loader 'bootstrap') at > org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372) > > The code that I wrote is > > Properties alerts = new Properties(); > > try (InputStream stream = OtelTransformerJob.class > .getClassLoader().getResourceAsStream("rule-based-config.txt")) { > > alerts.load(stream); > > } > > Map<String, Double> rules = alerts.entrySet().stream() > > .collect(Collectors.toMap(e -> (String) e.getKey(), e -> (Double) e > .getValue())); > > > Not sure what is the problem here > > Thanks, > Tauseef >