Category Archives: How to Fix

Solution of adding judgment error in the iterative process of Java iterator iterator

        The first time I tried to use a blog to record my Xiaobai’s learning process, which is mainly convenient for me to query in the future, but it would be great if I could help other friends!

1、 Scenario description

        This is the function of reading data from the database and then exporting excel tables. The value is assigned by the iterator to realize the export. The code is as follows:

protected void generate() {
   XSSFCellStyle xssfCellStyle = defaultStyle();
   defineHeader(this.meta);
   headerDataCount = this.defaultSheet.getPhysicalNumberOfRows();
   for (int i = 0; i < this.data.size(); i++) {
      List<Map<String, Object>> cellList = this.data.get(i);
      for (int j = 0; j < cellList.size(); j++) {
         renderCell(0, i, String.valueOf(i + 1), xssfCellStyle);
         Iterator<Object> iterator = cellList.get(j).values().iterator();
         while (iterator.hasNext()) {
            String value = String.valueOf(iterator.next());
            renderCell(j + 1, i, value, xssfCellStyle);
            beautifyColumn(j + 1, value, xssfCellStyle);
         }
      }
   }
}

        The problem encountered is that the null value (null value) displayed in the Oracle library is displayed as “null” in the exported excel table. I want to add a judgment during iteration to make the read null directly change to “”.

2、 Something went wrong

I changed it this way:

   String value = iterator().next()==null?"":String.valueOf(iterator().next());

However, an error is reported:

         java.util.NoSuchElementException

3、 Settle

Cause of problem:

         The next () method of iterator class cannot appear twice in the same loop, which will cause the last cursor to point to a null value.

Modification:

         Add a variable to receive the iterator:

    Object a = iterator.next();
    String value = a==null?"":String.valueOf(a);

 

Solution to the error cannot resolve symbol reported by build.sbt

Solution to the error cannot resolve symbol reported by build.sbt

1. Background 2. Error reporting 3. Solution

1. Background

Idea version 2017.2, development language Scala, when re importing the SBT project, build.sbt became popular and cannot resolve symbol

2. Error reporting

As shown below

3. Solutions

3.1 delete the. Idea folder

3.2 using file – & gt; Invalidcaches/restart restart


3.3 after restarting, wait for the idea to regenerate the. Idea folder and solve the error!

Solution to error reporting on the client caused by adding fields on the CXF server

To solve this problem, turn off the field verification function

1. Spring framework:

Add the following configuration in the configuration file

<cxf:properties>
   <entry key="set-jaxb-validation-event-handler" value="false"/>
</cxf:properties>

2. Springboot framework:

Add @ endpointproperties annotation on WebService implementation class

@WebService(
        targetNamespace = "http://ws.test.com/",
        serviceName = "demoWebService",
        endpointInterface = "com.test.ws.DemoWebService")
@EndpointProperties({@EndpointProperty(key = "set-jaxb-validation-event-handler", value ="false")})
@Configuration
public class FaultOrderWebServiceImpl implements DemoWebService {

}

Kafka opens JMX port and reports that the error port is occupied

Kafka turns on JMX_ After port, when using Kafka command-line tools (Kafka topics, kafka-console-consumer.sh, etc.), an exception will be reported that the port is occupied, such as:

bash-5.1# /opt/kafka_2.13-2.7.0/bin/kafka-topics.sh --create --topic chat --partitions 5 --zookeeper 172.16.5.16:2181 --replication-factor 3
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
        java.net.BindException: Address in use (Bind failed)
sun.management.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
        java.net.BindException: Address in use (Bind failed)
        at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:480)
        at sun.management.Agent.startAgent(Agent.java:262)
        at sun.management.Agent.startAgent(Agent.java:452)
Caused by: java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
        java.net.BindException: Address in use (Bind failed)
        at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346)
        at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:254)
        at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412)
        at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
        at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:237)
        at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:213)
        at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:173)
        at sun.management.jmxremote.SingleEntryRegistry.<init>(SingleEntryRegistry.java:49)
        at sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:816)
        at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:468)
        ... 2 more
