Starting of Tomcat failed from Netbeans - java

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)

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.

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.

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.

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

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,
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"/>
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?

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.

Related

SAP Hybris on Mac OS Catalina

I just update my Mac OS to Catalina version and my Hybris server stopped turning on. So on command ./hybrisserver.sh start I get this
MacBook-Pro-Sasha:platform sashayukhimchuk$ ./hybrisserver.sh start
Starting hybrisPlatform on Tomcat...
/Users/sashayukhimchuk/hybris/CXCOMM181100P_1-70004085/hybris/bin/platform/tomcat/bin/wrapper.sh:
line 1388: 4614 Killed: 9
"/Users/sashayukhimchuk/hybris/CXCOMM181100P_1-70004085/hybris/bin/platform/tomcat/bin/./wrapper-macosx-universal-64"
"/Users/sashayukhimchuk/hybris/CXCOMM181100P_1-70004085/hybris/bin/platform/tomcat/conf/wrapper.conf"
wrapper.syslog.ident="hybrisPlatform"
wrapper.pidfile="/Users/sashayukhimchuk/hybris/CXCOMM181100P_1-70004085/hybris/bin/platform/tomcat/bin/hybrisPlatform.pid"
wrapper.daemonize=TRUE wrapper.name="hybrisPlatform"
wrapper.displayname="hybrisPlatform on Tomcat"
wrapper.statusfile="/Users/sashayukhimchuk/hybris/CXCOMM181100P_1-70004085/hybris/bin/platform/tomcat/bin/hybrisPlatform.status"
wrapper.java.statusfile="/Users/sashayukhimchuk/hybris/CXCOMM181100P_1-70004085/hybris/bin/platform/tomcat/bin/hybrisPlatform.java.status" wrapper.script.version=3.5.29 --
Waiting for hybrisPlatform on Tomcat..................
WARNING: hybrisPlatform on Tomcat may have failed to start.
I had to allow the wrapper-macosx-universal-64 and some other libs in Systemsettings > Security > General while starting the Hybris Server.
Remove the app (and all the necesary side apps) from Mac OS quarantine:
xattr -d com.apple.quarantine wrapper-macosx-universal-64
You can find the blocked wrapper under /bin/platform/tomcat/bin
If you get an error saying that the wrapper-macosx-universal-64 or libwrapper-macosx-universal-64.jnilib cannot be opened because the developer cannot be verified, proceed as follows:
Go to system preferences security and privacy
Click the General tab.
In the list, select the executable that you tried to run, and unblock it.
Run the command again.
to fix it, u need new tomcat in bin/platform. I just create new hybris project with .zip and copy tomcat folder to my hybris project and after some confirming about security in Mac OS setting, it works
It's probably could happen as a result that wrapper-macosx-universal-64 was deleted by macOS during a security check.
You can copy the file from the original path in hybris zip archive -
hybris-dir/bin/platform/tomcat/wrapper-macosx-universal-64
to your installation and follow the actions related to macos developers security check to allow starting the tomcat

Configuring custom Realms for Tomcat 8.5, setting a custom mbean-descriptor

I have been tasked with Migrating our Tomcat Servers from 6.0 to 8.5. As you can imagine, there are going to be many inconsistencies with setting up the configuration and I have very limited knowledge of setting up a web server. What I need to do, to have our custom applications run on the new Tomcat Server, is to create a custom Realm so that our applications can validate users through their Identification cards in Active Directory. The custom realm was configured in the conf/server.xml file.
<Realm className="JEDRealm"
connectionName="CN=webapps,OU=Admin,OU=[OU],dc=[DC],DC=ds,DC=[DC],DC=[DC],DC=[DC]"
connectionPassword="[PASSWORD]"
connectionURL="[SERVER URL]"
alternateURL="[SERVER URL]"
referrals="follow"
roleBase="DC=pod,dc=ds,DC=[DC],DC=[DC],DC=[DC]"
roleName="cn"
roleSearch="(&(member={0})(objectclass=group))"
roleSubtree="true"
userBase="DC=pod,DC=ds,dc=[DC],DC=[DC],DC=[DC]"
userSearch="sAMAccountName={0}"
userSubtree="true" />
I then created a custom mbeans-descriptor file, placed it in the same directory as the JEDRealm.class file (which is a modified version of the JNDIRealm.java, then compiled as JEDRealm.class).
So after creating the JED_mbeans-descriptor, I had to set a listener for it. In Tomcat 6.0, there was:
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
descriptors="JED_mbeans-descriptors.xml"/>
However, in Tomcat_8.5, the ServerLifecycleListener has since been discontinued and I'm not sure where else to set the:
descriptors="JED_mbeans-descriptors.xml"
Here is the copy of the log file when I try to start Tomcat.
03-Oct-2017 17:33:41.907 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin
[SetPropertiesRule]{Server/Listener} Setting property 'descriptors' to 'JED_mbeans-descriptors.xml'
did not find a matching property.
03-Oct-2017 17:33:42.079 SEVERE [main] org.apache.tomcat.util.digester.Digester.startElement
Begin event threw error java.lang.NoClassDefFoundError: JEDRealm (wrong name: org/apache/catalina/realm/JEDRealm)
Forgive me, if I posted too much information. I've never had to setup/configure a web server before, so my knowledge is limited. All I had to go off of was configuration documentation of Tomcat 6.0, installed on a Windows 2008 server, running Java 7. Any help would be greatly appreciated!

