Tag Archives: tomcat

Tomcat running under Linux reports an error broken pipe

linux tomcat run error Broken pipe

It is possible that linux’s threading mechanism can generate JVM errors, especially during connection peaks often appear such problems, tomcat in linux also appear similar situations.
The solution is to set: _JAVA_SR_SIGNUM = 12 in the environment variable and you can basically solve it.In WIN environment variable set: _JAVA_SR_SIGNUM=12, if Linux with export _JAVA_SR_SIGNUM=12, basically you can solve.
sun’s explanation.
--posted by: cooper
Below is a clipping from Sun on working around JVM crashes under high
thread counts in the JVM 1.3 for Linux
On Linux, use a larger signal number for hotspot thread
suspension/resumption handler. The signal number being used is
specified by environment variable _JAVA_SR_SIGNUM. Setting it to a
number larger than SIGSEGV (11) will solve the PRoblem. A good number
to use is 12, which is SIGUSR2. Using signal 16 to work around the
problem might have potential problems. So on tcsh, “setenv
_JAVA_SR_SIGNUM 12” can solve the problem.

 

Several common error reporting and startup problems of Tomcat

error: a child container failed during start

1.Caused   by:   java.lang.IllegalArgumentException:   Servlet   mapping   specifies   an   unknown   servlet   name   Action  
this means that this node does not know. We only need to find the relevant web.xml file and delete the following nodes
 & lt; servlet-mapping>   
⦁      & lt; servlet-name> Action</ servlet-name>   
⦁      & lt; url-pattern>/ public/Action</ url-pattern>   
⦁  & lt;/ servlet-mapping>  

2..Caused   by:   java.lang.IllegalArgumentException:   The main resource set specified… Is not valid
generally speaking… The path of this project can not be found. I just made this mistake

Tomcat startup problem

When eclipse edits a web page, Tomcat used well before. I don’t know where to delete or modify it, and then when you start tomcat, an error is reported “ server Tomcat v7.0 server at localhost failed to start

Solution:
  1. Open your workspace folder in the following path:
& lt; workspace-directory>\. Metadata \. Plugins \ org. Eclipse. Core. Resources
then delete it  . Snap file. When eclipse is open, there is this. Snap file. Delete it
  2. Open the workspace folder in the following path:
& lt; workspace-directory>\. Metadata \. Plugins \ org. Eclipse. WST. Server. Core
delete the temp * folder. I have temp0 and temp1, which may be a Tomcat corresponding to a temp. Restart eclipse after deletion, and Tomcat can be used

 

⦁   4. The port of Tomcat server is occupied
when running the program, you will be prompted to start the Tomcat server. If there is a problem, port 8005 is occupied
 

 

Solution 1: open the task manager (ALT + Ctrl + Del), find the Java related process,
and then force it to close( These ports are already occupied by an application, so Tomcat cannot be started; End a javaw.exe process and Tomcat starts normally)

 

Solution 2: CMD enter the console and enter the command netstat   – ano|findstr   8005  ( Enter whatever port number is occupied) and press enter
 

 

It is found that process 2044 occupies this port
next, enter the command
taskkill  / pid   2044 /f     Enter. 2044 here corresponds to 2044 in the above figure
 

 

after terminating the process occupying the port, you can restart the Tomcat server

Solution to lifecycle exception with Tomcat error

After entering the URL configured by tomcat, there is a status 404 error. Repeatedly search and compare, search online, and then turn over the error information (this step was realized later). Lifecycleexception error is found. After finding the solution, it is finally successful

Thanks for the blog: http://blog.csdn.net/zhenqian52/article/details/51330164

My error is the first, the servlet     The URL pattern configuration of is written with a “/” less. It is successfully started after adding it

Other mistakes will be added later   –_–,,

When deploying Tomcat service, resolve the cannot invoke Tomcat manager exception

Recently, when using Jenkins to deploy a project with one click, there was an exception invoking the Tomcat Manager, and the solution was especially noted.

Exception information

Possible exceptions: (1) Cannot invoke Tomcat manager: Error writing to server; (2) Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1].

Abnormal

After checking the information, when installing Tomcat, the manager project is taken by default, which is responsible for the deployment of the WAR package and other functions. Since the use of manager requires account and password authentication, if the account and password are not configured, such an exception will be reported.

But there is still this situation. The configuration below is configured, but this exception will be reported. At this time, you need to restart Tomcat and then deploy. (The reason is the result of Tomcat’s remote address interceptor, you need to add the RemoteAddrValve attribute in /conf/Catalina/localhost/manager.xml, reference 3)

