Tag Archives: tomcat

[Solved] Druid register MBean error: ERROR [com.alibaba.druid.stat.DruidDataSourceStatManager]

It is normal to run a Tomcat project. When running two Tomcat projects, an exception will be reported.

ERROR [com.alibaba.druid.stat.DruidDataSourceStatManager] – unregister mbean error javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean………

Solution:

Modify catalina.sh under Tomcat: add and set Java at the end_OPTS="Ddruid.registerToSysProperty=true"

This method is effective in personal test. If it is added in other places, it is not guaranteed to be effective

Solution to Tomcat’s broken pipe error

         Broken pipe means that a pipe is broken. It is simply understood that there may be an IO or network problem between Tomcat’s server and client, resulting in one end being closed. Often occurs when the verification code cannot be displayed.

        Solution: enter the Linux environment variable file configuration parameters and configure them in/etc/profile.

        Set parameters at the end of the document:    export _ JAVA_ SR_ SIGNUM=12

export _ JAVA_ SR_ Signum = 12, 12 can be replaced by 16

Note: this method may solve the symptoms but not the root cause, or it should solve the problem code, or it is the wrong connection method. It’s best to tune the JVM. I hope you can give me some advice.

[Solved] Tomcat Error: org.apache.tomcat.util.digester.Digester.fatalError Parse fatal error at line [40] column [36]

Error Messages:

org.apache.tomcat.util.digester.Digester.fatalError Parse fatal error at line [40] column [36]
org.xml.sax.SAXParseException; lineNumber: 40; columnNumber: 36; The value of attribute “password” associated with an element type “user” must not contain the ‘<‘ character.

Solution:
apache-tomcat-10.0.12\conf\tomcat-users

  <user username=”admin” password=”admin” roles=”manager-gui”/>
<user username=”robot” password=”<must-be-changed>” roles=”manager-script”/>
<user username=”tomcat” password=”admin” roles=”tomcat”/>
<user username=”both” password=”<must-be-changed>” roles=”tomcat,role1″/>
<user username=”role1″ password=”<must-be-changed>” roles=”role1″/>

Change password, e.g.
<user username=”robot” password=”admin” roles=”manager-script”/>

[Sp;ved] Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssm]

tomcat startup error:

Error Messages:
Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssm]]
Servlet mapping specifies an unknown servlet name [springDispatcherServlet]
error messages:

Severe: Subcontainer start failure
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssm]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssm]]
	at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	... 21 more
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name [springDispatcherServlet]
	at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3179)
	at org.apache.catalina.Context.addServletMappingDecoded(Context.java:881)
	at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1391)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1168)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5056)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	... 27 more
	十月 21, 2021 1:52:20 下午 org.apache.catalina.startup.Catalina start
Severe: The required service component failed to start, so Tomcat could not be started
LifecycleException: child container failed to start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: child container failed to start
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	... 13 more
	Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name [springDispatcherServlet]
	at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3179)
	at org.apache.catalina.Context.addServletMappingDecoded(Context.java:881)
	at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1391)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1168)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5056)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	... 27 more

Solution:

In the web.xml configuration, the names of servlet name and servlet mapping are inconsistent, resulting in changing the name in servlet mapping to dispatcher servlet
note:

note: because I have a dispatcher servlet-servlet.xml file, the name should correspond!

[Solved] Upload Files Error: Request processing failed;nested exception is org.springframework.web.multipart.MultipartExcepti

During a project development, the front-end uploaded a file and reported a bug without permission

Problem description

Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; Needed exception is org.apache.commons.fileupload.fileuploadbase $iofileuploadexception: processing of multipart/form data request failed

Error reporting reason

It should be because HTTP remote access does not have permission to access the temporary directory of Tomcat on the server

So we might as well directly set a temporary file upload path instead of using the default path of Tomcat

Solution:

Modify the uploaded temporary file path instead of the default temporary file path of Tomcat

When uploading the configuration file in applicationcontext.xml of spring, add

<property name="uploadTempDir" value="/temp"/>

The content in value is the temporary file directory you want to set

The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in u

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

Port conflict
1. Open Task Manager
2. Open details
3. Find java.exe to end the task
if it still fails, you can clear the process by restarting the computer

