Servers\" menu and as you can see it appears in the list of servers:" />
开发者

How to deploy to Tomcat from NetBeans?

开发者 https://www.devze.com 2022-12-29 22:30 出处:网络
I\'ve added Tomcat in the \"Tools > Servers\" menu and as you can see it appears in the list of servers:

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 i开发者_如何转开发s not capable to execute it.


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


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


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?


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

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


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


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


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号