I'm trying to create a simple webapp as a maven project with m2e to help me manage dependencies, but I'm must be missing something, because I'm not able to run the project from eclipse.
To put a bit more context, here is what I do:
First, I choose to create a "Maven project"
Then, I select the "maven-webapp-archetype"
Finally, I fill the basic project information form of the next step and finalize project creation. Everything looks fine at this point.
The problem is that when I try to run the project, I don't find anything suitable to run the project on a local server:
Also, from the "Add and remove..." context menu entry of the local server, my project doesn't appear in the list of web projects.
Did I miss a step in the setup, or is there an other more suitable way to start the project?
You should install the m2e-wtp connector.
You can install this from: Window, Preferences, Maven, Discovery, click Open Catalog and search for wtp. Check the box next to m2e-wtp, and click Finish.
Once the installation process has completed, allow it to restart Eclipse. After that, you may need to right click on the project, choose Maven and Update project.
Related
I have Eclipse Indigo 3.7 base with MyEclipse 10 Java enterprise development plug-in:
I have installed Sonar plug-in for eclipse.
Installed Sonar server and running it locally from localhost (localhost:9000)
Tested the Server connection in Eclipse from
Windows>Preferences>Sonar>Servers. Connection is successful.
For my Project, ran the Maven goal for sonar (sonar:sonar). Build is
successful. I am able to browse the results in localhost. (localhost:9000)
My issue is with Associating the project to Sonar.
When i right click on my project, Configure > Associate with Sonar, I get a screen where nothing happens.
Basically the screen has 2 fields,Project and Sonar Project.
The Project field contains the name of my Project and Sonar Project field lists this message - "click here to start searching for a remote Sonar project"
I click on that field and enter my groupid:artifactid but nothing
happens.
I also tried entering the Project Name listed in Sonar dashboard
but that also does not help.
When i right click on my project, In the context menu i am unable to see 'Sonar' option.
Help me associate my project to Sonar in eclipse. Please let me know what i am missing.
Thanks in advance.
I had the same issue with my Liferay project in Eclipse (liferay-plugins-sdk.6.2.0) and here is how I got it working:
Install the eclipse plugin, and test server connection
Install the Sonar server and start it (for example on yourhost:9000)
Go to yourhost:9000 and login (admin/admin unless you changed it)
Go to Settings -> System -> Provisioning
Create new project (+Create in the top right corner)
I've used key=Liferay6.2 and name=liferay-plugins-sdk-6.2.0
After the above steps I went back to my eclipse project and in Configure > Associate with Sonar I was able to search/find the liferay project.
When using Sonar Eclipse, you can associate Eclipse projects only to the corresponding Sonar modules (unless you are working on a single-module project, which is pretty rare in fact).
This means that you can't associate the root project (which is logical as by definition, a root project has no sources in Sonar). You have to right-click on all the imported Maven modules, and associate them all in a single run.
Go to your project folder in eclipse workspace from the terminal and run following command:
mvn sonar:sonar
This command will create your sonar project. Try associating the project again. Make sure you enter the name associated with your project from your
pom file. (Clear the text field)
BEST ANSWER AFTER SO MUCH ANALYSIS(I have faced the same problem)
Forget to add to associate with SonarQube first
If you want to add sonar group id create sonar-project.properties
Just add below code
# Required metadata
sonar.projectKey=javapractice
sonar.projectName=javapractice
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
download sonnar-runner from github.
download sonar example from github
download sonar
run sonar as per your operating system from command prompt
go to sonar example path like c:/sonar example/java/.. /.. *.properties path (beside src)
run sonnar-runner c:/.... / sonnar-runner.bat -e
go to browser http://localhost:9000 after that (login:admin/admin)
your project is displayed in the browser.
Choose Maven on the project and then choose Select Maven Profiles and then choose with-sonar in Eclipse. This will enable the Sonar functionality on projects. Now you will see the Sonar option when you right click on projects.
I know Maven pretty well, but I usually work with Netbeans, which makes it quite easy to deploy Java EE applications - and handle hot deployment of any changes.
The team I work with now uses Eclipse as their IDE of choice, but none of them has worked with Maven projects before; so I need to know how to correctly add Eclipse's project facets to the maven projects we have, in order to support (hot) deployment through WTP. We are using Weblogic 12c for this particular endeavour.
Our project layout is as simple as it gets:
super-project (pom)
project-ear (pom)
project-ejb (pom)
project-web (pom)
Thanks for any resource you can point me to.
I suppose that you've installed all required plugins to the Eclipse already. As #MichaĆ Politowski mentions, M2E, M2E-WTP and so on.
Add Archetype Catalog
Go to menu Window--->Preferences.
At the Preferences window, select Maven---->Archetypes,
On the Right Panel, click Add Remote Catalog... button.
At the Remote Archetype Catalog windows enter the following: -
Catalog file: http://repo.maven.apache.org/maven2
Description Maven Central
Add more remote catalog.
Catalog file: http://download.java.net/maven/2
Description Java.Net
Click OK to apply change.
Create the parent project
Go to menu File ---> New ---> Other.
At the Select Wizard Windows, select Maven ---> Project.
Click next and enter the required information so that we are at the New Maven Project.
At the Filter textbox, enter pom
Choose org.codehaus.mojo.archetypes:pom-root:1.1
Click next and enter the required information so that the parent creation is finished.
Create the child project
Right click at the parent project and select New ---> Other.
At the Select Wizard Windows, select Maven ---> Project.
Click next and enter the required information so that we are at the New Maven Project.
You will see that the Parent Project = MY PARENT
Enter the Module name, e.g. my-ear, my-ejb or my-web. Then click Next button,
At the Filter textbox, enter some of the following
org.codehaus.mojo.archetypes:webapp-javaee6:1.5
org.codehaus.mojo.archetypes:ejb-javaee6:1.5
org.codehaus.mojo.archetypes:ear-javaee6:1.5
Click next and enter the required information so that the child creation is finished.
Summary
I've used both NetBeans 7.x and Eclipse Juno together. When I move to Eclipse I've face the issue as same as your. Then I've captured the steps above from NetBeans logs one by one, and do the same thing manually by using Eclipse.
I hope this may help.
I would make one small change:
Create the child project
Right click at the parent project and select New ---> Other.
At the Select Wizard Windows, select Maven ---> **Maven Module**
This way it will automatically recognize this as a child project of the parent.
I am learning Eclipse, and I'm trying to find out how to interact with Maven goals visually in Eclipse/SpringSource Toolsuite. In IDEA, there is a nice Maven menu on the right-hand side of the IDE that is put there by default - no extra user configuration is necessary to make this show up there.
How can I get the same thing in Eclipse? It seems weird that this is not enabled by default. I've looked in the "Window" section of the IDE and I also don't see it either. The only window dealing with Maven is the repository listings... which is not what I want.
Do people use the command line instead? How can I get the same thing that IDEA has?
If it is eclipse, get M2Eclipse plugin installed for your eclipse.
Just go to Help -> Eclipse Market Place and try to Find "Maven
Integration For Eclipse". In the results choose "Maven Integration
For Eclipse" and install it.
Then, if the project in your workspace is a Maven Project right click
on it and choose Run As -> it will show you some default goals
like clean, install, etc.. If you want to run other goals choose run
configurations and in the left part of the window, you will find an
option Maven Build. Right click on it and select New -> then you will
be prompted to choose the project and enter the goals you want to
execute...
I have a web app built with Maven.
Most of the time, I built the application using Intellij IDEA, but now I want to import the application in Eclipse to see something in this IDE.
After mvn eclipse:eclipse, I add in Eclipse the app, but when I try to add the app to the server (tomcat), I receive:
There are no resources that can be added or removed from the server
Solutions?
You need the project to have a Eclipse Dynamic Web Module facet. You can try doing this via the project properties dialog and looking at project facets, then clicking the appropriate check box. This may not be available however, so you may need to do the next thing.
Create a backup of your project and follow the directions at dzone.com. This'll allow you to modify the project facets via your eclipse .project file.
Keep in mind, once you add those facets, you cannot change them back via Eclipse. Definitely make sure you have a backup before starting.
This step worked for me:
Right-Click on the Project Name, then
Maven-->Update Project..
Click OK
After doing this I was able to see my project in Add/Remove Programs.
As mentioned somewhere else adding Eclipse WTP didn't do any good, however I performed the above step after I had already added Eclipse WTP, so I am guessing that may not be needed.
This was done for Eclipse Juno.
Hope this helps someone.
Edited: You can follow this link as above mentioned I think might have needed WTP and that add a lot of other things into the workspace.
http://blog.teamextension.com/maven-as-eclipse-dynamic-web-module-556
Check whether Maven Integration for Eclipse WTP is installed. If not, install it from Eclipse Marketplace
After installation restart Eclipse
Right click your project and Maven--> update project configuration
Delete tomcat and re create tomcat (clean tomcat,add your project,publish and enjoy)
I've got Tomcat 6, Java 1.6, and was trying to get it to work in Eclipse Juno Service Release 1's "internal server" (whatever that's called.) Here's what I did that worked for me:
(Found these instructions at http://www.mkyong.com/eclipse/eclipse-ide-tomcat-version-6-0-only-supports-j2ee-1-2-1-3-1-4-and-java-ee-5-web-modules/)
I should point out that I followed ClutchDude's instructions to make my project a Dynamic Web Module facet. It didn't work on its own for me, but maybe it was part of making it work in the end.
Using Eclipse (or other text editor), open the file
.settings/org.eclipse.wst.common.project.facet.core.xml
Find the line that reads
<installed facet="jst.web" version="3.0"/>
3.0 is for Tomcat 7.x (so says mkyong.) Change it to 2.5 (or 2.4).
I restarted Eclipse and it worked for my project.
The reason why this is happening is because eclipse by default looks for the deployment descriptor in the folder {project.home}/Webcontent/WEB-INF/web.xml where as the Maven puts them in src/main/webapp/WEB-INF/web.xml.
So when you are trying to add your project onto the server eclipse cannot find a deployment descriptor and hence you get the annoying message.
This can be solved by adding the following entries in .settings/org.eclipse.wst.common which can be found in
Project home folder in your workspace if it is a new maven project.
The folder where you already imported from if you are using Import -> Maven projects.
Make the following changes in to the org.eclipse.wst.common
wb-resource deploy-path="/" source-path="/src/main/webapp"/. Add this entry.
Edit --> property name="java-output-path"
Please check the following link from more details. http://java.dzone.com/articles/webapps-eclipse-and-maven.
The comments section has an excellent example with a working project.
This issue was fixed for me my installing additional eclipse modules. in particular, the ones related to m2e-wtp. just do a search for m2e in the plugins search listing for your version of eclipse
If you face an error like "There are no resources that can be added or removed from the server",
then
1) Go to the META_INF of your websvcsEAR and go to the application.xml.
2) Goto modules-> clickDetails and add the module that is existing. i.e., some EAR which your project demands.
3) Click ok
4) Now go to your server -> right click -> add and remove -> add your EAR.
Maybe you don't need add your application to the server's configuration. I think that you must use m2e eclipse plugin in order to launch the app.
For example, in your eclipse you will see a contextual menu called "Run as" if you right-click on your pom file. You can clicking on "Maven build" and Maven will download all the information needed to start tomcat.
I hope this helps you.
I used
mvn eclipse:eclipse -Dwtpversion=2.0
in command line in the folder where I had my pom.xml. Then I refreshed the project in eclipse IDE. After that I was able to add my project.
I was able to resolve this by removing my EAR project from my Eclipse workspace, then re-importing it.
Well, with a Spring and maven project, i got it that way:
Eclipse Version: 2019-06 (4.12.0)
Java 1.8
Tomcat 7
Yes, go to Project Properties >> Facets >> select Dynamic Web Module but dont apply yet!!!
Right under, it should appear a link Further Configuration Available. Click on it, otherwise one will have to edit .settings/org.eclipse.wst.common.component manually. Update source directory to src/main/java. (source)
Then in Facets window check Java - mine was pointing to 11 even though i don't have Java 11 installed or configured like a JRE runtime. I could only add/remove when changed to 1.8. (source). Note: That was really the problem, why don't Eclipse get this configuration automatically from the project?
Finally Eclipse creates some directories like WEB-INF and META-INF, just delete them.
I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.
I have managed to attach the sources to the libraries in the "Maven Managed Dependencies" classpath container, i.e. when I open a class file from a dependency (e.g. using Ctrl-Shift-T), I see the source code.
However, when I define a server connector for my tomcat, deploy the wepapp to it, and launch it in debug mode and execution halts on a breakpoint in that same class, the editor pane only displays the text "source not found", and a button to edit the "source lookup path". I have attempted to manually add the "Maven Managed Dependencies" classpath container, only to be told "Use maven project settings to configure depedency resolution". However, I see no useful setting in that property pane ...
How can I attach those sources? I am aware that this works with the m2e plugin and wtp, but I'd rather avoid convincing the rest of my team to switch plugins ...
Looks like issue MNGECLIPSE-983
I have confirmed that if I manually pick the External Archive option and find the relevant -sources jar (navigating that big .m2/repository tree to find it) and then add the jar as a sources it does work, and surprisingly it does remember the next time which isn't too bad.
That's at least doable I think for me because we don't often need to step debug through external dependencies, but when we do, it's often frequent, so adding it once while a bit of a pain, can be done on a case by case basis.
I have since discovered that this problem only occurs if the server is launched using a launch configuration.
The problem does not occur if the server is started by:
click the server icon in the toolbar -> context menu appears
mouse over the intended server -> submenu appears
click on "Start"
While this precludes sharing the server configuration by checking the launch configuration into version control, it at least allows seamless debugging.
Please do the following steps in Eclipse IDE(Tested with Version: 3.5.2),
In Package Explorer, Right Click on the Project which integrated with Maven container.
Select Maven 2 and then select "Fetch Source JARs".
The above action wil fetch sources of all the 3rd party jars present in the Maven Classpath.
Regards,
Rajesh.
Just put the .m2/repository/ folder itself with the search subfolders option.