WTP mini howto

Skip to end of metadata
Go to start of metadata

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

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

    am2605 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

    clacy 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.ekm 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

    baraodocafe 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.ekm says:

    Thanks Eugene, congratulations for the great plugin!!

    Thanks Eugene, congratulations for the great plugin!!

  8. Oct 28, 2008

    yofab 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

    zero 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, 2009

    kele20000@sina.com 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, 2009

    Eugene Kuleshov says:

    Vicky, please see my previous comment.

    Vicky, please see my previous comment.

  13. Mar 21, 2009

    kele20000@sina.com 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.

  14. Sep 10, 2009

    kamalsofteng says:

    Hello guys; I am following the tutorials here and it seems to be wroking. Howev...

    Hello guys;

    I am following the tutorials here and it seems to be wroking. However, there are some things that does not seem obvious to me so far. Please let me knwo what I am missing:

    When I create a Dynamic Web Project as usual, I get a web nature icon added to my project in addition to its java nature. That way, I can see my webapp settings and I have access to my classes in the web.xml editor. I don't see those in maven enabled projects!

    When I enable maven on any project, wtp or jdt, maven does not recognize my source folders. I right click and chose "Use As Source Folder" from the context, but not sure if there is other reasons!?

    Enabling dependency management on a java project does nto remove the java nature from the project, but adds an M to it, which is expected, but with web projects, as soon as you add dependency mangement, it looses its wtp icon, it seems almost that they are mutually exclusive?

    When I am in a WTP project, my JSP editor's intellisense is working better, for example, I can access all the implicit objects; however, they don't exist in a maven enabled webapp

    Any ideas? Thank you in advance...

    Kamal

  15. Dec 19, 2009

    skpandit says:

    Hi, I have an archetype of appfuse modular jsf.  I cant run the project. ...

    Hi,

    I have an archetype of appfuse modular jsf.  I cant run the project.

    I see the following message in the log:

    WARN [main] AbstractFacesInitializer.initFaces(82) | No mappings of FacesServlet found. Abort initializing MyFaces.

    and I get a 404.

    Help is appreciated,

    Thanks,

    Sonia