Regarding Maven - eclipse

I am new to Maven and if you feel i am asking really basic question then please forgive me.
I am facing couple of problems with Maven mentioned below.
I am using Eclipse Luna 4.4.1 (Which comes with the Maven Plugin).Now i installed two plugins..out of which one is for subclipse(with SVNKit) and m2e-Subclipse which is used for integrating the maven with SVN.I downloaded the project in eclipse using svn plugin as "checkout as Maven project" and i could see the project being downloaded and now to remove all the errors related with the POM.XML i downloaded the Maven and given the local path of the Maven in the preferences > Maven > installations and changed the Global Settings and user settings files which are project specific.
1). Now even after doing all this circus i still can not see the Maven build options in my Eclipse.
2). I am not even able to clean the project from command prompt.
when i go to my project directory and type "mvn -version" which shows me the correct version of maven.
But when i try to clean it using mvn clean. it does not work.
Please help.
Regards.

Related

setting up a maven project in Juno Eclipse

I recently upgraded my Eclipse to Juno and am struggling with the way maven dependencies are handled.
I installed the m2e plugin. Still, many of my projects started complaining about libraries missing as if the dependencies specified in the pom were completely ignored. This happened despite right-clicking on the project, selecting Configure --> Convert to Maven project, which seems to be the replacement for what used to be "Maven --> Enable dependencies" before. When I looked at the Maven dependencies under the project directory, there were many fewer dependencies listed than in my pom.
Running a maven compile on the command line outside of Eclipse allowed my project to build and after selecting Maven --> Update project, I was able to see the dependencies added or removed accordingly to what I specified in the pom.xml.
Bottom line: maven dependencies seem to work now but I had to do some combination of operations I didn't think should have been needed:
- Configure -> Convert to Maven project
- Maven -> Update dependencies
- Run maven outside of Eclipse
To get everything to work when with previous versions of Eclipse, all I had to do was Maven -> enable dependencies. What is the equivalent of this in Juno, i.e. what is the correct way of setting up juno Eclipse to handle properly a maven project?
I have been using Juno for a while now and the reliable way to solve Maven dependencies from within Eclipse after importing a project that is maven based is simply:
Configure --> Convert to Maven project
Maven --> Update project
Running Maven outside of Eclipse doesn't seem to help.
I am not sure why these two steps are now required when they were not before with previous version of Eclipse (at least, two steps were not needed before for sure).
Running
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
outside of Eclipse has brought me the problems I described in my comment to the other answer.
On a Mac running Windows under Parallels Desktop on OS X? This similar discussion may solve your problem: intellij - java: Cannot find JDK '1.7' for module

How to deploy a maven project in tomcat within Eclipse

I have been trying to deploy a project that I created within eclipse but when I right click on the tomcat server and click "Add and Remove...", I got the message "There are no resources that can be added or removed from the server".
From what I understand it has something to do with the facets? I am not really sure to understand what is going wrong here.
Here is what I did for know:
I created a Maven project.
executed mvn eclipse:eclipse through the command line on the folder of the project
installed m2e
tried to add the project to the tomcat server
You probably want to use either mvn eclipse:eclipse OR m2e, but not both. m2e has gotten MUCH better in the last couple years, so that's what I would suggest.
Make sure you are using Eclipse for Java EE, otherwise you will need to install other plugins like WTP
Install m2e.
Install maven integration for wtp (from the eclipse marketplace)
make sure the artifact type for your project is war
Import Existing Maven Project in eclipse and browse to your pom to import the project.
It should give the correct facets to your project so it looks like a web project.

How to fix error "Updating Maven Project". Unsupported IClasspathEntry kind=4?