solution

1. The tomcat-maven-plugin plug-in added to the pom file of the web project. This plug-in is used to deploy the war package built by maven to the specified remote Tomcat container and configure the account and password information. The account password needs to be the same as the corresponding Tomcat The configuration of conf/tomcat-user.xml is the same.

1  < plugin > 
2      < groupId > org.codehaus.mojo </ groupId > 
3      < artifactId > tomcat-maven-plugin </ artifactId > 
4      < version > 1.1 </ version > 
5      < configuration > 
6           < url >http:/ /ip/manager/text </ url > 
7           < username > tomcat </ username > 
8           <password> tomcat </ password > 
9           < update > true </ update > 
10           < path > /xxxx </ path > 
11      </ configuration > 
12  </ plugin >

Among them, url specifies the remote Tomcat, and path corresponds to the specific path in webapps.

2. Add the following role information in conf/tomcat-user.xml, and users with these roles

1  < role rolename ="manager-gui"  /> 
2  < role rolename ="manager-script"  /> 
3  < role rolename ="admin-gui"  /> 
4  < role rolename ="admin-script"  /> 
5  < user username ="tomcat" password ="tomcat" roles ="manager-gui,manager-script,admin-gui,admin-script"  />

3. Some people say that it is necessary to modify the configuration file (USER_HOME/.m2/settings.xml) under the Maven user warehouse path. I did not change it, and it succeeded (also written here for reference). This configuration is the username and password that need to be configured when the local maven warehouse accesses the remote warehouse.

1  < settings > 
2      ...
 3      < servers > 
4          ...
 5          < server > 
6              < id > my-tomcat </ id > 
7              < username > manager </ username > 
8              < password > managerPwd </ password > 
9          </ server > 
10      </ servers > 
11  
12  </ settings>

After modifying Tomcat’s server.xml, the Tomcat deployment project reported an error: removing observe files from server… Could not clean server

This article gives you a comprehensive understanding of Java object serialization and deserialization>>>

The second is that when you are in clean tomcat, the file is not clean. (temporary crash, system downtime or other reasons)
causes that the service.xml in eclipse is not consistent with the copy when you are cleaning.

solution:

1 find your tomcat folder. Find the service.xml file in it (path tomcat, conf, service. XML)

2,
Find service.xml in workspace \. Metadata \. Plugins/org. Eclipse. WST. Server. Core/tmpx (x is 1… N, depending on your project) conf
to see if this file is the same as your service.xml file.

if not, replace the temporary file in eclipse 2 with your service.xml.

the two files should be consistent before you can start Tomcat


[Ultimate Solution:]
1. Clean up all your Tomcat configurations
2. Clean up all the files in the workspace. Metadata. Plugins \ \ org. Eclipse. WST. Server. Core directory
3. Download the new Tomcat example:http :// archive.apache.org/dist/tomcat/tomcat-7/v7.0.77/bin/apache-tomcat-7.0.77. Zip
4. Restart your eclipse.
5. Reconfigure ecipse’s Tomcat (newly downloaded)

*********************************************************************************************
eclipse:Cannot Perform O peration:The resource Is not on the build path of a java project
modify the. Project file at the root of the workspace, After adding the following contents, restart Eclipse:

<natures>
   <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature> </natures>


In the face of such a problem, my first approach is to delete Tomcat and rebuild a server. However, the server.xml in Tomcat has to be reconfigured again, which is not cost-effective. I have been on the Internet for a long time, vaguely using the methods provided by netizens and my own attempts, and found a feasible method. I hope it will help you

Make sure that the server.xml of Tomcat in eclipse is consistent with the conf/server.xml in the root directory of tomcat, and then delete all problems in the temp0 folder of. Metadata. Plugins \ \ org.eclipse.wst.server.core in the workspace working directory of eclipse, and then rerun the project to start the server normally,

Original text: https://blog.csdn.net/hd20086996/article/details/51683813

Tomcat failed to start: Server Tomcat v8.5 Server at localhost failed to start

Tomcat failed to start

Project status
Maven project: the basic environment (dependency, basic configuration file) has been built, the front-end pages have been imported, and the test project environment has been deployed

Problem scenario:
1. Pop up window prompts Tomcat start failure

2. Console error:
problem:
serious: a child container failed during start

serious: the required server component failed to start so Tomcat is unable to start.

Solution:
1. Double click to open Tomcat settings page

2. Check

Tips
after modifying Tomcat settings, Ctrl + s saves them

Ubuntu Tomcat Server:insserv: warning: script ‘tomcat’ missing LSB tags and overrides

 

