Adding another project as a dependency to Vaadin-Maven Project

Hi everyone,

I am trying to add another project as a dependency to my vaadin project . Here is the step i follow,

1- Create Vaadin-Maven Project from command line.

mvn archetype:generate
2- After created project, i executed “mvn install” and “mvn jetty:run” and worked perfectly.
3- In eclipse, file->import->existing maven project, i imported project to eclipse
4- I added object which is releted my dependency project.

MavenMain mainObj; //Dependency project’s class
Button button = new Button(“Click Me”);
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label(mainObj.getMsg()));
) });

5- Normally, eclipse gave an error about finding class. So i added dependency.


6- Execute mvn eclipse:eclipse command from terminal. Then, i select “organize input” options from eclipse.

After applied this steps, eclipse still can’t find my dependency project’s class. I think problem is vaadin related. Because, i create basic maven project from eclipse and followed same steps and works perfectly.

Is there any problem with Maven2 -Vaadin7 about adding dependency ?

No, there are no problems.

Try to do the following inside Eclipse:

  1. Add dependency to pom.xml file
  2. Maven/Update Project with cleaning
  3. Refresh project
  4. Run/Build… package jetty:run

Thanks for reply, i just followed your steps results are below

2014-11-10 11:16:51.274:INFO:oejs.AbstractConnector:Started SelectChannelConnector@[INFO]
Started Jetty Server Nov 10, 2014 11:17:16 AM com.vaadin.server.DefaultErrorHandler doDefault
java.lang.Error: Unresolved compilation problems:
MavenMain cannot be resolved to a type
MavenMains cannot be resolved to a type

I think you have problem with external project.

Let’s do the following:

  • mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=my -DartifactId=my-lib
  • cd my-lib
  • mvn install
  • cd …
  • mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.3.4
  • after that add dependencies into the just created vaadin application:

suppose library and vaadin project have the same version (in my case 1.0-SNAPSHOT)

  • cd my-vaadin-app
  • mvn package jetty:run

I have no problem with it. What about you?

Thanks a lot, it is working. While i am following your instructions, i found my mistake. Thanks again Anatoly, you save my day :smiley: