Tag Archives: Tomcat Error

[Solved] Tomcat Error: Failed to start componen

I make a crud project of servlet + JSP, and start Tomcat with an error:

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/oa3]]

It was found that the path was not added ‘/’

//@WebServlet("dept/list")
//Add slash!
@WebServlet("/dept/list")
public class DeptServlet extends HttpServlet {

 

[Solved] Disconnected from the target VM, address : ‘127.0.0.1:6847’ , transport : ‘socket’

Disconnected from the target VM, address : ‘127.0.0.1:6847’ , transport : ‘socket’

Cause Analysis 1 The Tomcat used by the server, the compilation and packaging method is not set to war [the default packaging method is jar]
Scenes Unable to start when starting projectimage

1. Set the packaging method to war in pom.xml
image-20220727191657448

Cause Analysis 2 Port is occupied
Scenes Unable to start when starting projectimage

1. First check the startup status of the port

​ Win+R Enter cmd to open the DOS command box, enter netstat -ano | findstr 8060 [where 8060 is the port number of the running project] If this is image
displayed, it means that the background port 8060 is still running, and the PID is 10316, so kill the port process, Just restart the project

2. Kill the process, choose one of the two methods

​ 2.1, Ctrl + alt + delete, start the task manager, find the corresponding program according to the PID, right-click to end the taskimage

​ 2.2. According to tasklist | findstr 10316, query what program is occupying port 8060, of which 10316 is the PID queried above.image

​ Just continue to execute taskkill /f /t /im java.exe
​ (or) directly execute taskkill /pid 10316 -t -f to force kill the process

AN ERROR MESSAGE APPEARS WHEN TOMCAT DEPLOYS A NEW PROJECT: INVALID BYTE TAG IN CONSTANT POOL: 15

The above pile of tomcat startup prompt information is omitted, the following is the specific information of the error:
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
at org.apache.tomcat.util.bcel .classfile.Constant.readConstant(Constant.java:131)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:60)
at org.apache.tomcat.util.bcel.classfile .ClassParser.readConstantPool(ClassParser.java:209)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java :1911)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1800)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1759)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1745)
at org.apache.catalina.startup.ContextConfig.webConfig (ContextConfig.java:1249)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:317)
at org.apache. catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java: 5061)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild (ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1044)
at org.apache. catalina.startup.HostConfig.deployDirectories(HostConfig.java:967)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java: 1346)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:294)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.ContainerBase.backgroundProcess (ContainerBase.java:1233)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1391)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1401)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1380)
at java.lang.Thread.run(Thread.java:745)

 

 First paste the error message in the control column, the following is the solution:

First of all, I deleted all the deployed projects, and then restarted tomcat, it can start successfully, and can see the welcome page, and then deploy a few small servlet test pages written by myself in turn, it is fine, and it runs normally.

However, this error was reported when some projects were deployed. The error message on the Internet seems to be very small. After all the hardships, I finally found a usable solution. The specifics are posted as follows to warn myself and benefit future generations:

{tomcat path}/conf/web.xml modification method:

<web-app version=”3.0″ xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi :schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd” metadata-complete=”true”>

[Tomcat Error] SEVERE: Error listenerStart

System version: CentOS 6.6 x64

java version: 1.7.0_55

 

Problem Description:

An error appears in the log after the migration Tomcat project is started, and the content is as follows:

Jan 20, 2018 7:02:50 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 20, 2018 7:02:49 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
Jan 20, 2018 7:02:49 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8680"]
Jan 20, 2018 7:02:49 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 30535 ms

The key information cannot be obtained from the above content, which only prompts that there is an error but does not indicate the point of failure. At this time, we need to modify the log level to print more information to help us troubleshoot. The method is as follows.

 

solution:

In the classes path of the tomcat project, add the following content to the file logging.properties , if there is no such file, create it directly.

handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler  
org.apache.juli.FileHandler.level = FINE  
org.apache.juli.FileHandler.directory = ${catalina.base}/logs  
org.apache.juli.FileHandler.prefix = error-debug.   
java.util.logging.ConsoleHandler.level = FINE  
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

Next restart Tomcat, and then check the log, the problems I encountered are as follows:

Jan 20, 2018 7:07:20 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSourceHbe' defined in file
[/root/svn/busservice/WebContent/WEB-INF/classes/applicationContext_hbe.xml]: Could not resolve placeholder 'hbe.driver' in string value "${hbe.driver}"
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:650)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1582)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

 

Use the above information to confirm that the problem is on the database connection. After re-modifying the connection information, restart Tomcat, and “SEVERE: Error listenerStart” does not appear again.

How to Solve Tomcat Error: Could not resolve view with name ‘xxx/xxxxxxx‘ in servlet with

Click the control to not receive the returned JSON object, Tomcat reports an error.

reason:

Because the return information is a JSON object, the annotation added to the entry class where the controller method is located is: @ controller

The @controller is not suitable for returning JSON content

Method 1: change the @ controller annotation to @restcontroller without affecting the use of other methods

Method 2: add @ ResponseBody annotation to the method that needs to request to return the JSON object

Some of the other methods in the class of this method in the project return to the specified page, so @restcontroller cannot be used to replace @ controller directly, so method 2 is adopted to solve the problem.

The difference between @controller and @restcontroller is as follows

@Restcontroller is a stereotype annotation that combines @ ResponseBody and @ controller.
it means:
@restcontroller annotation is equivalent to the combined function of @ ResponseBody + @controller.

1) If you only use @restcontroller to annotate the controller, the methods in the controller cannot return the JSP page, the configured view parser internalresourceviewresolver does not work, and the returned content is the content in return.

For example, if you should go to the success.jsp page, success.jsp will be displayed

2) If you need to return to the specified page, you need to use @ controller with the view parser internalresourceviewresolver
3) if you need to return JSON, XML or custom media type content to the page, you need to add @ ResponseBody annotation to the corresponding method

Tomcat Error: because there was insufficient free space available after evicting expired cache entries

When Tomcat is running, it warns

The version is Tomcat 8.5.15

The alarm information keywords are as follows

because there was insufficient free space available after evicting expired cache entries

 

 

 

Just increase the maximum cacheable size of the resource in $CATALINA_BASE/conf/context.xml, and the size can be defined according to your needs

Resources
cachingAllowed= “true”
cacheMaxSize= “100000”
/>

 After adding it is as follows

 

 

Restart Tomcat