I'm using M2E to create Maven archetype projects (in this case a simple web app) with the aim of using Maven to deploy to a remote tomcat server.
I've added the tomcat-maven-plugin to the POM.XML file, and it appears to be correct.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>localServer</server>
</configuration>
</plugin>
and when I type "mvn tomcat:deploy" into terminal it deploys successfully. So I know my settings.xml as well as my tomcat settings are in order.
Is it possible to deploy the application directly from Eclipse without having to go through the terminal. In other words is it possible to pass the command "mvn tomcat:deploy" from eclipse to maven?
Cheers
You can run all maven goal directly from Eclipse Run Configurations
http://mevenide.codehaus.org/mevenide-ui-eclipse/user-guide/run.html
Also you can configure Server View in Eclipse (WTP) and simply deploy (or auto deploy after file change) directly from eclipse (maven is not used in this process, he is only responsible for configure proper nature of your project - ex. war).
Maven Integration for Eclipse WTP (a.k.a m2e-wtp) aims at providing a
tight integration between Maven Integration for Eclipse (a.k.a m2e)
and the Eclipse Web Tools Project (WTP) .
m2e-wtp provides a set of m2e connectors used for the configuration of
Java EE projects in WTP. It features :
Support for war projects : adds the Java and Dynamic Web Facets.
Support war overlays and on-the-fly resource filtering
Read also this: Maven/Tomcat Projects In Eclipse Indigo/3.7
Related
I have a basic question about running a Java EE application on Weblogic using maven in eclipse.
I use OEPE (Oracle Enterprise pack for Eclipse) which comes with some plugins such as m2e and wtp. As far as I know this plugins read the pom file and based on them build the jar, war and ear files.
What I do right now is like this:
I check the build automatically option and let these plugins create my EAR file, then right click on the instance of weblogic server in Eclipse and add it to server using add/remove option and finally start the application server. This way when I change code in my classes they will be picked by application server and hot swap works.
Another way to build the EAR file is using the m2e plugin: right click on the parent pom file and choose maven install then start the application server and use the wls:deploy in order to deploy the EAR file. (This time I don't add the ear file to the application server from within the Eclipse and eclipse also is not aware of that EAR file when I right click on the instance of my weblogic inside the IDE).
As far as I've seen I can only add those artifacts to server which are built using the wtp plugin and not the artifacts that are built using maven command of m2e plugin. The problem with wtp and all these plugins (except for m2e which actually just runs mvn -install) is that they don't work flawlessly. Sometimes they don't build the artifacts correctly sometimes the jar files are obsolete and they don't get updated. Moreover when you use the jar file of one project in another maven project they get stuck with the jar file prior to your changes, while using the m2e they are built flawlessly.
Now here is the real question:
Which way is the correct one to have hot deploy?
Am I missing something? Is building the ear file using m2e plugin and deploying using wls:deploy enough? If so how will hot swap happen by itself or should i use wls:redeploy each time? If m2e is enough then I assume that I should abandon wtp plugin (it does not know all the plugins of pom file and I should sometimes mark them as ignored in lifecycle management xml file of eclipse).
I'm sorry that the question is that long but I hope that I made the case clear and get some help!
Let me provide you with my checklist to make my web application hot-deployed on Weblogic. This checklist assumes a weblogic version which implements Servlet 2.5 and assumes your project is a maven one which is configured to run maven-compiler-plugin for JDK 1.6.
In other words your weblogic version is 10.x.x and your POM includes the following snippet:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
To build a war
Use OEPE plugin to create a new Weblogic Web module Weblogic.xml file:
Don’t enable spring extension
In FastSwap: Don’t enable class redefinition
Take note of the value
<wls:context-root>myappcontextroot</wls:context-root>
it will be used later in the hot-deployment
Execute Maven update project from Eclipse context menu of your project
Execute Maven clean install
For hot-deployment setup:
Add local weblogic as a runtime server in Windows->preferences->Server->Runtime. Remember to change its Java home to the Sun JDK instead of JRocket for development mode.
Add local server in Server->add server
Project context menu->properties->Project Facet-> add faceted nature
Make Sure Jave Facet is version 1.6
Check Dynamic web application version 2.5 and make the target runtime be the runtime server declared in the first step + In further configuration give “context root” the value "myappcontextroot" which was noted above and give “Content directory" the value "src\main\webapp”. Don't generate web.xml otherwise your web.xml is overwritten
Push OK to apply all the above facet changes to your project
Again open Project context menu->properties->Deployment Assembly->Add java build path->Maven dependencies
Finally, in the server window Add configured application to the running server
Please follow these steps literally, it is really worth it!
I have create a maven project in eclipse .
I want to build my maven project using jboss and also debug it while running
Can any one share there code please on hot to use jboss with maven project.
i am trying to run maven project as dynamic web projects.
I have my maven project in my eclipse. i want to run project on localhost:8080/abc like this.
Please suggest me the settings.
Well, I dont know if this is what you are looking for, but if you just want to run your Maven Web project easily, you can use the jetty-plugin to run it.
The configuration would be:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.3.v20120416</version>
<configuration>
<webAppConfig>
<contextPath>/abc</contextPath>
</webAppConfig>
</configuration>
</plugin>
Firstly, your maven project should be a web project (<packaging> should be war for instance).
You should have Eclipse IDE for Java EE Developers.
You should configure a server in your Eclipse - say tomcat, jetty, etc.
Install m2e Eclipse plugin as well as m2e-wtp support plugin.
Import maven project to Eclipse. After it build you should be able to choose "Run as server..." option and specify the server you have configured.
I have a project that I created with the Maven Archetype plugin and I added the Maven Jetty plugin so I can run the jetty server with "mvn jetty:run-war".
Now I have to change my project so that it integrates with Eclipse and Tomcat. I remember working on some projects which when I clicked the Tomcat button from the Sysdeo Eclipse Tomcat Launcher plugin, it would automatically compile the new code, deploy it to the Tomcat's webapp folder, and start the Tomcat server for you. Using tomcat also allows us to use the integrated Eclipse debugger.
How do I get that effect with my current Maven/Jetty setup without re-creating the entire project over again and starting it as a Tomcat project?
You can try using Tomcat Maven Plugin. It has similar goals to the jetty plugin. You just need to add the plugin configuration to your existing pom and make no additional changes.
I set up a small web project with JSF and Maven. Now I want to deploy on a Tomcat server. Is there a possibility to automate that like a button in Eclipse that automatically deploys the project to Tomcat?
I read about a the Maven War Plugin but I couldn't find a tutorial how to integrate that into my process (eclipse/m2eclipse).
Can you link me to help or try to explain it. Thanks.
I set up a small web project with JSF and maven. Now I want to deploy on a Tomcat Server.
During development I recommend to use Eclipse Web Tools Platform (WTP). M2Eclipse provides support for it (assuming you have Maven Integration for WTP installed) and your project should be recognized as a Dynamic Web Project runnable on a Server.
So, declare Tomcat as a Server (show the Servers view and right-click in it to add a Server via New > Server). And deploy your project to it (right-click on your project then Run > Run on Server).
There are other options like using the Tomcat Maven Plugin or the generic Cargo Maven Plugin but I wouldn't use them for development and, since you are a Maven beginner, I don't recommend them at all. Use your IDE.
I read about a the Maven War Plugin but I couldn't find a tutorial how to integrate that into my process.
Actually, the Maven War Plugin is only responsible of the packaging of your webapp project (it is bound automatically on the package phase when using a <packaging>war<packaging> for your project). It isn't used for deployment. But as I said, use your IDE to deploy your application during development.
The war plugin is for generating war files, not for deploying them. What you are asking for may be provided by the Cargo Plugin. Another interesting candidate for you could be the jetty-maven-plugin.