Author Archives: Robins

[Solved] Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses

Problem Description:

An error is reported when using MapReduce to implement data Deduplication

Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses

In addition, there are: Java.lang.NoClassDefFoundError; java.io.IOException: Cannot initialize Cluster.

Problem-solving:

These problems are due to the incomplete import of MapReduce and Hadoop dependencies:

<dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <version>3.2.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-hdfs</artifactId>
      <version>3.2.0</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <version>3.2.0</version>
    </dependency>

    <!--mapreduce-->
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-mapreduce-client-core</artifactId>
      <version>3.2.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-mapreduce-client-common</artifactId>
      <version>3.2.0</version>
    </dependency>

So far, the problem has been solved

[Solved] Django error: AttributeError: ‘QuerySet’ object has no attribute ‘id’

summary:

Login users can view the article details, and visitors can’t view the article details and report errors

Error codes are as follows:

Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
--The above codes are basically to determine the identity of the visitor--
1
The value of next_topic is: <QuerySet [<Topic: Topic object (2)>, <Topic: Topic object (3)>]>
Internal Server Error: /v1/topics/qq66907360
Traceback (most recent call last):
  File "D:\Program Files (x86)\Python\Python310\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "D:\Program Files (x86)\Python\Python310\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "D:\Program Files (x86)\Python\Python310\lib\site-packages\django\views\generic\base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "D:\Program Files (x86)\Python\Python310\lib\site-packages\django\views\generic\base.py", line 101, in dispatch
    return handler(request, *args, **kwargs)
  File "D:\PycharmProjects\linuxTangblog\topic\views.py", line 151, in get
    res = self.make_topic_res(author,author_topic,is_self)
  File "D:\PycharmProjects\linuxTangblog\topic\views.py", line 29, in make_topic_res
    next_id = next_topic.id if next_topic else None
AttributeError: 'QuerySet' object has no attribute 'id'
[17/Dec/2021 15:02:20] "GET /v1/topics/qq66907360?t_id=1 HTTP/1.1" 500 79151

Troubleshooting process:

After traversing the ‘queryset’ object, I found that the traversed data is an object object object, and then I took the value with the object value,

The value of next_topic is: <QuerySet [<Topic: Topic object (2)>, <Topic: Topic object (3)>]>
next_topic = Topic.objects.filter(id__gt=author_topic.id,author=author,limit='public')
for i in next_topic:
    print(i.id)

Then I thought that the previous article and the next article only need one value, but obviously the queryset object has multiple values, which does not meet the expectation. Then I look at the code and find that the condition of first () or last () is not written

        if is_self:
            #Next
            next_topic = Topic.objects.filter(id__gt=author_topic.id,author=author).first()
            #previous
            last_topic = Topic.objects.filter(id__lt=author_topic.id,author=author).last()
        else:
            next_topic = Topic.objects.filter(id__gt=author_topic.id,author=author,limit='public')
            last_topic = Topic.objects.filter(id__lt=author_topic.id,author=author,limit='public')

Solution:

Add the condition of first() or last()

        if is_self:
            #Next
            next_topic = Topic.objects.filter(id__gt=author_topic.id,author=author).first()
            #previous
            last_topic = Topic.objects.filter(id__lt=author_topic.id,author=author).last()
        else:
            next_topic = Topic.objects.filter(id__gt=author_topic.id,author=author,limit='public').first()
            last_topic = Topic.objects.filter(id__lt=author_topic.id,author=author,limit='public').last()

[Solved] Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

In the spring boot project, I deleted a line of code because I was in debt. It took 2-3 hours to solve the problem. It is hereby recorded.

        <!--The following resources are added later to specify the package file -->
         <resources>
             <resource>
                 <directory>src/main/resources</directory>
                 <!-- The resource root directory excludes the configuration of each environment to prevent redundant directories in the generated directory -->
                <filtering>true</filtering>
                <excludes>
                    <exclude>application*.yml</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>application.yml</include>
                    <include>application-${profiles.active}.yml</include>
                </includes>
            </resource>
        </resources>

This <include> in application.yml It was deleted by me.

[Solved] Failed to get node ip address matching nodeport cidr: no addresses found for cidrs [172.16.19.0/24]

The nodeport defined by the k8s cluster cannot take effect. There is no corresponding port listening in netstat

Check the Kube proxy log and find that

Guess, the address has run out. Temporary solution:

Modify Kube proxy configuration

kubectl edit cm kube-proxy  -n kube-system

# Add in the Path of nodePortAddresses
nodePortAddresses: ["172.16.0.0/16"]

# Delete kube-proxy pod working

The cluster is generated using kubedm. I guess you need to specify the address range of nodeportaddresses in kubedm

Anki cannot start on Debian Buster [How to Solve]

The default Anki package v2.1.8 in Debian Buster cannot start normally with the following error message.

