Skip to content

Tag: classloader

Why are log4j classes loaded by two class loaders?

I have a maven project for an application, which I run in a WildFly server. The project has log4j dependencies: I would like to get the LoggerContext like this: However, this results in ClassCastException: After some debugging, I have discovered that the problem is that the class LoggerContext is loaded via t…

Java: Reading from getResourceAsStream gets too many bytes

I’m trying to read a binary file, using getResourceAsStream. The problem is I get too many bytes back. The file is 56374 bytes long, according to ls, but when I read it in my code, I consistently get 85194 bytes. I get the same result with similar code: If I run the code without the resource, everything…

Java config file multidimensional array

I have a problem. For my code I have a config file with the following content: To read this config file, I have the following code: But now I need to change the format of the names to: The output varialbe has to be of the type: String[][] with as result: What is the best way to achieve this? Answer