m2Eclipse plugin with maven 3.0.3, no compilation errors, and jre5 with jdk7 - eclipse

Question about the m2 eclipse plugin. Currently I have "Eclipse Java EE IDE for Web Developers", the most recent update. I have the m2 eclipse plugin installed, and have started a normal java project. I then converted this to a maven project via
"right click->configure->convert to to maven project"
This appears to work, a pom.xml is created, the project converts, and everything is well and good.
The issue starts when I do anything to this project. In the maven settings for the project "Right client on project -> maven" there are several options that are behaving strangely, updating maven configuration will change the default JDK for the project (JDK7) to j2SE-1.5..., which was never installed on the machine, and of course is not found. Also code completion, and and error checking is not working in the editor.
Example:
params.put("some_string", ); This should render "red" for compilation errors because there is no second argument to put(), however this checks out as okay according to the eclipse editor.
I have some done some research on this issue, and from what I can gather from Google, it appears that there are some issues with m2eclipse and this distro of eclipse however there is nothing to resolve this. Is anybody else having similar problems, or does anybody have any idea how to resolve this?
Please let me know if the is any other information I can provide, I didn't want to just paste my settings.xml into stack overflow.
Note: I have my settings.xml configured in Eclipse, and have specifies which jdk to use (7)
System information:
Maven version: 3.0.3
Eclipse Version: Eclipse Java EE IDE for Web Developers Version
All eclipse plugins have the most recent versions installed as of this post date, and there are no XML integrity errors, or anything of the sort.

For the JDK issue: in your pom.xml specify
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
and then do another "Update Project configuration". Then the JDK 7 should be set (at least works for me).

Okay, so the answer to this is the answer to so many other questions on Stack overflow and other sites.... "mvn eclipse:eclipse". I was under the impression that Eclipse "did this for you" on project startup, and that is apparently not the case. After running that on a brand new work-space after an eclipse re-install (new computer) everything works fine.
I felt the need to close this one out. Thanks for the help though.

Related

Eclipse Neon + JBossTools + Maven results on error: No compiler is provided in this environment