I have imported maven project in STS, when I run update update project I receive:
"Updating Maven Project". Unsupported IClasspathEntry kind=4
Is there a workaround for this?
This issue has been fixed in m2e 1.5.0 which is available for Eclipse Kepler (4.3) and Luna (4.4)
Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=374332#c14
The problem is caused by the fact that STS (the Spring IDE/Eclipse), as well Eclipse and other Eclipse based IDE's, use the m2e(clipse) plugin but that eclipse:eclipse has been probably been run on the project. When m2e encounters a "var" .classpath entry, it throws this error.
The update sites are specified at the following url:
http://eclipse.org/m2e/m2e-downloads.html
If you can't use m2e 1.5.0 for any reason, then :
Disable the maven nature for the project (via the right-click menu)
Run mvn eclipse:clean (while your project is open in STS/eclipse). Depending on the timing, you might need to do a refresh or two on the project before re-enabling the maven nature. You should be able to see that your project has lost it's Maven nature. (The eclipse:clean goal just deletes the .project, .classpath and .settings/ files/directories. You can also just remove those files (again while the project is open) instead of running mvn eclipse:clean.)
Re-enable the maven nature.
(Most of the time, this can be done by right-clicking on the project in question in the package explorer pane, and then choosing 'Configure'-> 'Convert to Maven Project')
Right-click on your project, select Maven -> Remove Maven Nature.
Open you terminal, go to your project folder and do mvn eclipse:clean
Right click on your Project and select “Configure -> Convert into Maven Project”
Now you got “Unsupported IClasspathEntry kind=4 Eclipse Scala” disappear.
Sometimes, even re-importing the Maven project will not work. Updating the project correctly in eclipse is not a deterministic process.
The only 100% fail safe procedure I've found is:
Disable Maven Nature, run mvn eclipse:clean, restart, cross your fingers and Pray 3 times.
If this won't work, delete the project, run mvn eclipse:clean, re-import refresh, pray and use the force.
If this still doesn't work, restart Eclipse, or even better your computer. While waiting for the reboot, you can make a random donation to fix your Karma. Repeat step 2 and don't forget to pray and control your anger. Anger leads to hate. Hate leads to suffering.
Try all the other answers posted in this thread. You might need to try them all for 3 times at least before giving up.
Format your Computer, re-install Eclipse and Maven. No need to pray anymore, all gods hate you anyway
Delete your git project, burn the physical drive that stored the remote repository, and write your project from scratch.
Find a time machine, travel to the past and convince yourself to follow another, non-programming career or at least to avoid Java
Make sure that the version of the m2e(clipse) plugin that you're running is at least 1.1.0
Close maven project - right click "Close Project"
Manualy remove all classpathentry with kind="var" in .classpath file
Open project
or
Remove maven project
Manualy rmeove .classpath
4 Reimport project
Have you tried:
If you have import project into the eclipse 4, please delete it.
In maven consol, run: mvn eclipse:clean
In Eclipse 4: File -> Import -> Maven -> Existing Maven Projects
Seeing all other answers. I found for me a simpler way.
I just removed all lines in the .classpath (editing with eclipse) containing a var and used maven -> update project without an error.
This error is also thrown if the update command is used on a project instrumented for code coverage with Clover.
To resolve in this scenario:
Un-instrument the project folders you wish to update.
Run the maven update then instrument for code coverage again.
I tried Marco's steps but no luck. Instead if you just get the latest m2e plugin from the link he provides and one by one right click on each project -> Maven -> Update Dependencies the error still pops up but the issue is resolved. That is to say the warnings disappear in the Markers view. I encountered this issue after importing some projects into SpringSource Tool Suite (STS). When I returned to my Eclipse Juno installation the warnings were displaying. Seeing that I had m2e 1.1 already installed I tried Marco's steps to no avail. Getting the latest version fixed it however.
I couldn't get mvn eclipse:clean etc to work with Kepler.
However I changed creating and extending variables to just using external jars in my eclipse classpath. This was reflected in no var's in my .classpath.
This corrected the problem. I was able to do a Maven update.
This issue (https://bugs.eclipse.org/394042) is fixed in m2e 1.5.0 which is available for Eclipse Kepler and Luna from this p2 repo :
http://download.eclipse.org/technology/m2e/releases/1.5
If you also use m2e-wtp, you'll need to install m2e-wtp 1.1.0 as well :
http://download.eclipse.org/m2e-wtp/releases/luna/1.1
Upgrading from Kepler to Luna worked for me.
I had just added some components for Java 1.8 support. It seems that they where not as compatible as I would like or that I mixed the wrong ones. It really caused a lot of problems. Trying to update the system reported errors as they couldn't fulfill some dependencies. Maven upgrades didn't work. Tried a lot of things.
So, if there is no reason to avoid the upgrade just add the luna repository to avalilable software sites (Luna http://download.eclipse.org/releases/luna/ ) and "check for updates". It is better to have all the components with the same version and there are some nice new features.
I tried all the steps mentioned here and on similar questions but couldn't solve this problem. I could neither solve problem nor update my m2eclipse. So I installed Eclipse Luna and it solved my problem... though it mean that I had to spend about 45 min to configure all the environment in my workspace.
Try
mvn clean install eclipse:eclipse -Dwtpversion=2.0 command on DOS command prompt.
Suggesting you because , It worked for me!!
I'm using Eclipse 4.3.2 (Kepler) with M2E 1.4.x and felt over this problem several times!
In my case the "mvn eclipse:eclipse" command also generates Checkstyle, PMD and Findbugs configuration so "mvn eclipse:clean" does not help me because it drops all those config files again.
The best solution for me was to delete all ".classpath" files:
find . -name ".classpath" -delete
and import the project into eclipse afterwards.
Before importing the project, it should be converted into eclipse project
mvn eclipse: eclipse
Then i found the following error.
An internal error occurred during: "Importing Maven projects".Unsupported IClasspathEntry kind=4
Where is the value kind = "var" that M2E does not recognize and therefore throws the error.
Now type this.
mvn eclipse: clean
Now refresh the project in eclipse or re-import.

Eclipse:Run on server option not visible for maven project

I'm running through the jboss as7 getting started guide here http://hudson.jboss.org/jenkins/job/JBoss-AS7-Docs/lastSuccessfulBuild/artifact/guides/developer-getting-started-guide/target/docbook/publish/en-US/html/helloworld.html . The tutorial has us setting up an example helloworld quickstart maven project.
I'm able to deploy this project from the command line successfully
mvn package jboss-as:deploy
but when I attempt to deploy the helloworld example from Eclipse - the 'run on server' option is missing from the run menu. I have Eclipse 3.7 and maven wtp installed.
Not sure how to fix, any advice appreciated.
The run on server related options only appears if your project has the Dynamic Web Moudle project facets.
You can try to configure it using the Project Facets options in your project properties
To help any other developer with this problem.
I was dealing with this issue recently. Maven projects are structured differently than Dynamic Web Projects. So when you manually add the Dynamic Web Module using Project Facets, eclipse may not register it properly as a Maven project.
To solve this, you have to install the m2e plugin and M2E Eclipse WTP plugin (this tells Eclipse how to run your maven projects).
Go to Help -> Eclipse Marketplace to search for the plugins.
After installing, you will need to restart Eclipse then you will be able to use "run on server" for your Maven projects.
Note: You may need to remove/delete the previous project then import/create it again after the restart.
You have to add maven eclipse pluginin your pom.xml file..
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
</plugin>
According to Red Hat's site, The M2E Eclipse WTP plugin (m2eclipse-wtp) has been deprecated in favor of the newer m2e-wtp plugin. If you don't want to go through the marketplace, the URL for the new plugin is http://download.eclipse.org/technology/m2e/releases.
After copying the project and refreshing it, closing and reopening it, removing and re-adding it (right-click on server) and updating Maven... the option reappeared.
I think it occurs when you up the version of the Java compiler in your .pom file, when you up the compiler in project properties or it has to do with using the newer Jersey (2) version or when you both include local libraries and maven dependencies, it may also be a consequence of a combination of these. It's pretty unclear.
Note though, that you can still add/remove projects by right-clicking on the server in the servers tab.

maven adds dependency but eclipse does not see it

I've created a new project in maven like this:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
After that I use: mvn eclipse:eclipse
The problem is that when I add the project to my IDE, eclipse indicates errors. When I run it I get classNotFound for JUnit. In project properties I see that junit is added to build path
In project properties I see: M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar
But I cant use for example: import junit.framework.Test;
Why is that? To be honest, I have some major problems with dependency in maven and eclipse. Maven adds them correctly but eclipse doesn't see it correctly. It's not only the junit. What should I check/set?
Should I install some plugin to eclipse for maven support ?
EDIT
I thought again about everything. Of course the problem was small. M2_REPO was not recognize by Eclipse. I've added this variable and set it in od maven directory. It worked like a charm.
You can use the m2eclipse plugin for eclipse
http://m2eclipse.sonatype.org/installing-m2eclipse.html
I don't know if having the plugin would solve your problem, I used to do the command line before I started using m2elcipse, I never had the issue that you described
what version of eclipse are you using?