IntelliJ not recognizing/forgetting to use xml context files
I have an old Eclipse project. We use developer profiles to store our own context files and configurations. I have my profile folder marked as resources. In my profile, I have another folder containing 2 xml files necessary for running part of the application. Fairly frequently, IntelliJ stops recognizing the files, though I made no changes to the files or their location. The app will start up, but when I navigate to the area of the app requiring the files, I get an error. The only thing that works is deleting them and re-adding them and refreshing the project, and eventually it picks them up. Sometimes it takes 10+ attempts at deleting/re-adding for them to get used. Reindexing doesn't work. Invalidating caches doesn't work. Running Ant compilation/clean tasks doesn't work. This is incredibly frustrating and I'm wasting a lot of time trying to just get the project to run normally.
Please sign in to leave a comment.
Please go through below checklist and see if it could help.
• Mark resources correctly:
In Project Structure → Modules → Sources, ensure your profile folder is under the module’s content root and marked as Resources. No parent/child should be Excluded.
• Ensure XMLs are copied:
Settings → Compiler → Resource patterns should include `*.xml`. Then do Build → Rebuild Project.
• Classpath check:
Your Run Configuration → Use classpath of module must point to the module that contains your profile resources.
• File flags:
Right-click each XML → File Properties → make sure Exclude from compilation is off.
• No overlapping content roots:
Remove duplicate or overlapping module roots (common after Eclipse import).
• If Spring XMLs:
Add a Spring facet and register those XMLs under it.
Bond Han Hi. Thank you so much for your reply. I confirmed the resources and root are marked correctly and the classpath points to my profile. I have used the Spring facet before, but I wasn't at the moment, so I added those. I also made sure xml was marked for use by the compiler. Unfortunately, none of those things worked.
Erin Have you checked from run configuraiton side also?
Bond Han Hello again. I am deploying the web app using Tomcat 9.0.100. Under the run configuration, I don't see any settings regarding classpath. Can you point me in the right direction?
If you’re deploying via a Tomcat run configuration, the classpath is controlled by the artifact, not by the run configuration itself.
Check if the XML files are actually packaged
Confirm the correct module is included in the artifact