urbaindepuce
urbaindepuce

Reputation: 523

Library is not copied to Tomcat directory when deploying

I am developing a JSP application to test calling a servlet with AJAX that returns a JSON object. I am using Eclipse as IDE. As library for processing JSON I am using Gson. To make that library available in my project I created a lib folder inside my source directory and copied the Gson library into it. After reloading the project in Eclipse I included it in my build path. I can use that library in my classes with no problem. I configured the JSP application to be deployed to my local Tomcat installation. When running the application everything gets deployed to .../tomcat/8.0.26/libexec/wtpwebapps/AjaxJson so that part is working. As I understood it the directory WEB-INF contains all the classes and libraries. The classes directory contains all the classes I defined, but the lib directory is empty. Thats the reason why everytime a servlet is requested that uses the Gson library I get a java.lang.ClassNotFoundException. What do I have to do to get Eclipse to copy libraries into the lib directory when deploying the application?

Upvotes: 0

Views: 1594

Answers (2)

user2953113
user2953113

Reputation: 569

Check the mappings in web deployment assembly in project properties. If you use maven, there is no need to copy dependencies manually.

Upvotes: 1

Tassos Bassoukos
Tassos Bassoukos

Reputation: 16142

It's been a long time since I used Eclipse for building WARs, but I think that marking the library as exported in the project Build Properties dialog will do the trick. If not, please do downvote.

Upvotes: 0

Related Questions