I'm having some problems when trying to install wildfly.swarm addon (https://github.com/forge/wildfly-swarm-addon) through JBoss Tools on Eclipse
Maven keep telling me that java compiler was not found despite I have JDK correctly set on Eclipse.
But ok, first things first:
I installed Java 8 + Maven v3.3.9 + Eclipse Neon + JBoss Tools. Everything went fine...
Then, I tried to install wildfly.swarm addon (https://github.com/forge/wildfly-swarm-addon) through JBoss Tools.
Forged Console prompted me the following error:
Trying to solve this problem, I checked if JDK path is correct on Eclipse. It is:
I've also checked if system variables for Maven and Java home are correct. Also, everything seems fine:
At last, I went to Windows > Preferences > Maven > Installations on Eclipse
and added a new entry that point's to current Maven directory:
I've been looking some solutions on Stackoverflow and, between some sugestions, someone told to add tools.jar on JRE Definition. So, I did it, then restarted Eclipse, tried again to install wildfly-swarm through Forge Console but again... same error.
Did someone faced this problem as well?
Plus: I also tried to build Widlfly Swarm's example through mv package command and everything went fine:
I'm facing the same problem. I can run mvn install on command line, but not in eclipse. You can temporarily fix this problem by adding this in pom.xml
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_101\bin\javac.exe</executable>
</configuration>
</plugin>

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

Eclipse not picking up Maven attached source on debug

I've downloaded the source for all the Maven JARs in my buildpath using Maven->Download Sources and mvn eclipse:eclipse -DdownloadSources=true, which worked! When I open up the build path I can see that the sources JARs are attached for every JAR file.
But when I run the damn thing on Tomcat 6 I keep getting "Source not found" page with "Edit Source lookup path" button. But the source is already attached in the build path. What isn't this working?
When I manually point it to the JAR file by clicking on the "Edit Source lookup path" button it works. And when I manually point it to the folder it does not work. Why isn't Eclipse or Tomcat picking up the attached source in the build path?
Note: I'm using apache-maven-3.0.4, apache-tomcat-6.0.16 and Eclipse Indigo Service Release 2.
Although this bug had the most votes of all bugs #Sonatype, it hasn't been fixed.
However I have filled an enhancement request on Eclipse Bugzilla and if you agree this issue "Source not found" should be fixed, please vote for it here.
You can found three workarounds here.
I found this com.ifedorenko.m2e.sourcelookup plugin. The link was provided in "Java Debugging: Source not found".
Go to Help > Install New Software .. and use
http://ifedorenko.github.com/m2e-extras/
to search for the links. After installing this plugin I was finally able to debug the source code of dependencies.
Use External Maven instead of default Embedded in Debug Configurations dialogue.
Please see example screenshot below (menu Run -> Debug Configurations...):
Configure external Maven
Tested environment:
Eclipse IDE for Java Developers: Oxygen.1a Release (4.7.1a), 64-bit (from spring.io)
Oracle JDK jdk1.8.0_144, 64-bit
Maven: 3.5.2
OS: Windows 10 Enterprise N, 64-bit
Test goal hpi:run (sample Jenkins plugin)
Window->Preferences->JBoss Tools->Source Lookup
make sure you have check "Automatically add the JBoss Maven source container to all JBoss As launch configurations".
and under "Automatically configure the Java Source Attachment",
choose "Always".
this helps myself out of the problem.
In my case the problem was related with the source code attached with the "Debug Configuration", maybe some remnants form a migration to Maven.
I solved it by going to the "Debug Configurations..." page and selecting the configuration in case, then at the "Sources" tab I restored the defaults, which added all the project's Maven dependencies.
I think I fixed this for myself by updating my Eclipse m2e.
I think I had version ~1.2, and then updated to latest [as of writing] 1.6.2.
The Eclipse Bug comments helped me figure this out.
Now I can debug into my gquery-dnd-bundle-1.0.6!
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${version.maven-source-plugin}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
The "target" maven project should emit it's source code before the "client" projects can have access to the source code. I solved the issue by using the maven-source-pluging in the "target" project: https://maven.apache.org/plugins/maven-source-plugin/index.html
Just use the following snippet in the pom.xml file of the target project, make a release, and use the release version into the pom.xml file of the client project. Then eclipse can automatically let you "jump" to the target project seamlesly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${version.maven-source-plugin}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

Error when importing Maven-GWT project ("No marketplace entries found to handle gwt-maven-plugin")

I'm using Eclipse Indigo on Win XP, Maven 3.0.3 and GWT 2.4. I created a Maven-GWT project using the Mavne gwt archetype. Then I opened Eclipse, went to File -> Import, selected Existing Maven Projects, chose the pom for my GWT-Maven project, and then got this dialog:
The errors are
No marketplace entries found to handle gwt-maven-plugin:2.4.0:generateAsync in Eclipse. Please see Help for more information.
No marketplace entries found to handle gwt-maven-plugin:2.4.0:i18n in Eclipse. Please see Help for more information.
No marketplace entries found to handle maven-war-plugin:2.1.1:exploded in Eclipse. Please see Help for more information.
Anyone know how to resolve these errors? It is wreaking havoc when I actually import my project and try and work with it. - Dave
Make sure you are not using the embedded Maven of Eclipse.
Go to Window->Preference ->Maven -> Installation->choose your own maven installation folder there.
EDIT
If your company pays for IDE, you should ask for IntelliJ the IDE for Java, which I would say is better than Eclipse in many ways, not saying Eclipse is not good, that's just a good alternative. And you won't have this issue to start with
If your pom is not specific as to the version of the maven-resources-plugin, that version will come from the superpom. By default, m2e uses an embedded copy of Maven 3.0.x. If the superpom there points to 2.4.3 and your 'outside-of-Eclipse' version asks for something else, then the Maven inside of Eclipse will go looking for 2.4.3 and fail due to the 'offline'.
Fix by configuring m2e to use the Maven installation you are using outside, or turning off 'offline' for one build.
If you want to use maven from your local installation instead of the embedded version that comes with m2e, You have to do this
Windows ==> Preferences ==> Maven ==> Installations ==> Click Add (select your local maven installation directory)
Installation Directory is not where local repository. It is where maven is installed.
After changing try right click on project then,
Maven ----> Update Project
See How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds
You can basically just copy the snippet from http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven#POM_changes_needed_for_Eclipse_Indigo and adapt to your plugins and goals.
I am using a different approach with maven, gwt and eclipse.
I am using the maven eclipse plugin to generate a .classpath and .project file and import the project manually into eclipse (not as a maven project).
My configuration for the maven eclipse plugin looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<buildOutputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</buildOutputDirectory>
<projectnatures>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
<projectnature>com.google.gdt.eclipse.core.webAppNature</projectnature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
</projectnatures>
<buildcommands>
<buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
<buildcommand>com.google.gdt.eclipse.core.webAppProjectValidator</buildcommand>
<buildcommand>com.google.appengine.eclipse.core.projectValidator</buildcommand>
<buildcommand>com.google.gwt.eclipse.core.gwtProjectValidator</buildcommand>
</buildcommands>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>com.google.gwt.eclipse.core.GWT_CONTAINER</classpathContainer>
</classpathContainers>
<excludes>
<exclude>com.google.gwt:gwt-servlet</exclude>
<exclude>com.google.gwt:gwt-user</exclude>
<exclude>com.google.gwt:gwt-dev</exclude>
<exclude>javax.validation:validation-api</exclude>
</excludes>
<linkedResources>
<linkedResource>
<name>war</name>
<type>2</type>
<location>${basedir}/target/${project.artifactId}-${project.version}</location>
</linkedResource>
</linkedResources>
</configuration>
</plugin>
Hope that helps
This helped me:
Delete the project from eclipse (but don't delete from disk)
Close eclipse
In your user folder there is .m folder.
Delete repository folder underneath it (.m/repository).
Open eclipse Import project as existing maven project (from disk).

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.