WTP mini howto

Prereqs

Define Tomcat 6.0 server runtime

  • Window / Preferences / Server / Installed Runtimes / Add...
  • In New Server Runtime dialog select Apache, Apache Tomcat v6.0
  • Select tomcat 6.0 installation

Create new webapp using maven-archetype-webapp archetype

  • Open "New Maven Project" wizard from File / New... / Maven Project.
  • Leave default values on the first wizard page.

Select maven-archetype-webapp archetype and go to the next page.

If no archetypes appear in this view make sure that the "Maven Central repository index" feature is installed or index for http://repo1.maven.org/maven2/ is manually registered in the Maven Indexes view

!

Specify groupId, artifactId and optionally package name for generated Java classes, e.g. m2eclipse.howto and webapp and press Finish.

Wizard will create new webapp project and configure it to work with WTP.

Launch web application on the server

  • Right click on the project, Run As -> Run On Server
  • Press Finish to let WTP create server configuration and run webapp on the server

After WTP deploys webapp and start the server you should see "Hello World!" page

Create java source folder

  • Standard Maven convention for java sources is src/main/java folder. Create this folder by drilling down to src/main then right click -> new folder. You will need right click the project and run Maven -> Update Project Configuration as you have added a new source folder.
If you need to troubleshoot, jars for your project are located in a subfolder below  \.metadata\.plugins\org.eclipse.wst.server.core\ . You will need to explore the subfolders to locate the actual location where the web application is being assembled.

Add Servlet and JSP dependencies

Many JEE web applications have dependencies on javax.servlet:servlet-api and javax.servlet:jsp-api. These required at compile time, but should not be packaged with web application, because they are provided by the application server (e.g. see tomcat/lib folder). The provided scope is used to handle such dependencies. Add the following lines to your pom.xml:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.4</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jsp-api</artifactId>
  <version>2.0</version>
  <scope>provided</scope>
</dependency>

Labels

wtp wtp Delete
maven maven Delete
eclipse eclipse Delete
m2eclipse m2eclipse Delete
tomcat tomcat Delete
archetype archetype Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 29, 2008

    Andrew Myers says:

    I'm sure I've followed these instructions to the letter, however when I right cl...

    I'm sure I've followed these instructions to the letter, however when I right click on the project and choose "Run As -> Run On Server" as described in the section "Launch web application on the server" I get the following error in a pop-up dialog:

     "The selection did not contain anything that can be run on a server"

    Any suggestions as to what is happening?

    Andrew 

  2. Aug 13, 2008

    Chris Lacy says:

    I have a similar problem to Andrew.  When I get to the same step (right cli...

    I have a similar problem to Andrew.  When I get to the same step (right click on project, "Run As -> Run On Server") the "Run On Server" option is not there.

    m2eclipse 0.9.6
    eclipse 3.4.0
    Fedora 9

    Follow Up:
    This was on an underpowered (~1ghz, ~512M) box. I've got it working on both an underpowered Windows XP box and a high powered 64 bit Fedora box. Thanks for replying, Eugene. This is the best setup ever!

  3. Aug 07, 2008

    Eugene Kuleshov says:

    Chris, please make sure that you have installed "Maven Integration for WTP" feat...

    Chris, please make sure that you have installed "Maven Integration for WTP" feature in m2eclipse.

  4. Aug 28, 2008

    Ricardo Mayerhofer says:

    Is it possible to use WTP integration with an existing project?

    Is it possible to use WTP integration with an existing project?

  5. Aug 28, 2008

    Eugene Kuleshov says:

    Ricardo, you can use "Maven / Update project configuration" to configure existin...

    Ricardo, you can use "Maven / Update project configuration" to configure existing project. Note that your project should have pom.xml with corresponding packaging (currently only "war" packaging is supported, but we are working on adding support for "ejb" and "ear") and maven-war-plugin configuration. In other words, your project should build with Maven, you can find some examples on Maven web site.
    In a long term we will provide support for converting Eclipse configuration back to Maven, but currently it is not supported.

  6. Oct 03, 2008

    Renato de Melo says:

    Can I use "WTP Integration" to create a "Dynamic Web Project" using JSF 1.2 and ...

    Can I use "WTP Integration" to create a "Dynamic Web Project" using JSF 1.2 and targeting "Websphere Application Server Community Edition"?

    Is there any howto available?

    Thanks

  7. Oct 20, 2008

    Ricardo Mayerhofer says:

    Thanks Eugene, congratulations for the great plugin!!

    Thanks Eugene, congratulations for the great plugin!!

  8. Oct 28, 2008

    fab says:

    what is your preconisation for using filtering resources ? * Using a <Ac...

    what is your preconisation for using filtering resources ?

    * Using a <ActiveProfile> ?

    * Using a -PMyProfile in the mvn command line ?

  9. Dec 10, 2008

    Roman says:

    Hi! First of all: Thanks a lot for this great plugin! I finally can now...

    Hi! First of all: Thanks a lot for this great plugin! I finally can now use the WTP and start my tomcat from eclipse and a lot more

    But: Startup is fine, I see all the Spring/Hibernate/Wicket logs but it seems, that it does not read my web.xml! I checked workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/myapp/WEB-INF/web.xml, so it is there. When going to http://localhost:8080 I am forwarded to http://localhost:8080/app/ as expected. But there is no http://localhost:8080/app/.

    The app is working on a external tomcat as well as with jetty. Any Sugesstions?

  10. Dec 10, 2008

    Eugene Kuleshov says:

    Roman, the best is to ask in the project mailing list or even submit jira issue ...

    Roman, the best is to ask in the project mailing list or even submit jira issue and provide sample test project that would allow us to reproduce. Also read this wiki page for more hits on reporting issues. Thanks.

  11. Mar 20

    Vicky says:

    hello, I 've a problem ,when I update index ,I got fllowing error  Updati...

    hello,

    I 've a problem ,when I update index ,I got fllowing error

     Updating index central
     Unable to update index for central http://repo1.maven.org/maven2/

    in maven console.

     is it not connect net or other?  anyone else confirm problems?

  12. Mar 20

    Eugene Kuleshov says:

    Vicky, please see my previous comment.

    Vicky, please see my previous comment.

  13. Mar 21

    Vicky says:

    Thank you, the problem is resolved.it work well in my home,so it's my network pr...

    Thank you, the problem is resolved.it work well in my home,so it's my network problem.