12

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

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?

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

1
  • 2
    How did you get to the "Select deployment server" dialogue? I am using NB7.1 and I don't see it. Commented Feb 13, 2012 at 22:22

8 Answers 8

6

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).

Sign up to request clarification or add additional context in comments.

2 Comments

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 Hmm... Sorry, I'm wrong then because I think you do have a web.xml under src/main/webapp/WEB-INF, don't you?
6

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"> 

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

Comments

5

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?

1 Comment

This dropdown is empty as well.
4

Add this to your pom.xml after: <repositories></repositories>

<properties> <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server> </properties> 

1 Comment

For some reason I don't know, I had to write "Tomcat" without the "60"... but otherwise, this worked for me.
3

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 http://www.freeimagehosting.net/uploads/20d7e476a5.png

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

1 Comment

I wanted to convert from ant to maven, and I found that I needed to mess with my old web.xml and change the namespaces and the version. The version was 3.0, but changing it to 2.4 seemed to do what I wanted. I figured this out via netbeans.org/bugzilla/show_bug.cgi?id=49545
2

I had the same problem and solved it ;

It was because the Java EE version was higher than the tomcat version requires.

What to do :

Click the files tab near projects tab. Under nbproject folder , select j2ee.platform , if you use Tomcat7 than change the platform to 1.6 for example(Tomcat6 > Jave EE 1.5). than make a "clean and build" on the project .

Now the server will come at Project > properties > Run > Servers

Comments

0

One of the mistakes I was making when I got this problem was that I was trying to deploy EAR project to Tomcat. Tomcat isn't an application server. It is a web server. It worked when I deployed the only the Web project of the EAR to Tomcat. The ejb can only be deployed to an application server.
I hope this helps.

Comments

0

A more updated "web-app" should look like this.

<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/ http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_1.xsd"> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.