4
votes

Recently I switched from eclipse to Intellij. I'm running a war on tomcat, and I need to add a external classpath (with property files) to the tomcat launch configuration. In Eclipse it's available in view servers - Tomcat (2click) -> open launch configuration -> classpath tab -> select user entries -> advanced -> Add Folder

In Intellij I tried Menu Run -> edit configuration -> select tc instance -> Configure -> add (+) classes But when I add the directory with property files the war still crashes during startup with the message that it can't find a property file.

The file is present and tomcat/eclipse starts successfully. In Tomcat I believe the path can be modified with setenv.bat. What can be wrong? Our final target is Websphere where this kind of environment dependent properties are loaded from a specific directory. So maven profiles is an option but is not useful in the final deliverable.

2

2 Answers

6
votes

In edit configurations -> After adding the Tomcat server using plus icon -> in the Server tab you can provide the property files location in VM options (See screenshot below)

The value to be given in VM options is:

-Xbootclasspath/a:C:\workspace\project\config\target\config-src\local

where C:\workspace\project\config\target\config-src\local is the path where the property files are present after the maven build

enter image description here

enter image description here

0
votes

There is currently no possibility to add classpath directly on server. You can add any classpath resource into build artifact, which is being deployed on server.

Do not forget to re-add artifact in Tomcat configuration settings after changing artifact!