Starting of Tomcat failed from Netbeans
Asked Answered
O

6

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)
Osage answered 6/3, 2014 at 13:17 Comment(10)
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.Baseless
Checking the existing log files should always be the first thing you do.Amagasaki
Log is totally empty. There is only one file created: localhost.2014-03-06.logOsage
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...Amagasaki
From command line everything is all right, I have no problems with starting in normal or debug mode.Osage
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.Irv
From Zip file. I haven't got service, I start it only from command line - maybe tomorrow I will try with tomcat windows service.Osage
Do you use https? (configured <Connector port="8443" ...> in server.xml)Swedenborgianism
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.Conceptionconceptual
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.Osage
B
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.

Borborygmus answered 15/10, 2014 at 3:47 Comment(11)
Worked for Tomcat 7.0.56 running on Netbeans 8.0.1Wilser
didn't help me - netbeans 8.0.2, tomcat 8.0.15Heady
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.Conceptionconceptual
On Windows 8 I had to open notepad as an administrator to get this done.Microbalance
thanks , this solution worked for tomcat 8.0.23 alsoAba
Perfect solution!! Works for tomcat 8.0.28. Thanks!!Hesse
Thank, It worked for me. Netbeans8.0.2 and tomcat 7.0.67Continuum
Not work for me netbeans 8.1. tomcat 8, and windows 8Towner
@BlackSwan see my answer specific for tomcat 8.5.3 onward and at least up-to netbeans 8.1.Hanni
This is working yet doesn't make any sense! Nice work I guess but really, how, and why ?Ebullient
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://mcmap.net/q/160158/-starting-of-tomcat-failed-from-netbeansTorietorii
H
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.

Hanni answered 9/7, 2016 at 1:51 Comment(7)
This was the exact solution for the brew installed version, as well!Sirloin
I had to apply both the accepted answer and this for it to work properlyAplanospore
I did this configuration for making work of following combination NetBeans IDE 8.1 and apache-tomcat-8.5.6. Thanks.Denise
This workaround works with Apache Tomcat/8.5.28 NetBeans IDE 8.1 too.Sun
Workaround works with NB 11.1 and Tomcat 9.0.6 on Windows 10, thanks.Zebadiah
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://mcmap.net/q/160158/-starting-of-tomcat-failed-from-netbeansTorietorii
This work-around was needed to use Tomcat 9.0.54 with NetBeans 8.2 and 12 on Windows.Withoutdoors
N
25

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.

Nocturnal answered 15/4, 2017 at 22:26 Comment(4)
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.Hanni
Yeah, you are absolutely right. My case applying to situatuion when your network uses no proxy.Nocturnal
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)Goldfish
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://mcmap.net/q/160158/-starting-of-tomcat-failed-from-netbeansTorietorii
T
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

Torietorii answered 24/2, 2020 at 22:44 Comment(2)
That's awesome! Thank you for contacting devs and helping them to fix this issueHabile
This worked for me, thank you. I am using Netbeans 11.3, Tomcat 9.0.39 running on macOS High Sierra.Estey
C
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?

Cinder answered 7/3, 2014 at 15:44 Comment(2)
Unfortunately it didn't helps. Nothing changes. My tomcat-users.xml is now: <?xml version="1.0" encoding="UTF-8"?> <tomcat-users> <role rolename="tomcat"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="admin"/> <user password="tomcat" roles="tomcat, manager-gui,manager,manager-script,admin" username="tomcat"/> </tomcat-users>Osage
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 directoryOsage
B
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.

Besides answered 16/8, 2018 at 19:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.