qt: Could not load the Qt platform plugin "xcb" in "" even though it was found.
qt: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted

This message is not detailed enough to locate the cause of the problem. To make more starting information of Anki printed out, set the environment variable QT_DEBUG_PLUGINS as

export QT_DEBUG_PLUGINS=1

Then, restart Anki and at the end of the error message, it reads as

qt: Got keys from plugin meta data ("xcb")
qt: QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
qt: Cannot load library /home/username/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)
qt: QLibraryPrivate::loadPlugin failed on "/home/username/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/username/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No suchfile or directory)"
qt: Could not load the Qt platform plugin "xcb" in "" even though it was found.
qt: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted

So it is obvious that the shared library libxcb-util.so.1 cannot be found on my system and what has actually been installed is libxcb-util.so.0, which is provided by the package libxcb-util0. Luckily, this problem can be easily solved by creating a symbolic link from libxcb-util.so.0 as below.

cd /usr/lib/x86_64-linux-gnu
sudo ln -sf libxcb-util.so.0 libxcb-util.so.1

Now, Anki can start and work properly.
Unfortuntely, there is still a shortcoming that it does not support the Chinese input method Fcitx. It is said that the input method ibus can be supported, but I refuse to switch to it, since it has another problem which, according to here, makes the first character in the selection list blocked by a black box. Then I suggest you download the newest version of Anki from its official site.

FileZilla path must be absolute [How to Solve]

The FileZilla server is downloaded. When setting the FTP directory, the software reports path must be absolute

I have set the absolute path F:\Users\Administrator\PycharmProjects\python_switch\ops\

Why do you report an error?

Solution:

Virtual path use /

Native path use \

virtual path  /ops/

Native path  F:\Users\Administrator\PycharmProjects\python_switch\ops\

[ftp]get /ops/ops_demo.py

[Solved] rocky-linux8.5 Install gitea Error: services.server Additional property db is not allowed

problem

Today we use rocky – Linux 8 5 installed docker composer and then gitea. An error was encountered during installation services server Additional property db is not allowed

Solution:

First of all, other errors were reported for the yml format problem. After the problem was resolved, the above error was reported. Some people on the Internet said that it is related to the version of docker-compose, but it is not. The docker version I use is 20.10.12, and the version of docker-compose is v2.2.2 (offline installation), finally check the yml format, where the mirror image gitea and mysql are not at the same level, mysql is used as a sub-layer of gitea, and gitea is depend-on mysql. You can adjust it to the same level later.

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.15.7
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
       - "3000:3000"
       - "222:22"
    depends_on:
       - db
 
  db:
    image: mysql:8
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
         - ./mysql:/var/lib/mysql

The reason for the error is that depends_on is db, and db and server are not at the same level. You can find the reason by comparing with online yml or a text editor.

[Solved] IDEA: JSP Could Not Use session Build-in Object

Problem description

Cause

since the author uses Tomcat 10, the servlet dependency used is Jakarta Servlet. For details, see building a servlet using Tomcat 10. An error is reported: class XXX is not a servlet. The error is because the servlet API package is not imported.

Solution:

Import servlet API dependencies.

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
</dependency>

Qitemselectionmodel: How to Fix Getting qmodelindexlist program crash Issue

There are no trivial things in work: turning a stone into gold and a drop into a river. Only by taking everything you do seriously can you overcome all difficulties and achieve success.

The program crashed when using QT’s qitemselectionmodel to get qmodelindexlist in the project.

Usage scenario:

QItemSelectionModel *selections =pTreeView->selectionModel();
QModelIndexList selectedindexes = selections->selectedRows();

In this way, an error will be reported after calling.

Solution: find the source code of selectedrows and implement the currently selected item by yourself

    QItemSelectionModel *selections = pTreeView->selectionModel();

    QModelIndexList selectedindexes;
    //the QSet contains pairs of parent modelIndex
    //and row number
    QSet<QPair<QModelIndex, int>> rowsSeen;

    const QItemSelection ranges = selections->selection();
    for (int i = 0; i < ranges.count(); ++i)
    {
        const QItemSelectionRange& range = ranges.at(i);
        QModelIndex parent = range.parent();
        for (int row = 0; i < range.top(); row <= range.bottom(); row++)
        {
            QPair<QModelIndex, int> rowDef = qMakePair(parent, row);
            if (!rowsSeen.contains(rowDef))
            {
                rowsSeen << rowDef;
                if (selections->isRowSelected(row, parent))
                {
                    selectedindexes.append(pModel->index(row, 0, parent));
                }
            }
        }
    }

[Solved] Jenkins deploy task error: Host key verification failed

Environment configuration: Jenkins + gitlab deployment

Jenkins reported the following error: host key verification failed; could not read from remote repository

Xshell logs in to the background to view the problems during deployment

The background directly uses the GIT command gitllab to check in locally

Then go to the page to deploy the task, and you can succeed