Reference to workspace project with Vaadin


i have a project that uses Vaadin as front-end and references another project in the workspace. I already added the project to the web deployment assembly of my vaadin project and the compiler does not complain, but at runtime i get java.lang.NoClassDefFoundError and java.lang.ClassNotFoundException when i try to use classes from the other project. Can you help me on this?

This sounds familiar, there was a discussion recently on this topic, but I forget where - it might have been on skype.

Deployment Assembly is the correct place to set this up, but it does not seem to work in all cases (BTW this is an Eclipse issu afaik - Vaadin is just a regular Dynamic Web Project in this respect). I think this depends on which type the other project is - if it’s a Dynamic Web Project for instance, Eclipse does not seem to know how you’d like that packaged (technically, you can’t really include a web-application in another…)

So: what kind of project is the other project?

(A quite common scenario is that you have an add-on project and a demo-project for that, and both are dynamic web projects → deployment descriptor does not work. The quickest workaround in this case is to not link the projects, but instead manually ‘export add-on jar’ to the demo project - it’s quite quick.)

Best Regards,

The other project is a conventional java project.

No one?
In the meantime tried to export the dependent project as a jar and include that jar, but it seems some of the jars included in the dependent project are not correctly found then

Is there already any solution for this problem?

You need to expost the conventional Java project as regular JAR, and place this JAR in the WEB-INF directory of the Vaadin project exported as WAR.

Thanks, but this may be a solution for deployment but not for development time. It seems to me like Eclipse messes up the deployment structure if the referencing projects are both web or vaadin projects.

A probable reson could be that your project is referring to interfaces (thats why you are able to compile your project) but when you run it, your project is unable to find the implementations (Class definitions), and throws the exceptions (java.lang.NoClassDefFoundError and java.lang.ClassNotFoundException).

Do you have Eclipse? In that case, you need to tell Tomcat that you want to use a Workspace project.

  1. Open Servers View (Window->Show Window → Other → search “Servers”)
  2. Double click on your configured Tomact installation
  3. In the “General Information” Area, click the link "Open launch configuration
  4. Go to Classpath Tab → User Entries → Add Projects
  5. Select Projects from your workspace.

This works, but I recommend creating a Jar file from the other project, put it in a library directory and add a resolver to your ivysettings.xml. Then you can add the project just like a normal to your ivy.xml.

Doing this in my case resolves the class not found error for the project I’m trying to reference, but then complains that it cannot find the vaadin classes that the referenced project uses. Both projects are vaadin projects.