[java] Starting of Tomcat failed from Netbeans

I have problem with starting Apache Tomcat 6 from Netbeans IDE 7.4 (on 7.3 version I had the same troubles. Other people mentioned that this problem exist also in other versions, like 8.0 etc).

What did I do:

  • remove installed Tomcat 7 (without removing it, I had the same difficulties)
  • add new server, downloaded from Apache Tomcat website (version apache-tomcat-6.0.39, with other version I had the same problems)
  • my server location: D:\apache-tomcat-netbeans
  • system variable CATALINA_HOME: D:\apache-tomcat-netbeans
  • system variable JAVA HOME: C:\Program Files\Java\jdk1.7.0_51\
  • tomcat user: I let netbeans creating new user, called tomcat with password tomcat. When I open {tomcat}\conf\tomcat-users.xml file after adding server, there is info about my user:

    < user password="tomcat" roles="manager,admin" username="tomcat"/ >

When I now click "start", I got "Starting of Tomcat failed".

My suspicions:

  • I'm working on Windows 7 as administrator, so I think this is not a problem with privileges to files.
  • Disabling proxy didn't helps.
  • Logs: There is only one log file created: localhost.2014-03-06.log and it is totally empty.
  • Starting Netbeans "as administrator" didn't helps.
  • From command line everything is all right, I have no problems with starting in normal or debug mode (catalina.bat jpda start or startup.bat)

This question is related to java apache tomcat netbeans

The answer is


For NetBeans to be able to interact with tomcat, it needs the user as setup in netbeans to be properly configured in the tomcat-users.xml file. NetBeans can do so automatically.

That is, within the tomcat-users.xml, which you can find in ${CATALINA_HOME}/conf, or ${CATALINA_BASE}/conf,

  1. make sure that the user (as chosen in netbeans) is added the script-manager role

Example, change

<user password="tomcat" roles="manager,admin" username="tomcat"/>

To

<user password="tomcat" roles="manager-script,manager,admin" username="tomcat"/>
  1. make sure that the manager-script role is declared

Add

<role rolename="manager-script"/>

Actually the netbeans online-help incorrectly states:

Username - Specifies the user name that the IDE uses to log into the server's manager application. The user must be associated with the manager role. The first time the IDE started the Tomcat Web Server, such as through the Start/Stop menu action or by executing a web component from the IDE, the IDE adds an admin user with a randomly-generated password to the tomcat-base-path/conf/tomcat-users.xml file. (Right-click the Tomcat Web server instance node in the Services window and select Properties. In the Properties dialog box, the Base Directory property points to the base-dir directory.) The admin user entry in the tomcat-users.xml file looks similar to the following: <user username="idea" password="woiehh" roles="manager"/>

The role should be manager-script, and not manager.

For a more complete tomcat-users.xml file:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager-script"/>
  <role rolename="manager-gui"/>
  <user password="tomcat" roles="manager-script" username="tomcat"/>
  <user password="pass" roles="manager-gui" username="me"/>
</tomcat-users>

There is another nice posting on why am I getting the deployment error?


This affects:

  • All versions of Tomcat starting from 8.5.3 onwards.
  • All versions of Netbeans up to 8.1 (It is fixed in Netbeans 8.2).

This is because Netbeans does not 'see' that tomcat is started, although it started just fine.

I have filed Bug #262749 with NetBeans.

Workaround

In the server.xml file, in the Connector element for HTTP/1.1, add the following attribute: server="Apache-Coyote/1.1".

Example:

<Connector
  connectionTimeout="20000"
  port="8080"
  protocol="HTTP/1.1"
  redirectPort="8443"
  server="Apache-Coyote/1.1"
/>

Cause

The reason for that is that prior to 8.5.3, the default was to set the server header as Apache-Coyote/1.1, while since 8.5.3 this default has now been changed to blank. Apparently Netbeans checks on this header.

Maybe in the future we can expect a fix in netbeans addressing this issue.

I was able to trace it back to a change in documentation.

Tomcat 8.5:

"Overrides the Server header for the http response. If set, the value for this attribute overrides any Server header set by a web application. If not set, any value specified by the application is used. If the application does not specify a value then no Server header is set."

Tomcat 8.0:

"Overrides the Server header for the http response. If set, the value for this attribute overrides the Tomcat default and any Server header set by a web application. If not set, any value specified by the application is used. If the application does not specify a value then Apache-Coyote/1.1 is used. Unless you are paranoid, you won't need this feature."

That explains the need for explicitly adding the server attribute since version 8.5.3.


I had the same problem but none of the answers above worked. The solution for me was to restore the Manager web application that is bundled with Tomcat.


None of the answers here solved my issue (as at February 2020), so I raised an issue at https://issues.apache.org/jira/browse/NETBEANS-3903 and Netbeans fixed the issue!

They're working on a pull request so the fix will be in a future .dmg installer soon, but in the meantime you can copy a file referenced in the bug and replace one in your netbeans modules folder.

Tip - if you right click on Applications > Netbeans and choose Show Package Contents Show Package Contents then you can find and replace the file org-netbeans-modules-tomcat5.jar that they refer to in your Netbeans folder, e.g. within /Applications/NetBeans/Apache NetBeans 11.2.app/Contents/Resources/NetBeans/netbeans/enterprise/modules


Also, it is very likely, that problem with proxy settings.

Any who didn't overcome Tomact starting problrem, - try in NetBeans choose No Proxy in the Tools -> Options -> General tab.

It helped me.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to apache

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer

Examples related to tomcat

Jersey stopped working with InjectionManagerFactory not found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat Spring boot: Unable to start embedded Tomcat servlet container Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Spring Boot application in eclipse, the Tomcat connector configured to listen on port XXXX failed to start Kill tomcat service running on any port, Windows Tomcat 8 is not able to handle get request with '|' in query parameters? 8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE 403 Access Denied on Tomcat 8 Manager App without prompting for user/password Difference between Xms and Xmx and XX:MaxPermSize

Examples related to netbeans

Can't create project on Netbeans 8.2 I'm getting favicon.ico error Cannot find java. Please use the --jdkhome switch Netbeans 8.0.2 The module has not been deployed Error starting Tomcat from NetBeans - '127.0.0.1*' is not recognized as an internal or external command Cannot start GlassFish 4.1 from within Netbeans 8.0.1 Service area javac: invalid target release: 1.8 connecting MySQL server to NetBeans Starting of Tomcat failed from Netbeans Display Records From MySQL Database using JTable in Java