Download xml file in java application

I need to upload the log4j.xml configuration file to my website in order to initialize logging. log4j.xml is in the com.test.config package.

when in j2se java application code

InputStream input = ClassLoader.getSystemClassLoader().getResourceAsStream("com/test/config/log4j.xml");

returns the original thread, but when I execute this in the servlet, it returns null. servlet is a java web application deployed on glass planet 2.1

who cares?

+3
source share
2 answers

If the file log4j.xmlis in the jar file, be sure to add the jar file to the servlet class path in Glassfish.

, , resources/com/test/config, resources .

+1

Thread.currentThread().getContextClassLoader(), , .

0

Source: https://habr.com/ru/post/1753353/


All Articles