2

I used Eclipse to create two dynamic web projects. One is meant to build/deployed, the other is a dummy project which contains classes, resources and jars to be included in other projects.

My project layout is like this:

Project PortalLogin

java sources: src folder + resources folder
build
target
common
WebContent/WEB-INF: lib folder + classes folder (actually empty, it is just a linked resource to the lib and classes folder of the common project)


Project PortalCommon

java sources: src folder + resources folder
build
target
WebContent/WEB-INF: lib folder + classes folder

The projects are linked together as follows:

enter image description here

This is also the reason why the "common" folder is present in the layout of the PortalLogin project.

However, when I deploy the PortalLogin Project to tomcat 7.0, the container complains he cannot find the source files of the common project and throws a ClassNotFoundException at the first class he needs:

Caused by: java.lang.ClassNotFoundException: company.acme.portal.common.webapp.UndefinedActionHandler at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216) ... 19 more

I looked into my tomcat server configuration and saw that in the "source" tab both projects were properly included:

enter image description here

The claspath doesn't shown anything suspicious?

enter image description here

As a final check I looked into my file system to see if the Common project has actually builded the .java source files into .classes files, and they are properly present.

My first attempt was using deployment Assembly as described in this question, but when I click on "java build entry", i just see an empty list and I cannot click on anything there.

My second attempt was also using deployment Assembly to add the common project and/or source folder of the common project as following. This did not solve the issue.

enter image description here

Lastly I tried adding the project to the classpath in the tomcat server configuration as described in this question. THIS DOES WORK... but now suddenly my tomcat cannot find any jar in web-inf/lib folder nor any jar in program files/apache/tomcat 7.0/lib. So adding the project there messes up something else and I don't know how to fix this.

enter image description here

Any thoughts?

EDIT: server module overview screenshot

enter image description here

Community
  • 1
  • 1
user1884155
  • 3,616
  • 4
  • 55
  • 108
  • could you send a picture from Servers view in eclipse ? with tomcat expanded – Radu Toader Dec 05 '14 at 12:42
  • I don't see a tab or button with label "Tomcat" in the server view. I added a screenshot of the overview instead. Can you derive any information from it? – user1884155 Dec 05 '14 at 12:56
  • Press Ctrl + 3 Write "Servers" - then a view will activate, that's the important view, or the Modules part from the screenshot you just sent. You should be able to add to modules your both projects. – Radu Toader Dec 05 '14 at 13:01
  • Ok I added it. First it was only the module "PortalLogin", but then I also added the module "PortalCommon" to see if it did anything. Both settings give the same class not found exception. – user1884155 Dec 05 '14 at 13:09
  • remove the Project PortalCommon from the Classpath - tomcat. Then go to project PotralLogin properties - java build path - > projects , add project PortalCommon. Build Clean, Stop tomcat and the Start it – Radu Toader Dec 05 '14 at 13:15
  • So do I need both modules on my server or only the portalLogin project module? – user1884155 Dec 05 '14 at 13:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66266/discussion-between-radu-toader-and-user1884155). – Radu Toader Dec 05 '14 at 13:20

1 Answers1

1

PortalCommon must not be a web project, it must be just java project.
Add PortalCommon to PortalLogin's "Build Path" and "Deployment Assesmbly"

Then Tomcat>Clean.

user1884155
  • 3,616
  • 4
  • 55
  • 108
outdev
  • 5,249
  • 3
  • 21
  • 38
  • I made a normal java project called "PortalCommon2" that has the contents of the PortalCommon. When I try to go deployment assembly in the project properties of PortalCommon2, it is no longer an option because it is not a web project? Are you sure your answer is correct? – user1884155 Dec 05 '14 at 17:00
  • Ok I did everything you said except the line "open portalCommon deployment assembly", but it worked anyway! Thanks for the clean solution – user1884155 Dec 05 '14 at 17:20
  • PortalCommon2's "Deployment assembly" option will become available when PortalCommon2 is added to the PortalLogin's "Deployment assembly". The PortalCommon2's "Deployment assembly" will allow to pacakge PortalCommon2's build path into the PortalCommon2.jar .So I should swap the 2nd and 3rd line of my answer. – outdev Dec 05 '14 at 17:54