Eclipse - Could not publish server configuration for Tomcat8.0 server at localhost

I have created some example web service methods and trying to publish in my localhost with Tomcat v8.0. I use Eclipse Java EE IDE for Web Developers with Mars version 4.5.0.
I configured the server Tomcat v8.0. I got the configured server in Eclipe's Servers list. I Start the server. But Eclipse prompts saying
Publishing to tomcat v8.0 Server at localhost..." has encountered a problem.
And the error details shows that Multiple context have a path for /HelloWorldServlet and /com.vogeila.jersy.first. These are the servlet projects I created in my workspace.
You can refer this screen shot:
I followed this answer.
"Server Tomcat v7.0 Server at localhost failed to start" without stack trace while it works in terminal
But It didn't work for my case.
Share your ideas.
The prompted message helped me. The Server.xml file under Servers has multiple entries of <Context> tag. I deleted everything by leaving only one entry. It worked for me. 
Delete Existing tomcat server...
Then add new server.. its work for me

Getting error in running apache tomcat server

When I try to run a servlet program in NetBeans, I get the following error in build-impl.xml at line 1045, which is not allowing Tomcat server to start.
And, apache server log is giving message as IP is not recognized as an internal or external command,operable program or batch file.
I do not know where I did it wrong, or where I configured the environment variables, provided in servlet mapping.
Any help is welcome.
I think, there is some issue in tomcat which comes with netbeans or permission issue in Windows.
Follow below steps to resolve :
1) Remove your current tomcat. (Tools --> servers --> select tomcat --> remove)
2) Download latest tomcat from here
3) Extract it (Not in system drive)
4) Go to Tools --> servers --> click on add server
5) From Server list choose Apache Tomcat or TomEE element.
6) Choose server location by clicking the Browse button.
7) Click on Finish.
8) Start tomcat.
Hope this will resolve your issue.

Why is my Tomcat server throwing intermittent 404's when compiling JSP's?

I need help figuring out why a couple of my web applications are intermittently throwing 404 errors when trying to bring up a JSP. One of them has the JSP accessed directly and the other has a servlet that is forwarding to a JSP. The pages work most of the time, but occasionally will throw a 404. If the user refreshes their browser 1-3 times, the page starts working again without any changes required.
Here is a sample of the error as seen in the web browser (Chrome):
type: Status report
message: /app_root/my_page.jsp
description: The requested resource is not available
The problem seems to be related to recompiling the JSP pages. The .war file and expanded directory haven't changed. There are always three errors in the logs that correspond to each 404 error:
WARNING: Failed to delete generated class file [D:\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\app_root\org\apache\jsp\my_005fpage_jsp.class]
May 19, 2015 6:32:24 AM org.apache.jasper.compiler.Compiler removeGeneratedFiles
WARNING: Failed to delete generated Java file [D:\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\app_root\org\apache\jsp\my_005fpage_jsp.java]
May 19, 2015 6:32:24 AM org.apache.jasper.compiler.Compiler generateJava
WARNING: Failed to delete generated Java file [D:\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\app_root\org\apache\jsp\my_005fpage_jsp.java]
I'm running Java 1.7 on Tomcat 7.0.53. Tomcat is running on a Windows 2008 R2 server.
Here is what I've tried so far, based on the information I've found from google. However, the 404's continue.
Disabled Windows indexing on the entire Tomcat directory
Turned off development mode in my production environment
Increased modificationTestInterval in my QA environment from the default (4 seconds) to 3600 (1 hour) [Note: it is currently set to 0 to try to help me reproduce the issue]
Changed the owner on the Tomcat work directory to be the same id as the id that the service is running as.
I am in the process of getting anti-virus turned off on the work directory to see if that helps.
While this issue is occurring on my prod and QA servers, it doesn't occur for me on my local Tomcat instance. In fact, I have yet to see the problem from my workstation even when running the QA and Prod applications. The issue has only been seen by other people.
The Tomcat container caches .java and .class files generated by the JSP parser, which are used by the web application. Sometimes these get corrupted or cannot be found. This may occur after a patch or upgrade that contains modifications to JSPs.
Solution is to just simply delete the work directory and restart the tomcat
I had the same problem after deploying a .war on our live server. These are the steps that I followed to solve the problem:
1) Shut down the tomcat server
2) Go to <your tomcat directory> -> work -> Catalina -> localhost -> <your project> -> org -> apache -> jsp ->
3) Manually delete both .class and .java
4) Delete the .war file and the deployed folder from the website that is having the issue on the webapps folder.
5) Export a new .war, and put it into the webapps folder.
6) Start up the tomcat service again.
Once the server is finished deploying, it will auto re-generate the deleted files in the "work" directory and the website should be available again without the intermittent 404 error.
I hope it works for you too.
Check the authority of this file or folder. Generally this problem is caused by lack of access to folders.

Categories