0

I found several similar topics, like reading from inner structure etc, however it still does not solve my problem.

Project structure:

  • whole project -> war, which has:

    several jar's connected as dependency in pom.xml;

    context.xml in META-INF folder, which I need to read from one of jars.

  • part of it -> jar, which is dependency in war's pom.xml

I've tried a few solutions like:

        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream input = classLoader.getResourceAsStream("META-INF/context.xml");

However I did not expect that to work as I think my jar searches for this resource in its structure, not in war.

I need jar project to read context.xml from war project. So, jar is like inner structure and war is outer. Is that possible to do?

quento
  • 1,074
  • 4
  • 20
  • 43

1 Answers1

1

With getResourceAsStream() you have access to all resources in the classpath. The classpath of a webapplication consists of every jar under WEB-INF/lib and every file under WEB-INF/classes

META-INF is not in the classpath.

Please read the question: How to get resource from the context.xml file in tomcat webapp?

Community
  • 1
  • 1
Tobias Otto
  • 1,634
  • 13
  • 20