How to deploy to Tomcat from NetBeans?

前端 未结 9 980
渐次进展
渐次进展 2021-02-08 14:51

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 dr

相关标签:
9条回答
  • 2021-02-08 15:30

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

    <properties>
            <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server>
    </properties>
    
    0 讨论(0)
  • 2021-02-08 15:31

    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">
    
    0 讨论(0)
  • 2021-02-08 15:33

    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

    0 讨论(0)
  • 2021-02-08 15:34

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

    0 讨论(0)
  • 2021-02-08 15:38

    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

    0 讨论(0)
  • 2021-02-08 15:39

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

    0 讨论(0)
提交回复
热议问题