If you use apt get and apt fast to install the software, you will report an error and the installation fails

A Tomcat startup script is written, which is easy to execute, but there are a lot of problems when installing mysql

insserv: warning: script 'S20tomcat' missing LSB tags and overrides
insserv: warning: script 'tomcat' missing LSB tags and overrides
insserv: There is a loop at service rmnologin if started insserv: There is a loop between service rmnologin and mountnfs if started insserv: loop involving service mountnfs at depth 6 insserv: loop involving service networking at depth 5 insserv: There is a loop between service tomcat and hwclock if started insserv: loop involving service hwclock at depth 3 insserv: loop involving service mountdevsubfs at depth 2 insserv: There is a loop between service tomcat and udev if started insserv: loop involving service udev at depth 1 insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true! insserv: Starting tomcat depends on rmnologin and therefore on system facility `$all' which can not be true!

Actually, it also led to the failure of automatic configuration prompt after MySQL installation. According to LSB tags specification, the rewriting script is as follows (debian8 environment)

#!/bin/bash
### BEGIN INIT INFO
# Provides:          bbzhh.com
# Required-Start:    $local_fs $network
# Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: tomcat service # Description: tomcat service daemon ### END INIT INFO # # description: Apache Tomcat init script # processname: tomcat # chkconfig: 234 20 80 # # # Copyright (C) 2014 Miglen Evlogiev # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # this program. If not, see <http://www.gnu.org/licenses/>. # # Initially forked from: gist.github.com/valotas/1000094 # Source: gist.github.com/miglen/5590986 #Location of JAVA_HOME (bin files) export JAVA_HOME=/opt/jdk #Add Java binary files to PATH export PATH=$JAVA_HOME</span>/bin:<span class="variable">$PATH #CATALINA_HOME is the location of the bin files of Tomcat export CATALINA_HOME=/opt/tomcat #CATALINA_BASE is the location of the configuration files of this instance of Tomcat export CATALINA_BASE=/opt/tomcat export CATALINA_BOOTSTRAP=/opt/tomcat/bin/bootstrap.jar #TOMCAT_USER is the default user of tomcat export TOMCAT_USER=tomcat #TOMCAT_USAGE is the message if this script is called without any options TOMCAT_USAGE="Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;31mkill\e[00m|\e[00;32mstatus\e[00m|\e[00;31mrestart\e[00m}" #SHUTDOWN_WAIT is wait time in seconds for java proccess to stop SHUTDOWN_WAIT=20 tomcat_pid() { echo `ps -fe | grep $CATALINA_BOOTSTRAP | grep -v grep | tr -s " "|cut -d" " -f2` } start() { pid=$(tomcat_pid) if [ -n "$pid" ] then echo -e "\e[00;31mTomcat is already running (pid: $pid)\e[00m" else # Start tomcat echo -e "\e[00;32mStarting tomcat\e[00m" #ulimit -n 100000 #umask 007 #/bin/su -p -s /bin/sh $TOMCAT_USER if [ `user_exists $TOMCAT_USER` = "1" ] then /bin/su $TOMCAT_USER</span> -c <span class="variable">$CATALINA_HOME/bin/startup.sh else echo -e "\e[00;31mTomcat user $TOMCAT_USER</span> does not exists. Starting with <span class="variable">$(id)\e[00m" sh $CATALINA_HOME/bin/startup.sh fi status fi return 0 } status(){ pid=$(tomcat_pid) if [ -n "$pid" ] then echo -e "\e[00;32mTomcat is running with pid: $pid\e[00m" else echo -e "\e[00;31mTomcat is not running\e[00m" return 3 fi } terminate() { echo -e "\e[00;31mTerminating Tomcat\e[00m" kill -9 $(tomcat_pid) } stop() { pid=$(tomcat_pid) if [ -n "$pid" ] then echo -e "\e[00;31mStoping Tomcat\e[00m" #/bin/su -p -s /bin/sh $TOMCAT_USER sh $CATALINA_HOME/bin/shutdown.sh let kwait=$SHUTDOWN_WAIT count=0; until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count</span> <span class="operator">-gt</span> <span class="variable">$kwait ] do echo -n -e "\n\e[00;31mwaiting for processes to exit\e[00m"; sleep 1 let count=$count+1; done if [ $count</span> <span class="operator">-gt</span> <span class="variable">$kwait ]; then echo -n -e "\n\e[00;31mkilling processes didn't stop after $SHUTDOWN_WAIT seconds\e[00m" terminate fi else echo -e "\e[00;31mTomcat is not running\e[00m" fi return 0 } user_exists(){ if id -u $1 >/dev/null 2>&1; then echo "1" else echo "0" fi } case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) status exit $?;; kill) terminate ;; *) echo -e $TOMCAT_USAGE ;; esac exit 0 

In fact, the solution is in the future/ Bin/Bash

### BEGIN INIT INFO
# Provides:          bbzhh.com
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: tomcat service # Description: tomcat service daemon ### END INIT INFO

Of course, once and for all:

apt-get remove insserv

The startup script file is placed in the/etc/init.d/ folder, and the file name is the service name that reported the error. What I reported is tomcat8, which is installed according to other people’s tutorial. It seems that even if you follow the tutorial, there is no error
(PS: I still suggest not to go once and for all. It’s safer to change the above documents. Anyway, I succeeded according to the above, but the once and for all method was not successful. On the contrary, there were some other problems.)

[Solved] Too large catalina.out file of Tomcat (logrotate mode)

Problem:

sudo du -sh /opt/tomcat/logs/*
...
4.5G    /opt/tomcat/logs/catalina.out
...

The log file catalina.out of Tomcat on CentOS has reached more than 4G

Solution:

logrotate

Create profile

vi /etc/logrotate.d/tomcat

To write a configuration file:

/opt/tomcat/logs/catalina.out {   
    copytruncate   
    daily   
    rotate 7   
    compress   
    missingok   
    size 5M  
}

Configuration Description:

/opt/Tomcat/logs/Catalina. Out : log path to archive

copyruncat : copy truncation mode

daily : trigger once a day

Rotate : up to 7 log files

compress : use compression

missingok : if the log file is missing, proceed to the next log file without issuing an error message

size : log files are rotated only when the log file size exceeds the byte size

In this way, logrotate automatically triggers log cutting and archiving once a day

Test logrotate rotation log

logrotate -v /etc/logrotate.conf
...
rotating pattern: /opt/tomcat/logs/catalina.out  5242880 bytes (7 rotations)
empty log files are rotated, old logs are removed
considering log /opt/tomcat/logs/catalina.out
  log needs rotating
rotating log /opt/tomcat/logs/catalina.out, log->rotateCount is 7
dateext suffix '-20180928'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
copying /opt/tomcat/logs/catalina.out to /opt/tomcat/logs/catalina.out-20180928
set default create context
truncating /opt/tomcat/logs/catalina.out
compressing log with: /bin/gzip
...

Then, under the logs folder of tomcat, check whether the Catalina. Out file has been rotated and backed up

[admin@Servicenumber logs]$ ls -lh
23M
...
-rw-r-----. 1 tomcat tomcat 249K 9月  28 09:30 catalina.out
-rw-r-----. 1 tomcat tomcat 566K 9月  28 09:27 catalina.out-20180928.gz
...

When you see the GZ file, it means that logrotate is OK

Log file of logrotate

/var/lib/logrotate.status 

Attention

When using logrotate, make sure that the Tomcat log output location is /var/log/Tomcat/Catalina. Out to take effect. Logrotate cannot be enabled if it is not the log output location of /var/log/ of the operating system

 

Tomcat Warning: HTTP Status 500 – Internal Server Error

Error: 

 1 HTTP Status 500 – Internal Server Error
 2 Type Exception Report
 3 
 4 Message Error instantiating servlet class [Servlet.BeerSelect]
 5 
 6 Description The server encountered an unexpected condition that prevented it from fulfilling the request.
 7 
 8 Exception
 9 
10 javax.servlet.ServletException: Error instantiating servlet class [Servlet.BeerSelect]
11 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
12 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
13 org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
14 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
15 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
16 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
17 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
18 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
19 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
20 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
21 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
22 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
23 java.lang.Thread.run(Unknown Source)
24 Root Cause
25 
26 java.lang.UnsupportedClassVersionError: Servlet/BeerSelect has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [Servlet.BeerSelect])
27 org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2376)
28 org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:834)
29 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1297)
30 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
31 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
32 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
33 org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
34 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
35 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
36 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
37 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
38 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
39 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
40 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
41 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
42 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
43 java.lang.Thread.run(Unknown Source)
44 Note The full stack trace of the root cause is available in the server logs.

I didn’t take a close look at it at the beginning. I thought it was the wrong Tomcat directory structure. I searched the Internet for various methods, but they couldn’t solve it

Later, if you look at root cause carefully, it is caused by the Java runtime version. After thinking about it, I installed it

It is jdk10, and the default compiled version is also 10. The compiled version should be too high

solution:
just lower the compilation level