Tomcat cross server upload error 403forbidden [How to Solve]

HTTP Status [500] – [Internal Server Error]
Type Exception Report

Message Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:9090/loads/2441068f057c4c7fa87e406837bd08f9_ returned a response status of 403 Forbidden

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:9090/loads/2441068f057c4c7fa87e406837bd08f9_ returned a response status of 403 Forbidden
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:986)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Root Cause

com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:9090/loads/2441068f057c4c7fa87e406837bd08f9_ returned a response status of 403 Forbidden

Reason: the default configuration readonly of Tomcat web.xml is true, which makes it impossible to read and write data to the server across servers

The solution is: configure in xeb.xml under config in the local folder of Tomcat

<servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
		
		 <!--New-->
        <init-param>
            <param-name>readonly</param-name>
            <param-value>false</param-value>
        </init-param>
		
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

Gateway forwards weboskct with an error ClassCastException

    usage environment: the springcloud gateway forwards an error message to the websocket. Error message content:

    15:30:38.092 [http-nio-9999-exec-1] ERROR c.m.g.e.GlobalErrorWebExceptionHandler - [handle,38] - org.apache.catalina.connector.ResponseFacade cannot be cast to reactor.netty.http.server.HttpServerResponse
    java.lang.ClassCastException: org.apache.catalina.connector.ResponseFacade cannot be cast to reactor.netty.http.server.HttpServerResponse
    	at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.getNativeResponse(ReactorNettyRequestUpgradeStrategy.java:182)
    	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
    Error has been observed at the following site(s):
    	|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
    	|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
    	|_ checkpoint ⇢ HTTP GET "/sys/websocket/1" [ExceptionHandlingWebHandler]
    Stack trace:
    		at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.getNativeResponse(ReactorNettyRequestUpgradeStrategy.java:182)
    		at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.upgrade(ReactorNettyRequestUpgradeStrategy.java:162)
    		at org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService.lambda$handleRequest$1(HandshakeWebSocketService.java:235)
    		at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:151)
    		at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.Mono.subscribe(Mono.java:4252)
    		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
    		at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at com.alibaba.csp.sentinel.adapter.reactor.MonoSentinelOperator.subscribe(MonoSentinelOperator.java:40)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    
      cause of error: dependency conflict
      the Tomcat servlet of springboot is used in the request and the Tomcat of gateway netty is used in the response, so the type conversion exception is caused. Solution: modify the gateway POM file:
      delete or exclude the following dependencies

      <dependency>
      	<groupId>javax.servlet</groupId>
      	<artifactId>javax.servlet-api</artifactId>
      </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
       </dependency>
       <dependency>
      	<groupId>javax.servlet</groupId>
      	<artifactId>jstl</artifactId>
      </dependency>
      <dependency>
      	<groupId>org.apache.tomcat.embed</groupId>
      	<artifactId>tomcat-embed-jasper</artifactId>
      </dependency>
      

[Solved] Docker Error: Error response from daemon: driver failed programming external connectivity on endpoint

Error Message:

docker: Error response from daemon: driver failed programming external connectivity on endpoint kibana (16b783b436c6fc895f51866efea8a25c5748f7b3a78db1ec2cb0364e28e7feef): (iptables failed: iptables –wait -t nat -A DOCKER -p tcp -d 0/0 –dport 5601 -j DNAT –to-destination 172.17.0.4:5601 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).

Solution:
Docker reboot
You can register the iptables chain
Restart the Docker container

systemctl restart docker

Project startup error: outofmemoryerror [How to Solve]

1. check tomcat settings, whether the start is set at the same time build, if so, to remove
2.  configurate tomcat的vm option
-server -Xms512m -Xmx2048m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=512m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8

3 Set the compile size
Settings -> Build, Execution, Deployment -> Complier -> Build process heap size VM options

4 Check the VMs that come with Idea
Help – >Edit  Custom VM Options

Port out of range: – 1 for Tomcat startup in idea

Port out of range: – 1 for Tomcat startup in idea

The reason for this may be that the port number of your configuration file is – 1

how to solve it
first, let’s find the configuration file in conf under your Tomcat installation path

Mine is here

Open with Notepad

Change the port number to another number at this position. Make it larger. Here I change it to 1001

OK, it’s normal