Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have build errors with m2eclipse but not with maven2 on the command line - is my m2eclipse misconfigured?

I installed m2eclipse to build a java project in Eclipse.

I imported the project as follows:

Import->
Maven->
Existing Maven Projects->
Import Maven Projects->
- Select root directory
- Select pom file
- Click Finish

To be sure m2eclipse was actually building the project, I deleted the target directory and made sure it was re-created by m2eclipse and it was. But unlike with the command-line version of maven which built everything perfectly, m2eclipse leaves a large number of build errors in the source code.

Is it possible that I did not configure m2eclipse properly? How would I check this?

This is a github link to the project I'm trying to build. I'm getting the @Override build errors at this line. It says "The method createNewToken must override a superclass method".

like image 841
Chris Collins Avatar asked Aug 21 '10 19:08

Chris Collins


2 Answers

Update: The problem is the same as the one described in ‘Must Override a Superclass Method’ Errors after importing a project into Eclipse and here is what the accepted answer says:

Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).

Changing the compiler level to Java 1.6 would make the problem go away. To do so, modify the compiler plugin configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>

And update the project configuration (right-click on the project then Maven V Update Project Configuration) does solve the problem under Eclipse.

Or stick with 1.5 but remove the problematic @Override annotations.

I don't know how Taylor got things working with a Java 1.5 compiler level. And my guess is that the project wouldn't build on the command line with a JDK 5.


But unlike with the command-line version of maven which built everything perfectly, m2eclipse leaves a large number of build errors in the source code.

Hard to say what is happening exactly without seeing those "errors" (are them really errors?). Please provide some traces.

Is it possible that I did not configure m2eclipse properly? How would I check this?

One difference is that m2eclipse uses by default a embedded version of Maven 3 which is probably not the same version that you use on the command line. You can change that through Window V Preferences V Maven V Installation (and add your own installation):

alt text

But while I would recommend to use the same version under Eclipse than on the command line, this is very likely not the root cause of the problem, Maven 2 builds should run on Maven 3 without problems.

like image 160
Pascal Thivent Avatar answered Oct 07 '22 20:10

Pascal Thivent


I checked out the code. I have exactly the same problem. The code seems to be just broken.

Edit: It definitely is. Look at the class com.jappstart.service.auth.UserDetailsServiceImpl. It wants to override the method public final UserDetails loadUserByUsername(final String username) but this method doesn't exist in the interface the class implements and is has no superclass.

Edit: Ok, that doesn't explain why it builds with maven standalone. This also works for me. Very strange. It seems that there is something going on with the build that doesn't work with m2eclipse.

Edit: I'm pretty sure the code works because the bytecode is modified by the datanucleus plugin. When I run the project as maven build (right-click->Run->maven package) it sucessfully creates the war with m2eclipse. So my guess is that the problem is with the m2eclipse Maven Builder.

like image 23
Raoul Duke Avatar answered Oct 07 '22 20:10

Raoul Duke