views:

246

answers:

5

I've added Tomcat in the "Tools > Servers" menu and as you can see it appears in the list of servers:

server list

But when I try to run my project, I cannot select Tomcat! The drop-down with servers is empty. I tried it with NetBeans 6.8 and 6.9 Beta. Any idea?

server selection

The end: I've used the wrong archetype so that NetBeans decided that Tomcat is not capable to execute it.

A: 

If you right-click the project, select Properties and go to Run, there should be a dropdown list of servers. Is that one empty as well?

Stian
This dropdown is empty as well.
deamon
+2  A: 

Is your webapp a real Java EE 6 webapp (without web.xml or with a Servlet 3.0 web.xml)?

If yes, maybe NetBeans doesn't show Tomcat because Tomcat is not a valid runtime environment for your application (use GlassFish).

Pascal Thivent
I've used the Maven webapp archetype which doesn't contain a web.xml. What would be the right archetype for a simple servlet application?
deamon
@deamon Hmm... Sorry, I'm wrong then because I think you do have a `web.xml` under src/main/webapp/WEB-INF, don't you?
Pascal Thivent
+1  A: 

Hi,

When you create a Maven based web app project, you specify the spec version of the project as you create it.

image of the Maven web App Wizard with default values

If you want to create a project that you can deploy with Tomcat, you need to change the value of the 'Java EE Version' field from 'Java EE 6' to 'Java EE 5', before you hit the Finish button.

Note: I had hoped that there was a simple change that could be applied to your projects pom file to convert it from Java EE 6 to Java EE 5... but it turns out that it is not so easy...

vkraemer
A: 

I had this exact same issue, when creating a default EE project in Netbeans it does a full EE spec which Tomcat doesn't fulfill.

I created manually because I couldn't find a good archetype, could you please post the place where you got the good Tomcat archetype?

Amala
A: 

Go into your web.xml and replace the header with:

<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;

Go back to properties and you will be able to pick Tomcat

walnutmon