How can I link and export another project when developing a J2EE web application?

I have several J2EE projects using servlets, each of which extends from a base class that processes the main doGet and doPost methods and calls more specific methods in subclasses. Instead of having this base class as a class in each WAR file, I want to move it to my JAR, which can reference each of the other projects.

I am using Eclipse. So, I created a new Java project and moved the base class there. He complained about the lack of a reference to servlet-api.jar, so I added it there. Then other projects complained about the lack of links to this new project, so these links were added.

Now they no longer complain, but when I start the project (opening the servlet class and select Run As), it does not export classes from another project, and Tomcat throws an exception when trying to create an instance of a subclass of an unknown class.

How to tell eclipse to export both the servlet project itself and this other java project to which it refers?

+3
source share
2 answers

I am using Eclipse. So, I created a new Java project and moved the base class there. He complained about the lack of a reference to servlet-api.jar, so I added it there.

, Java Build Path > Libraries > Add Library > Runtimes a > [ ] (, , , ).

, .

, .

, ( Run As), , Tomcat .

- . Java EE , .

+4

CLASSPATH . , "Run As...", . , , , .

0

Source: https://habr.com/ru/post/1733558/


All Articles