Category Archives: Error

[Solved] Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse

Ajax cannot get data:
Problem Description:
vm379:1 uncaught syntax error: unexpected end of JSON input at json.parse(

Cause analysis:
1. The format of JSON data returned by the back end is incorrect
2. The method of JSON data returned by the back end is incorrect

Solution:
PHP:

  return json_encode(array(
         'status' => 3,
         'message' => 'Incorrect ID'
     ));

Replace with:

echo '{"status": 3, "mesg": "Incorrect ID" }';

Note: JSON strings should be enclosed in double quotation marks

Problem-solving

 // ajax
    function del_cate(id, pid) {
      if (window.XMLHttpRequest) {
        var xmrt = new XMLHttpRequest();
      } else {
        var xmrt = new ActiveXObject('Microsoft.XMLHTTP');
      }

      xmrt.onreadystatechange = function () {
        if (xmrt.readyState == 4 && xmrt.status == 200) {
          console.log(xmrt);
          console.log(JSON.parse(xmrt.responseText));
          var status = JSON.parse(xmrt.responseText);

          if (status.status == 1) {
            alert('Deleted successfully!');
            window.location.href = 'cate.php';
          } else if (status.status == 0) {
            alert('Deleted successfully!');
            window.location.href = 'cate.php';
          } else {
            alert('Deleted successfully!');
            window.location.href = 'cate.php';
          }
        }
      }
      xmrt.open('DELETE', './del_cate.php?id=' + id + '&pid=' + pid, true);
      xmrt.send();
    }

How to Solve the inaccessibility of Website After the SSL certificate is added

Error Message:
An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding ‘EnableRetryOnFailure()’ to the ‘UseMySql’ call.

Solution:
Connection string Add;sslMode=None on it, the code is as follows.
“Default”:’Server=127.0.0.1;port=3306;Database=database;Uid=account;Pwd=password;CharSet=utf8;Allow User Variables=True;sslMode=None;’;

IProgress not found. Please update jupyter and ipywidgets [How to Solve]

Iprogress not found. Please update Jupiter and ipywidgets

The following error messages appear when using jupyter recently

ImportError: IProgress not found. Please update jupyter and ipywidgets. 
See https://ipywidgets.readthedocs.io/en/stable/user_install.html

The following methods can solve this problem:

Install dependent libraries first

pip install ipywidgets widgetsnbextension pandas-profiling

Start the Jupiter corresponding plug-in

jupyter nbextension enable --py widgetsnbextension
 

[Solved] failure to inject AuthenticationManager directly Error

@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter
{

    /**
     * Solution: Unable to inject directly AuthenticationManager
     *
     * @return
     * @throws Exception
     */
    @Bean
    @Override
    public AuthenticationManager authenticationManagerBean() throws Exception
    {
        return super.authenticationManagerBean();
    }


xxxxxxxxx.......
}

[Solved] Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location

Problem description

When using Vue router code for route jump, click a link repeatedly and report the following error

analysis

Avoid repeated navigation to this address. In short, don’t click repeatedly in the same place.

Solution:

Add the following code in index.JS under the router folder:

Note: before creating a routing instance

import VueRouter from "vue-router"

const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function (location) {
  return originalReplace.call(this, location).catch(err => err)
}

It seems that the other party declares a variable to point to the original replace function, and then re declares the new replace function. When we call the replace function of router again, we execute the new replace function, and then catch exceptions to enable the program to continue to execute later

[Solved] org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character ‘@’

1. Question


Running the springboot project encountered the following error

org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character ‘@’.

This is because I configured it in POM.XML

<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<env>dev</env>
				<mysql.host>172.30.254.12</mysql.host>
				<mysql.port>3306</mysql.port>
				<mysql.user>root</mysql.user>
				<mysql.password>123456</mysql.password>
			</properties>
		</profile>
</profiles>

Then, I want to get the mysql.host attribute configured in the profile through% MySQL. Host% in application.yml.

However, when the project is started, the above error is reported.

2. Solution


After searching the Internet, it is true that some people have encountered similar problems. In his article, he said that Maven reimport can solve them.

The following is the step of Maven reimport. After following this step, the project can start smoothly.

Intellj’s function of automatically loading Maven POM is sometimes very easy to use, but sometimes many problems will be encountered, resulting in POM file modification without triggering automatic rewriting loading. At this time, you need to manually force the update of dependencies:

Manually delete the libraries package in project setting

Click the clean function in the project lifecycle in the Maven window to delete the previously compiled files

Right click the item — Maven — reimport

[Solved] psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

Error message.

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

There are many cases of this problem, the following are some of the cases I have encountered so far, and I will continue to add them afterwards.

1. The .s.PGSQL.5432 and .s.PGSQL.5432.lock files in the /tmp path are deleted.

Solution: Restart the database $sudo service postgresql restart

2. Modify the listening port.
Before I used 5434 to listen, but later I changed it to 5432, the database started, but psql could not enter the database, but I could enter it by psql -p 5432.

Solution: The port PGPORT was configured during installation. modify the port specified in ~/.bash_profile or /etc/profile file.

3. modified unix_socket_directories in postgresql.conf

 

Quoting from which.
“First, let’s look at the socket file “/tmp/.s.PGSQL.1921″, where 1921 is the port number of pg; the socket file can be configured with the
postgresql.conf file with the following parameters.
#unix_socket_directory = ”
#unix_socket_permissions = 0777
Note: The parameter unix_socket_directory is used to configure the directory of the socket file, the default is the /tmp directory, and the parameter
unix_socket_permissions is used to set the permissions of the socket file.”

Solution:Specify the host and connect with psql -h

[Solved] SyntaxError: unexpected character after line continuation character

Note: the above code looks OK on the surface, but an error is reported: syntax error: unexpected character after line continuation character.

The reason for the problem here is:

There is a space after the line break ‘\’ on the first line. When there is a space after the newline character, the program will report an error.

Solution:

Very simple, just delete the spaces after the newline character “\” and the problem is solved.

In other words, nothing else is allowed after the newline character. Include comments#

hdfs cluster Error: Please check the logs or run fsck in order to identify the missing blocks. See the Hadoop FAQ for common causes and potential solutions.

Please check the logs or run fsck in order to identify the missing blocks. See the Hadoop FAQ for common causes and potential solutions.

hadoop  fsck 


hadoop  fsck -delete

Cause analysis:

This problem occurs after deleting data on several HDFS. The exception information is

In HDFS, data is stored in block mode (blk_1073748128 is a block without understanding error), and After BLK_1073748128 is deleted, the metadata is still there, but the data block is gone, so this error is reported. However, this part of the data is not needed, so the metadata information of the abnormal file block can be deleted directly.

[Ubuntu18.04] Docker Start Error: Got permission denied while trying to connect to the Docker daemon socket

1. Reasons

The docker process uses UNIX sockets instead of TCP ports. By default, UNIX socket belongs to root user, so it needs to   Root privileges   To access

2. Solutions

# Create a docker group
sudo groupadd docker
# Check if the current user is in the docker group          
sudo gpasswd -a $your_user_name docker   
# Add the current user to the docker group
sudo gpasswd -a $USER docker
# Update group information  
newgrp docker

3. Inspection results

docker version