Tag Archives: abnormal

Org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception: the wildcard matching is comprehensive, but the declaration of element XX: XX XX cannot be found

When configuring spring’s XML file, you want to start component scanning. As a result, the following error occurred during the operation:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">
    <context:component-scan base-package="com.zxb"></context:component-scan>
</beans>

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from class path resource [bean2.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 52; CVC complex type. 2.4. C: wildcard matching is comprehensive, but the element cannot be found‘ context:component-scan ’A statement from the government.

After searching for a long time, it turned out that in the XML file, you need to specify the specific location of the schema file to be followed through the schemalocation . I forgot to configure it, just add it.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="com.zxb"></context:component-scan>
</beans>

It’s not detailed enough~

[Elasticsearch Exception]Found interface org.elasticsearch.common.bytes.BytesReference

24322; normal information

Found interface org.elasticsearch.common.bytes.BytesReference, but class was expected

picture of child problems.

https://stackoverflow.com/questions/61029889/error-at-createindex-elasticsearch-using-elasticsearchoperations-why-is-the-by

To solve the solution,

<elasticsearch.version> 7.6.2

<dependency>
         <groupId>org.elasticsearch.client</groupId>
         <artifactId>elasticsearch-rest-high-level-client</artifactId>
         <version>${elasticsearch.version}</version>
     </dependency>

JAVA ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit erro

When running the program is suddenly the following exception occurs

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [util.c:840]

The reason:

1.JDK1.6.1
2. There is an error in the last debugging code, which causes the process not to terminate and take up the Console output, and such error occurs when starting debugging later.

Solutions:

At the end of the program, the main() function adds: System.exit(0);
System.exit(0); will cause the program to be terminated immediately, and if there are threads in the program that are still executing tasks, subsequent tasks will not be able to continue.

 

Spring Boot Druid Error: discard long time none received connection

Spring boot integration Druid exception

In the spring boot integrated Druid project, the following error messages are frequently found in the error log:

discard long time none received connection. , jdbcUrl : jdbc:mysql://******?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8, version : 1.2.3, lastPacketReceivedIdleMillis : 172675

After troubleshooting, it was found that the exception was caused by Druid version, which did not appear in version 1.2.2 or earlier. In the above versions, there is this problem, the following is to analyze the causes of the exception and solutions.

Anomaly analysis

First of all, the above exception does not affect the normal operation of the program, but as a programmer to see the program constantly abnormal or intolerable. So we still need to get to the bottom of it.

Trace the stack information and find that the corresponding exception is thrown from the com.alibaba.druid.pool.druidabstractdatasource # testconnectioninternal method. The corresponding code is as follows:

if (valid && isMySql) { // unexcepted branch
    long lastPacketReceivedTimeMs = MySqlUtils.getLastPacketReceivedTimeMs(conn);
    if (lastPacketReceivedTimeMs > 0) {
        long mysqlIdleMillis = currentTimeMillis - lastPacketReceivedTimeMs;
        if (lastPacketReceivedTimeMs > 0 //
                && mysqlIdleMillis >= timeBetweenEvictionRunsMillis) {
            discardConnection(holder);
            String errorMsg = "discard long time none received connection. "
                    + ", jdbcUrl : " + jdbcUrl
                    + ", jdbcUrl : " + jdbcUrl
                    + ", lastPacketReceivedIdleMillis : " + mysqlIdleMillis;
            LOG.error(errorMsg);
            return false;
        }
    }
}

In the above code, mysqlutils.getlastpacketreceivedtimems (conn) is to get the last used time, mysqlidle millis is to calculate the idle time, and timebetweenevecitionrunsmillis is a constant of 60 seconds. If the connection is idle for more than 60 seconds, the discard connection (holder) discards the old connection and prints a log. Warn (errormsg) along with it.

Principle tracing

In the above code, we can see that there is a prerequisite for entering the business logic, that is, the variables valid and ismysql are true at the same time. It is necessary for ismysql to be true. What we use is the MySQL database. Can I make valid false?In this way, it will not enter the business processing?

Let’s take a look at the source of the valid method

boolean valid = validConnectionChecker.isValidConnection(conn, validationQuery, validationQueryTimeout);

We find the MySQL implementation subclass of validconnectionchecker, MySQL validconnectionchecker. The implementation of isvalidconnection in this class is as follows:

public boolean isValidConnection(Connection conn, String validateQuery, int validationQueryTimeout) throws Exception {
    if (conn.isClosed()) {
        return false;
    }

    if (usePingMethod) {
        if (conn instanceof DruidPooledConnection) {
            conn = ((DruidPooledConnection) conn).getConnection();
        }

        if (conn instanceof ConnectionProxy) {
            conn = ((ConnectionProxy) conn).getRawObject();
        }

        if (clazz.isAssignableFrom(conn.getClass())) {
            if (validationQueryTimeout <= 0) {
                validationQueryTimeout = DEFAULT_VALIDATION_QUERY_TIMEOUT;
            }

            try {
                ping.invoke(conn, true, validationQueryTimeout * 1000);
            } catch (InvocationTargetException e) {
                Throwable cause = e.getCause();
                if (cause instanceof SQLException) {
                    throw (SQLException) cause;
                }
                throw e;
            }
            return true;
        }
    }

    String query = validateQuery;
    if (validateQuery == null || validateQuery.isEmpty()) {
        query = DEFAULT_VALIDATION_QUERY;
    }

    Statement stmt = null;
    ResultSet rs = null;
    try {
        stmt = conn.createStatement();
        if (validationQueryTimeout > 0) {
            stmt.setQueryTimeout(validationQueryTimeout);
        }
        rs = stmt.executeQuery(query);
        return true;
    } finally {
        JdbcUtils.close(rs);
        JdbcUtils.close(stmt);
    }

}

We can see that there are three return places in the above methods: the first connection is closed; The second uses Ping to check; Third, use select 1 to check. When Ping is used, it will return true no matter whether the exception is thrown or not. Here we can disable this mode.

The business logic of Ping mainly depends on the variable usepingmethod. Tracing code will find the settings here:

public void configFromProperties(Properties properties) {
    String property = properties.getProperty("druid.mysql.usePingMethod");
    if ("true".equals(property)) {
        setUsePingMethod(true);
    } else if ("false".equals(property)) {
        setUsePingMethod(false);
    }
}

In other words, when we set the system property Druid. Mysql. Usepingmethod to false, we can disable this function.

Disable ping method

After finding the root of the problem, the rest is how to disable it. There are usually three forms.

First, when starting the program, add: – Druid. Mysql. Usepingmethod = false in the running parameters.

Second, in the spring boot project, you can add the following static code to the startup class:

static {
    System.setProperty("druid.mysql.usePingMethod","false");
}

Third, class file configuration. In the druidconfig class of the project, add:

/*
* Resolving druid log errors: discard long time none received connection:xxx
* */
@PostConstruct
public void setProperties(){
    System.setProperty("druid.mysql.usePingMethod","false");
}

So far, the function has been successfully turned off, and the exception information will never appear again.

Why clear connections that are idle for more than 60 seconds

It is speculated that the idle waiting time of the database set by Alibaba is 60 seconds. When the MySQL database reaches the idle waiting time, the idle connection will be closed to improve the processing capacity of the database server.

The default idle waiting time of MySQL is 8 hours, which is “wait”_ “Timeout”. If the database actively closes the idle connection, but the connection pool does not know that it is still using the connection, an exception will be generated.

[Solved] javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat

There was a problem when the test server restarted Tomcat

javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat

the main reason for the error: 

there are multiple Tomcat on the server, and they all use Druid  to do so

solution: 

modify the catalina.sh :
add this sentence Code: Java_ OPTS=”- Ddruid.registerToSysProperty=true ”

 

With root cause solution

Phenomenon: 1. There is no exception when the project starts, when the page is loaded into the spring:message In the background, the null pointer is abnormal, and the console will display the prompt with root cause;

2. Note out spring:message After related tags, there is no exception, but where the specific content should be displayed, the code value in the tag is displayed;

3. The same project can be used on other people’s computers, but not on my computer;

4. Available on eclipse, not on MyEclipse;

Reason: there is a space in the Tomcat installation path;

Solution: put the Tomcat of the deployment project in a path without spaces, such as the root directory.

The above are the phenomena and solutions I encountered. If there are any other phenomena and solutions, please add.

Caused by: java.io.IOException: APR error: -730053

After the project started, the swigger web page was closed, and the error was reported. Ah, just now it was good. How could the error be reported?I didn’t see the error, and I didn’t know what the problem was. I thought it was a code problem, and then I went to Baidu

The general reason is: the server is outputting problems to the browser, and I shut them down. That’s why the problem is caused. Let’s do it again and solve the problem

Postscript: although it’s a small problem, if you don’t know it, you can waste a lot of time and change your bad habits.

learn in actual combat and grow in happiness

Causes and solutions of WordPress media library pictures not showing or showing errors

Recently, I am developing a WordPress Theme – wait theme, but in the process of development, a wonderful problem suddenly appears, the media library pictures are not displayed!! Always show the small circle in loading, and upload images always fail. After struggling for two or three days, I finally found out the problem and quickly wrote it down….

describe

Recently, I am developing a WordPress Theme – wait theme, but in the process of development, a wonderful problem suddenly appears, the media library pictures are not displayed!! Always show the small circle in loading, and upload images always fail. The details are shown in the figure below:

The selection list mode is normal

attempt

After finding this problem, the other work of theme development can only be temporarily stopped and focused on solving this problem.

First go to the Internet search, the results found that the results are the same, what folder permissions, file coding problems, plug-in settings and so on.

However, this is a local test system. No plug-ins are installed and there is no permission problem. The coding format is utf8 without BOM.

It is found that a few netizens have the same problem as me, but no one below gives a solution…..

After the search on the Internet is fruitless, we can only find a solution by ourselves.

explore

First of all, I suspect that my topic function has the same name as the function of WP. So open it upload.php , compare the functions one by one with the functions written by yourself, and find that there is no duplicate name problem, so this option is excluded.

Then check the admin file, no suspicious situation is found.

In the browser debugging window, check the loading and debugging of CSS and JS, and no exception is found.

Finally, there is no way to open the code window, line by line to view the code, also did not find anything suspicious.

It took me two or three days to go back and forth in this way. Until this afternoon, I found the root of the problem~~~~

problem

When looking at the code again this afternoon, I suddenly found such a statement:

The problem lies in this sentence!!!!

Look at the explanation of HTML Declaration on w3school

≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag.

≪! DOCTYPE & gt; declaration is not an HTML tag; it is an instruction to the web browser about which HTML version the page is written with.

In HTML 4.01, the & lt;! DOCTYPE & gt; declaration references DTD because HTML 4.01 is based on SGML. DTD specifies the rules of markup language, so that the browser can present the content correctly.

HTML5 is not based on SGML, so there is no need to reference DTD.

Tip: always add a & lt;! DOCTYPE & gt; declaration to an HTML document so that the browser knows the document type.

≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag! ≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag! ≪! DOCTYPE & gt; declaration must be the first line of an HTML document, before the & lt; HTML & gt; tag!

Three important words~~

Therefore, as long as the above obnoxious sentence is removed, this problem can be solved ~ ~
by removing it

solve

Looking for the source code, I found that there was a reference in my admin file:

At that time, I thought that this sentence would be in the main body of the web page, so I wrote it. But today, I found that no matter where I put it, it will always appear in the first line of the web page!!! WTF!!!

Only by deleting it and writing the CSS code to the file, can the problem be solved successfully~~~~

summary

1. Don’t blindly believe in things on the Internet, do it yourself is the king

2. Debugging a bug starts with the source code.

3. When it comes to problems, be calm and don’t be impatient~~

4. Do it yourself~~~

prospect

Wait theme will be released soon, please look forward to it~~~

Reprint English blogs with source

Reprint English blogs with source

Reprint English blogs with source

Three important words~~


Welcome to my website:

Other English Blogs

++>

Causes and solutions of WordPress media library pictures not showing or showing errors

Java Error | Error:java: Compilation failed: internal java compiler error

Background

Error:java: Compilation failed: internal java compiler error

According to previous experience, the compiling environment of the read project is reset, and the JDK version is all specified as 1.8
1. Setting – & gt; Java complier

2.Project Structure->Modules

After the above steps are set, the same error will be reported in the recompile run

Solution

After investigation, the project Pom.xml The file does not specify a compiled version, in the Pom.xml Add the following plug-ins:

<build>

    <plugins>
        <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>utf-8</encoding>
            </configuration>
        </plugin>
    </plugins>

</build>

Shrio | java.io.IOException: Resource [classpath:shiro.ini] could not be found

case

case

java.io.IOException: Resource [classpath:shiro.ini] could not be found

Directory of Shiro file:

Solution

After troubleshooting, there is no problem with the file storage directory structure, but the bytecode file directory under target is still the old storage location, under conf/instead of the class directory. Therefore, you can know that this exception must be a compilation problem. Just delete the whole target directory and recompile it

[unable to read project file xxxxx, XXX failed to load project file, name cannot start with “<" character (hex value 0x3c)] exception handling method

Recently, I took over a new project. I downloaded the source code from SVN server to local. When I opened it with visual studio, I reported this exception at the moment of opening it.

Loading D: \% project \% SVN\ xx.csproj …

D:\Project\SVN\ xxx.csproj : error: unable to read project file“ xxx.csproj ”。

D:\Project\SVN\ xxx.csproj (20,2): failed to load project file. The name cannot start with the “& lt;” character (hex value 0x3c). Line 20, position 2.

Then, according to the prompt, I found the position of line 20. Sure enough, there are some problems here.

This is caused by something wrong with SVN. SVN version control software will add content to the csproj file. There should be something wrong with one step.

Solution: in the csproj file, find the problem line, and then delete it from line 20 to line 26.