Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sources from referenced projects are not deployed to Tomcat in Eclipse

I have setup a dynamic web project in eclipse with JSF in which I trust on code from another project (framework). Therefore, I added the framework project to the build path of the website project.

So far so good, Eclipse recognises every class and the project builds without errors.

Problem is though that when I do "run on server" to test it on tomcat 6.0.24, the application fails. I get ClassNotFoundException on every class from the framework project.

Is this a bug or is some specific configuration necessary for this?

like image 805
Steven De Groote Avatar asked Jun 02 '10 14:06

Steven De Groote


People also ask

Why Tomcat is not working with Eclipse?

Most of the time, this means that Tomcat is already running in the background and Eclipse is trying to open it again on the same ports. This is obviously not possible, as the ports will be in use. The issue typically arises from either the Eclipse or Tomcat process crash or being stuck.

Why I am not getting run on server option in Eclipse?

Recently i found that once i have imported a project as an existing maven project to the eclipse, it does not show the run on server option. The reason is that it is not a dynamic web project. So go to project properties and change it to dynamic web project as follows. Now it should be working.

How do I update Tomcat in Eclipse?

For configuring the tomcat server in eclipse IDE, click on servers tab at the bottom side of the IDE -> right click on blank area -> New -> Servers -> choose tomcat then its version -> next -> click on Browse button -> select the apache tomcat root folder previous to bin -> next -> addAll -> Finish.


2 Answers

I was googling and ended up here for a similar problem. I wanted to make a note for others about the current situation on Eclipse Indigo, as the terminology has changed a bit by the looks of things.

On your project properties, do a filter/search for "deployment assembly".

It is then straightforward to add a project dependency. Job Done.

Thanks to Alexander's edited answer which led me to this.

like image 111
Aitch Avatar answered Nov 03 '22 23:11

Aitch


Did you check Warnings in Problems view?

Do you see Classpath entry /your/framework.jar will not be exported or published. Runtime ClassNotFoundExceptions may result warning?

If you do.

  1. Right-Click the warning and choose Quick Fix.
  2. Choose "Mark the associated entry as publish/export dependency." from Select a Fix box.
  3. Click Finish.

EDIT
Now, I think I understand where disconnect is. I think now I remember the joy of figuring this out for the first time.

In your website project ( I will speculate here , but I guess you've created it as a Dynamic Web Project ):

  1. Open project properties
  2. Select Java EE Module Dependencies panel
  3. Check your framework project in JAR/Module column. Beware, that for reasons not known to me, the list is not sorted ( and is not sortable ) in any particular order, so you may need to search for your project reference there.

The results of this operation will be written to /website-project/.settings/org.eclipse.wst.common.component file. Put this file into your source control.

like image 38
Alexander Pogrebnyak Avatar answered Nov 04 '22 00:11

Alexander Pogrebnyak