67

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)
liquide
  • 1,346
  • 3
  • 20
  • 28
  • 1
    Check your server logs, could be in location like D:\apache-tomcat-netbeans\logs\ . Could be due to port conflicts. But your log would have such information. – Jay Mar 06 '14 at 13:21
  • Checking the existing log files should always be the first thing you do. – jgitter Mar 06 '14 at 13:24
  • 1
    Log is totally empty. There is only one file created: localhost.2014-03-06.log – liquide Mar 06 '14 at 13:24
  • Have you tried starting up the server from the command line? I have seen times where it immediately fails because of configuration errors and you might get a better error message there... – jgitter Mar 06 '14 at 13:28
  • From command line everything is all right, I have no problems with starting in normal or debug mode. – liquide Mar 06 '14 at 14:39
  • I have attempted to reproduce the problem in my own machine, without success. Did you install the Tomcat from the zip file or from the Windows installer? I always use the zip file. – Almir Campos Mar 06 '14 at 20:40
  • From Zip file. I haven't got service, I start it only from command line - maybe tomorrow I will try with tomcat windows service. – liquide Mar 07 '14 at 00:30
  • Do you use https? (configured in server.xml) – R. Oosterholt Jan 23 '15 at 08:52
  • This is relevant to NetBeans 8.0.2 and Tomcat 8.0.15. I'd suggest removing the version numbers from the question title and body as the problem transcends those specifics. –  Mar 02 '15 at 05:07
  • Thank you, Tom, I deleted info about version from topic. Unfortunatelly now I don't have access to machine, where problem occurred, so I can't mark any of suggested answers as correct answer, I'm very sorry. – liquide Mar 05 '15 at 21:07

6 Answers6

164

It affects at least NetBeans versions 7.4 through 8.0.2. It was first reported from version 8.0 and fixed in NetBeans 8.1. It would have had the problem for any tomcat version (confirmed for versions 7.0.56 through 8.0.28).

Specifics are described as Netbeans bug #248182.

This problem is also related to postings mentioning the following error output:

'127.0.0.1*' is not recognized as an internal or external command, operable program or batch file.

For a tomcat installed from the zip file, I fixed it by changing the catalina.bat file in the tomcat bin directory.

Find the bellow configuration in your catalina.bat file.

:noJuliConfig
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"

:noJuliManager
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"

And change it as in below by removing the double quotes:

:noJuliConfig
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%

:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%

Now save your changes, and start your tomcat from within NetBeans.

YoYo
  • 9,157
  • 8
  • 57
  • 74
Sudeepta
  • 2,194
  • 4
  • 20
  • 24
  • 5
    Worked for Tomcat 7.0.56 running on Netbeans 8.0.1 – Katana24 Oct 31 '14 at 11:31
  • 5
    didn't help me - netbeans 8.0.2, tomcat 8.0.15 – BIU Feb 08 '15 at 21:35
  • Worked with NetBeans 8.0.2 and Tomcat 8.0.15 on Windows! Any idea what the problem is exactly? I don't understand what difference the quotes make. –  Mar 02 '15 at 05:04
  • On Windows 8 I had to open notepad as an administrator to get this done. – Gyan Jul 10 '15 at 04:57
  • thanks , this solution worked for tomcat 8.0.23 also – jawath Jul 19 '15 at 14:06
  • Perfect solution!! Works for tomcat 8.0.28. Thanks!! – Kumar Nov 14 '15 at 17:50
  • Thank, It worked for me. Netbeans8.0.2 and tomcat 7.0.67 –  Jan 31 '16 at 07:30
  • Not work for me netbeans 8.1. tomcat 8, and windows 8 – Black Swan May 22 '16 at 15:46
  • 1
    @BlackSwan see [my answer](http://stackoverflow.com/a/38277506/744133) specific for tomcat 8.5.3 onward and at least up-to netbeans 8.1. – YoYo Jul 26 '16 at 11:34
  • This is working yet doesn't make any sense! Nice work I guess but really, how, and why ? – Tarek Aug 30 '18 at 10:29
  • None of the solutions here helped me, but the Netbeans guys provided me with a file that got this working Netbeans 10.2 and Tomcat 8.x and 9.x on Mac Catalina - please see my answer https://stackoverflow.com/a/60385013/583616 – RobbiewOnline Feb 24 '20 at 22:51
79

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.

YoYo
  • 9,157
  • 8
  • 57
  • 74
  • This was the exact solution for the brew installed version, as well! – xathien Aug 24 '16 at 22:34
  • I had to apply both the accepted answer and this for it to work properly – reden Feb 03 '17 at 10:49
  • I did this configuration for making work of following combination NetBeans IDE 8.1 and apache-tomcat-8.5.6. Thanks. – S.P Singh Jun 01 '17 at 07:10
  • This workaround works with Apache Tomcat/8.5.28 NetBeans IDE 8.1 too. – taringamberini Mar 02 '18 at 09:17
  • Workaround works with NB 11.1 and Tomcat 9.0.6 on Windows 10, thanks. – Gunnar Jul 29 '19 at 11:00
  • None of the solutions here helped me, but the Netbeans guys provided me with a file that got this working Netbeans 10.2 and Tomcat 8.x and 9.x on Mac Catalina - please see my answer https://stackoverflow.com/a/60385013/583616 – RobbiewOnline Feb 24 '20 at 22:51
  • This work-around was needed to use Tomcat 9.0.54 with NetBeans 8.2 and 12 on Windows. – jla Oct 21 '21 at 20:30
24

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.

Yan Pak
  • 1,767
  • 2
  • 19
  • 15
  • In a corporate environment, a proxy might be required for the rest of your integrations to work, including receiving netbeans updates, and git access to external repositories including github. A better alternative to keep your proxy is to set a localhost exception on your proxy. – YoYo Apr 24 '17 at 03:46
  • Yeah, you are absolutely right. My case applying to situatuion when your network uses no proxy. – Yan Pak Apr 24 '17 at 09:48
  • oh unexpectedly enough this worked for me, after changing server.xml as suggested above (which still had the same problem) : Netbeans 8.1 + TomEE 7.1.0 (tar.gz version) – hello_earth Oct 19 '18 at 14:10
  • None of the solutions here helped me, but the Netbeans guys provided me with a file that got this working Netbeans 10.2 and Tomcat 8.x and 9.x on Mac Catalina - please see my answer https://stackoverflow.com/a/60385013/583616 – RobbiewOnline Feb 24 '20 at 22:51
14

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

RobbiewOnline
  • 1,350
  • 1
  • 16
  • 36
3

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?

Community
  • 1
  • 1
sampathlk
  • 338
  • 2
  • 17
  • Unfortunately it didn't helps. Nothing changes. My tomcat-users.xml is now: – liquide Mar 10 '14 at 11:40
  • When I removed Root folder from tomcat and start it from Netbeans, tomcat log files had properly created, with error: SEVERE: Error starting static Resources. java.lang.IllegalArgumentException: Document base C:\Tomcat\webapps\ROOT does not exist or is not a readable directory – liquide Mar 10 '14 at 11:47
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.

lalo
  • 404
  • 6
  • 14