Category Archives: java

spring boot tomcat jsp is downloaded not rendered

Questions: I am bootstrapping my spring application to spring boot and I have the problem that the embedded tomcat is not rendering the jsp files instead the file will be downloaded. I have googled and tried everything what I have found so far but I still do anything wrong. I have the following dependencies in… Read More »

What are the reasons why Map.get(Object key) is not (fully) generic

Questions: What are the reasons behind the decision to not have a fully generic get method in the interface of java.util.Map<K, V>. To clarify the question, the signature of the method is V get(Object key) instead of V get(K key) and I’m wondering why (same thing for remove, containsKey, containsValue). Answers:

Unable to decrypt config property in Spring Cloud config using asymmetric encryption

Questions: I am trying to load the decrypted config property from config server but failing with below error: 2018-08-07 09:58:26.534 WARN 20400 — [nio-8888-exec-3] o.s.c.c.s.e.CipherEnvironmentEncryptor : Cannot decrypt key: password (class java.lang.IllegalStateException: Cannot load keys from store: class path resource [server.jks]) This error happens when server.jks is placed in the classpath. But when placed in… Read More »

Which of these two code segments is more efficient?

Questions: I’m writing a Java method to go through an array of objects and add one at a specified location (dropping the one at the end), and I’m wondering which is more efficient: This public static void insertCandidateInt(Candidate [] Candidates, int inPosition, String nameToAdd, int votesToAdd) { for (int i = Candidates.length – 1; i… Read More »

FTPClient How to get around org.apache.commons.net.io.CopyStreamException: IOException caught while copying

Questions: I am trying to upload a .zip File with my Java application to an FTP server using the Apache Commons Net FTPSClient. <pre><code>import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.UUID; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPSClient; public class FTPUploader { /** * Zips the source file first and then uploads it to the ftp… Read More »

Cannot find a image file that exists in java

Questions: I have written a function which takes in a BufferedImage and compares it to a pre-existing image in my hard drive checking if they are same or not. public boolean checkIfSimilarImages(BufferedImage imgA, File B) { DataBuffer imgAdata = imgA.getData().getDataBuffer(); int sizeA = imgAdata.getSize(); BufferedImage imgB = null; try { imgB = ImageIO.read(B); } catch… Read More »

Flink cluster deployed with “Fencing token not set exception”

Questions: What does mean this exception? I am trying to deploy flink cluster(v.1.5.2) with 3 nodes in HA mode (zookeeper). I have following flink-conf.yaml settings: high-availability: zookeeper high-availability.storageDir: /flink/ha high-availability.zookeeper.quorum: {node1_ip}:2181,{node2_ip}:2181,{node3_ip}:2181 high-availability.jobmanager.port: 50010 high-availability.zookeeper.path.root: /flink high-availability.zookeeper.path.namespace: /default_ns Zookeeper cluster is running. After start-cluster.sh executed I have only one working node. Another 2 nodes return {“errors”:[“Could… Read More »

how to get data from Edit text once checkbox is checked

Questions: i want to get data from edit text once i check a checkbox using edit.getText().toString, but everytime i run the code it’s telling me that it’s empty and i tried to clear focus from edit text and request it by the checkbox i tried the editText.clearFocus(); but that didn’t work either pls help me… Read More »