How to get an EAR to read a properties file from a WAR?

I am using Wildfly 11 and Java 8. I am trying to deploy an EAR file containing multiple WAR files. One of my WAR files contains this in his web.xml ...

<context-param>
    <param-name>Owasp.CsrfGuard.Config</param-name>
    <param-value>csrfguard.properties</param-value>
</context-param>

This file is in one of my WARS in

myapp.war/WEB-INF/classes/csrfguard.properties

When I deploy WAR myself, everything deploys normally. However, when I deploy the EAR containing the WAR, I get an error complaining about the inability to find the properties file ...

Caused by: java.io.IOException: unable to locate resource - csrfguard.properties
    at org.owasp.csrfguard.CsrfGuardServletContextListener.getResourceStream(CsrfGuardServletContextListener.java:85)
    at org.owasp.csrfguard.CsrfGuardServletContextListener.contextInitialized(CsrfGuardServletContextListener.java:36)
    ... 10 more

I feel that there is a class loader issue, and I don't understand how to work. How do I tell my EAR file where to find the properties file?

+4
source share
1 answer

, csrfguard.properties, getResourceAsStream, .ear, CSRFGuard?

context.getRealPath, .war:

<context-param>
    <param-name>Owasp.CsrfGuard.Config</param-name>
    <param-value>WEB-INF/classes/csrfguard.properties</param-value>
</context-param>
+1

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


All Articles