Tomcat throws ClassNotFound exceptions for classes in other open eclipse projects

巧了我就是萌 提交于 2019-11-28 04:33:17

The reason that tomcat cannot find your classes is that the project dependency in eclipse is not seen by tomcat. To resolve the issue you can add the bin folder of project a to the tomcat classpath of the app running from project b.

Jalkin

What you need to do is this:

  1. In Eclipse go to Window > Show View > Servers > and open tab called Servers
  2. In Servers, double click the server you want
  3. This action should open a window entitled Overview, with your selected Server in the TAB
  4. In this window select: Open launch configuration, and click the link.
  5. In the Edit Configuration window, select the tab called Classpath
  6. In the ClassPath textbox, select the line: User Entries
  7. Now push the button on the right entitled: Add Projects
  8. In the resulting Project Selection window select the external project you want the server to find via click.
  9. Close these windows by clicking Apply then OK as appropriate as you work up the stack
  10. Restart your server in the Overview window

You should be ready to go. It's actually only a 2 minute exercise. Good luck

If you go to the project properties, pick the item "Deployment Assembly", click "Add..." and choose "Project", you can add the dependent project and the issue should be solved.

Right click on the web project which is added to container server and select Maven and then select Disable Workspace Resolution. Then your dependency project will start appearing as a jar like any other dependencies.

Right Click on the WebProject --> Maven --> Disable Workspace Resolution.

Have you installed the m2eclipse extension that know about WTP? Without it m2e will not work correctly for WTP projects. See this:

https://docs.sonatype.org/display/M2ECLIPSE/WTP+mini+howto

Simple way :

Run -> Run Configurations... -> Classpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!