Tag Archives: bug

Bug [virtual machine error reporting]: summary of RM: cannot remove X: read only file system in CentOS

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

Problem Description: when I finished the test on the virtual machine, in the process of clearing the project in the environment, the file system was damaged due to misoperation. Some log files became read-only files and could not be deleted. This error was reported. The specific cause of misoperation will be analyzed later

The problem is: RM: cannot remove ` 03/03a707c4dce673e63218917d710388. Cache ‘: read only file system

Solution:

DF - M ᦇ to view the file system partition, the biggest one is the file system used by the system DF – M ᦇ to view the file system partition

mount # or view the file system partition in this way

fsck - Y/dev/mapper/volgroup00-logvol00 ᦇ perform repair of file system

shutdown - r now ᦇ restart the system after repair

Then run RM - RF again, and you won't be prompted to read only file system

Solution to java.io.IOException: Server returned HTTP response code: 400 for URL

The error reported

Accident code

The cause of the accident

Solutions

Summary

Looking at the source code, my above implementation is not good. If the response code returned is less than 400 but not 200, geterrorstream will return null, so the specific and perfect solution needs to be explored slowly

Tomcat a bug causes close_ WAIT

It should have been mentioned before that our online architecture has been rebuilt as a whole, and spring boot is used at the application level. Recently, due to some third-party reasons, we started the online internal test ahead of time

Then the operation and maintenance found a problem, the server’s HTTPS port has a large number of close_ WAIT:

My first reaction was that there was a bug in spring boot, because this project was divided into two services: HTTP and HTTPS, which were started in the form of jar. There was no problem with HTTP. At the same time, there was no problem with services of the old architecture in Tomcat providing services in the form of HTTPS. At that time, I thought that it could be judged that there should be no problem at the socket level, So I started to analyze the spring boot code

After debugging and analysis (if there is a chance in the process, I’ll sort out another article), although the cause of this phenomenon is not found, a rule is found. In the dorun method of socketprocessor, which is the internal class of org.apache.tomcat.util.net.nioendpoint, the handshake state is always in handshake = = selectionkey.op_ Read, monitoring will never be turned off

Although, at this point, it seems that the problem should appear at the socket level, I still think it should be spring boot, because the Tomcat code referenced by spring boot to handle this part of the function is embedded (tomcat-embedded-core-8.5.4), but it is no different from the full version, and the full version does not have this problem

Then, for two reasons, I decided to continue the investigation and directly mention issue: first, it takes a lot of time to analyze the relevant code to ensure that this problem can be solved without other problems; 2、 To be sure, it’s not about our new architecture and development. So I went to GitHub and asked an issue https://github.com/spring-projects/spring-boot/issues/7780 The next day, however, I was advised to ask Tomcat for issue:

Although I still think it’s a toss, I don’t have any proof that it’s not a Tomcat problem. So I looked at the code again, trying to prove it, but I didn’t find it

Finally, I went to ask Tomcat a bug, https://bz.apache.org/bugzilla/show_ Bug. CGI?Id = 60555. The reply points to another bug. The reason is that this version does have this problem

The problem occurs for TLS connections when the connection is dropped after the socket has been accepted but before the handshake is complete. The socket ended up in a loop:
- timeout -> ERROR event
- process ERROR (this is the new bit from r1746551)
- try to finish handshake
- need more data from client
- register with poller for READ
- wait for timeout
- timeout ...

... and around you go.

Well, since Tomcat is connected, I don’t want to say much, but I compared the code of the local class package with that of r1746551. After debugging, I found that it wasn’t caused by the code he said, because I still didn’t solve the problem after debugging the code of r1746551. However, there is a barely acceptable solution to the problem of online environment. The embedded Tomcat is replaced by the embedded jetty. As expected, there is no problem

Now the spring boot starter web reference to embedded Tomcat is excluded from gradle.build

compile('org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE'){
    exclude module: "spring-boot-starter-tomcat"
}

Then change to jetty

[group: 'org.springframework.boot', name: 'spring-boot-starter-jetty', version: '1.4.0.RELEASE'],

As for the question raised to tomcat, I’ll take time to think about it carefully and then raise it. However, after testing and upgrading the version just now, there is no problem

After debugging for a while, I really feel that it’s not his r1746551 that solves the problem. Here’s what I found when I looked at the code. The part that directly solves the problem is not included in r1746551. The original part that has the problem is as follows:

                        if (socket.isHandshakeComplete() || event == SocketEvent.STOP) {
                            handshake = 0;
                        } else {
                            handshake = socket.handshake(key.isReadable(), key.isWritable());
                            // The handshake process reads/writes from/to the
                            // socket. status may therefore be OPEN_WRITE once
                            // the handshake completes. However, the handshake
                            // happens when the socket is opened so the status
                            // must always be OPEN_READ after it completes. It
                            // is OK to always set this as it is only used if
                            // the handshake completes.
                            event = SocketEvent.OPEN_READ;
                        }

Now the code is OK

                        if (socket.isHandshakeComplete()) {
                            // No TLS handshaking required. Let the handler
                            // process this socket/event combination.
                            handshake = 0;
                        } else if (event == SocketEvent.STOP || event == SocketEvent.DISCONNECT ||
                                event == SocketEvent.ERROR) {
                            // Unable to complete the TLS handshake. Treat it as
                            // if the handshake failed.
                            handshake = -1;
                        } else {
                            handshake = socket.handshake(key.isReadable(), key.isWritable());
                            // The handshake process reads/writes from/to the
                            // socket. status may therefore be OPEN_WRITE once
                            // the handshake completes. However, the handshake
                            // happens when the socket is opened so the status
                            // must always be OPEN_READ after it completes. It
                            // is OK to always set this as it is only used if
                            // the handshake completes.
                            event = SocketEvent.OPEN_READ;
                        }

Because the problem is caused by the handshake being closed in the process of normal establishment. As long as the judgment is changed to the above, when the handshake is caused by the failure of socket establishment, it will go to the close method, but the original judgment method can’t do it, so the problem is solved. As for the location of this code, I said at the beginning, hehe…, If there’s anything I miss, I’ll be told

==========================================================

My recent GitHub: https://github.com/saaavsaaa

WeChat official account:

Bootstrap switch Uncaught TypeError: Cannot read property ‘apply’ of undefined

<input type=”checkbox” name=”my-switch” checked>

js write the following code, otherwise the switch control will not come out

$(“[name=’my-switch’]”).bootstrapSwitch();

$(‘[name=”my-switch”]’).bootstrapSwitch({

onText:”run”,

offText:”stop”,

onColor:”success”,

offColor:”info”,

size:”small”,

onSwitchChange:function(event,state){

if(state==true){

$(this).val(“1”);

}else{

$(this).val(“2”);

}

}

})

 

<div class="make-switch" data-on-label="开" data-off-label="关" id="toggle-state-switch" data-on="success" data-off="warning">
    <input id ="toggle" type="checkbox"  checked="checked" class="toggle"  />
</div>

function changeState(stateValue){
        if(stateValue==1){
            $('#toggle-state-switch').bootstrapSwitch('setState', true);
        }else{
            $('#toggle-state-switch').bootstrapSwitch('setState', false);
        }
}

Use the above method

$(‘#toggle-state-switch’).bootstrapSwitch(‘setState’, false); There is a problem

It should be used

$(‘#toggle-state-switch’).bootstrapSwitch(‘state’, true/false);

Another pit is to use the ID of the external div to set the state of the bootstrap switch, and there will be more nodes, as follows:

This is not the result we want, so it is wrong to set the value of external Div. The ID of the check box should be set as follows:

$(‘#toggle’).bootstrapSwitch(‘state’, false);

When assigning a value to the bootstrap switch, an error
uncaught type error: cannot read property 'apply' of undefined is prompted


        if (isUp==undefined || isUp == ''){
            $('#isUp').bootstrapSwitch('setState',true);
        } else{
            $('#isUp').bootstrapSwitch('setState',isUp);
        }

The detailed error information is shown in the following figure:

I refer to this setting and use jQuery to get the value of bootstrap switch
it seems that there is a problem, so I check the source code. There is no setstate method at all. I should use the following method:

if(stateValue==0){
            $('#toggle').bootstrapSwitch('state', true);
            console.log("Status enabled or not 1:",stateValue);
        }else{
            console.log("Status enabled or not 2:",stateValue);
            $('#toggle').bootstrapSwitch('state', false);
        }

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.co

First, you need to find the. Condarc file
if you don’t know where it is, you can
Win + R
Enter% HomePath%

and then find

to replace the content with the following one

channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
show_channel_urls: true
ssl_verify: false

Context initialization failed — solution

[wb] [2019-04-29 10:15:12] [ERROR] org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:331) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'printController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private util.jasperReport.JasperResolver com.yd.wb.report.controller.PrintController.jasperResolver; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [util.jasperReport.JasperResolver] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
	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:632)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
	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)

Context initialization failed: initialization failed
some solutions have been found on the Internet, such as adding @ controller or @ service notes. If not, check the log and find the error, could not autowire field: private util.jasperReport.JasperResolver com.yd.wb.report.controller.PrintController.jasperResolver

1. At the beginning, I found that this was a tool class, and I added the annotation @ Autowired to it, which led to this bug

delete it, save it and recompile run.

2. However, we found that this tool class needs to generate business data in JSON format through spring MVC, so we need to add the annotation @ Autowired , so we will go back to the above problem, and then try to solve it

originally, the package util was not loaded. Just copy it to report. Finally solved, sometimes is some small mistakes!