Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA add library to Tomcat

I'd like to add some libraries that would be loaded before my WebApp, something like adding the Jar to CATALINA_HOME\lib. How can I do that?

Equivalent in Eclipse:

Servers->Tomcat v6.0->Open Launch configuration->Classpath->User Entries

The problem I'm tryint to solve is that I need to include a library that contains javax.servlet.Servlet and that one cannot be loaded if not in the Tomcat system classpath. Error log:

INFO: validateJarFile([...]\WEB-INF\lib[...].jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

like image 312
spakendralo man Avatar asked Nov 04 '13 09:11

spakendralo man


3 Answers

You can do that by going to your Run/Debug configuration, go to one of your tomcat configured web appication, next to the application server combobox click on configure.
In the Application servers popup, you have a list of libraries click on the + button to add the Jar of your choice.

enter image description here

like image 73
Frederic Close Avatar answered Oct 22 '22 13:10

Frederic Close


You can do that by selecting a different Tomcat base directory when you configuring your Tomcat server.

Just create a separate directory (tomcatBase) and copy inside the conf directory from Tomcat installation; also create a lib directory and copy there the libraries you want to include. The final structure should look like this:

-TomcatBase
   |-conf
     |-catalina.policy
     |- ...
     |-web.xml
   |-lib
     |-myJar.jar
     |-myJar2.jar

Tomcat configuration screen

Using a different base directory will also allow you to use the same tomcat installation with different configurations and different libraries.

You could also upload that folder to your version control system, so any change on the server libraries could be shared by all users.

Hope this helps

like image 4
Adrian Lopez Avatar answered Oct 22 '22 15:10

Adrian Lopez


Unfortunately, this doesn't seem to work in IDEA 13 using Tomcat 7.

like image 1
Rasa Avatar answered Oct 22 '22 13:10

Rasa