Unable to read file from my WEB-INF folder

Answered

I have the following facet config for an appengine module :

<facet type="web" name="Web">
      <configuration>
        <descriptors>
          <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
        </descriptors>
        <webroots>
          <root url="file://$MODULE_DIR$/src/main/webapp/info" relative="public-root/info" />
          <root url="file://$MODULE_DIR$/docs/ui" relative="public-root/apidocs" />
          <root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
          <root url="file://$MODULE_DIR$/target/backend/WEB-INF" relative="WEB-INF" />
        </webroots>
      </configuration>
    </facet>

I have a file in the WEB-INF folder that I try to read by doing new File("WEB-INF/filename").
When running in terminal with mvn appengine:devserver everything works fine.
But when running debug in Intellij, I get a FileNotFoundException.
I checked the file is copied to the target dir.
This is a maven project and the facet is automatically generated by importing the maven project.
(I had it working before upgrading from appengine plugin to google cloud tools)

I have already reinstalled Intellij, removed the .idea and .iml files and reloaded the project. Nothing seems to work.
How can I make it work?

0
3 comments
Avatar
Permanently deleted user

I have made a test. I have remove the logging.properties file from the target WEB-FOLDER folder (/project-dir/module-dir/target/module-name/WEB-INF).
When I run the module, I get a FileNotFoundException for logging.properties. Meaning the this is the actual folder from which the webResources are loaded.
The file I'm trying to read is in the same target folder and I'm not able to read it.

0
Avatar
Permanently deleted user

I have added the following debug code :

 

System.out.println("########### " + new File("WEB-INF").getAbsolutePath());

When run from withing Intellij I get :
/Applications/IntelliJ IDEA.app/Contents/bin/WEB-INF

When run from my terminal, I get :
/Users/userName/Documents/workspace/projectName/moduleName/target/backend/WEB-INF (changed folder names to generic once).

The code comes from another project module and it is added as a maven dependency in my module.

 

0

Please sign in to leave a comment.