Caused by: java.net.BindException: Address in use (Bind failed)
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.ServerSocket.bind(ServerSocket.java:392)
        at java.net.ServerSocket.<init>(ServerSocket.java:254)
        at java.net.ServerSocket.<init>(ServerSocket.java:145)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:45)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:345)
        at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670)
        at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335)
        ... 11 more

terms of settlement:

Modify the bin/kafka-run-class.sh file:

Find this code

if [  $JMX_PORT ]; then
  KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
fi

Replace with the following:

ISKAFKASERVER="false"
if [[ "$*" =~ "kafka.Kafka" ]]; then
    ISKAFKASERVER="true"
fi
if [  $JMX_PORT ] && [ -z "$ISKAFKASERVER" ]; then
  KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
fi

Then create topic and solve the problem.

bash-5.1#
bash-5.1# /opt/kafka_2.13-2.7.0/bin/kafka-topics.sh --create --topic chat --partitions 5 --zookeeper 172.16.5.16:2181 --replication-factor 3
Created topic chat.
bash-5.1#

Solutions to remote or adding SSH key errors

 

 

Method 1

ssh-keygen -R XX.XX.XX.XX  

Method 2

【1】 Delete the corresponding IP in known_ Hosts related information

vim /.ssh/known_ hosts

The problem is solved. The reason is that after the system is reinstalled, the remote connection is made again. After entering yes, this opportunity writes the information of the remote machine to/users/Wangdong /. SSH/known_ Hosts file, so if you reinstall the system remotely, you must clean up the machine first.

The browser reported an error ‘stylesheets undefined’‘‘

Problem Description:

The browser reported an error of ‘stylesheets undefined’

this.sheetData.styleSheets = "";

Cause analysis:

In some scenarios, stylesheets do not exist, causing the browser to report an error and are not defined


Solution:

Add a judgment. If stylesheets does not exist, this attribute will be automatically added and null value will be assigned.

if (this.sheetData) {
      this.sheetData['styleSheets'] = "";
    }

Canal synchronization error target column: name not matched

I. problem description

We have a usage scenario for canal:

Synchronize the same table data from multiple source ends to the same target end for unified data display.

However, it is found that after the field is deleted at source 1, the canal client logs of other sources will report an error:

Target column: name not matched
after that, the SQL operations of this table (such as insert, even if data is not inserted into the deleted field) cannot be synchronized.

II. How to avoid

In the scenario where multiple source ends are performing canal synchronization to the same target end, the drop field is prohibited.

Ego planner swarm installation and error reporting solution

Project address: https://github.com/ZJU-FAST-Lab/ego-planner-swarmhttps://github.com/ZJU -FAST-Lab/ego-planner-swarm https://github.com/ZJU-FAST-Lab/ego-planner-swarm

The errors reported after compilation are as follows:

  After consulting the author, the reply is as follows:

But I didn’t know how to change the file the author said, so I asked/ego Planner/SRC/UAV_ simulator/Utils/multi_ map_ Modify server/cmakelists.txt as follows:

  After compiling successfully, run

roslaunch ego_planner rviz.launch
roslaunch ego_planner swarm.launch

The results are as follows:

The java.lang.exceptionininitializererror of mybatis reports an error

1. First, look at mybatis-config.xml

<mapper resource="com/kuang/dao/TeacherMapper.xml"/>

Be sure to follow the student mapper above. The directory where XML is stored is right

2. Look at mapper.xml

<mapper namespace="com.kuang.dao.StudentMapper">

Be sure to match the directory stored in the student mapper above

3. If there is Chinese in the comments, check whether UTF-8 in the two XML is changed to uft8

<?xml version="1.0" encoding="UTF8" ?>

4. Maven resource export problem

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>
</build>

5. Check whether mapper and mapper.xml are in the same directory under the target directory, and then check whether there are any extra or duplicate. If so, delete those that do not correspond to the SRC directory above.

Summary:

The directories of SRC, test and target should be consistent!!!