Tag Archives: java

The reason why HashMap multithreads send out life and death loops

This article is a learning record of Vaccine: Java HashMap’s endless loop, welcome to discuss ~
Suppose the state of a cylinder to be expanded is as follows:
1->; 2-> Null
1 for the current thread to insert a new element of an array of e: 1 and the next element next:
when thread 2 completed the expansion, the pointer to the current status to 2 – & gt; 1-> NULL
Thread 1 continues:
rst (e:1,next:2)
n>arrel :1 ->; null

e=next=2;
next=e1.next=1;

> (e:2,next:1)
> 1-> null

e=next=1;
next=e1.next=null;

(e:1,next:null)
new barrel :1 ->; 2-> 1 is just 1 lt; -> 2

e=next=null;

cpu100%
7 using head insert, 1.8 using tail insert for capacity expansion.
1.7 using head insert, 1.8 using tail insert for capacity expansion.

Eclipse cannot import org.apache.log4j .Logger

Recently, I’ve been practicing using log4j, but I keep getting errors when importing from Eclipse

 
But I have already imported it in the lib below
 

I guess the JAR package was not imported
If you want to place the JAR under the JDK, right-click and select Build Path –>; Configure Build Path
 

 
Then select Add Externsl Jars

 
Select the package we want to import

Then click Apply and it’s OK.
 

Unable to read meta data for class

From: http://www.infoq.live/links, original author: Chen, wei

    problem description

Unable to read meta-data for class
Unable to read meta-data for class
Unable to read meta-data for class
Unable to read meta-data for class
Locate

    analysis custom starter in spring. The factories configure multiple configuration, need each other to interval \

    org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    cn.xxx.xxx.secret.SecretAutoConfiguration,
    cn.xxx.xxx.secret.modules.cors.WebMvcConfiguration
    

    Correct configuration:

    org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    cn.xxx.xxx.secret.SecretAutoConfiguration,\
    cn.xxx.xxx.secret.modules.cors.WebMvcConfiguration
    

Causes and solutions of classnotfoundexception / NoClassDefFoundError

A NoClassDefFoundError is an Error, while a ClassNotFoundException is an exception. In Java, an Error and an exception are handled differently. You can recover from an exception but you shouldn’t try to recover from an Error.
ClassNotFoundException causes:
Java supports dynamically loading classes using the Class.forName method. Passing the Class name of any Class as an argument to the method will cause the Class to be loaded into the JVM memory. If the Class is not found in the classpath, then a ClassNotFoundException is thrown at runtime.
ClassNotFoundException solve
Solving this problem requires ensuring that the required class, along with its dependent packages, exists in the classpath. A common problem is that the class name is misspelled.
Another cause of ClassNotFoundException is that when a class has already been loaded into memory by one class loader, another class loader tries to dynamically load the class from the same package. This can be avoided by controlling the dynamic classloading process.
NoClassDefFoundError causes:
If the JVM or ClassLoader instance tries to load a class (either through normal method calls, or by using new to create a new object), the class definition is not found. The class you are looking for exists at compile time but cannot be found at run time.
The problem may be caused by missing classes during the packaging process, or by corrupted or tampered JAR packages.
NoClassDefFoundError solve
The solution to this problem is to look for classes that are in the classpath at development time but not at run time.

solve com.mysql.jdbc . exceptions.jdbc4 .MySQLSyntaxErrorException:

Solve the com. Mysql. JDBC. Exceptions. Jdbc4. MySQLSyntaxErrorException:
1. Error content

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where userid='j2ee'' at line 1
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at [email protected]/com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
	at [email protected]/com.mysql.jdbc.Util.getInstance(Util.java:408)
	at [email protected]/com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
	at [email protected]/com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
	at [email protected]/com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
	at [email protected]/com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
	at [email protected]/com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
	at [email protected]/com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2501)
	at [email protected]/com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
	at [email protected]/com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966)
	at com.a51work6.jpetstore.dao.mysql.AccountDaolmp.findById(AccountDaolmp.java:33)
	at com.a51work6.jpetstore.ui.LoginFrame.lambda$0(LoginFrame.java:65)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6632)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6397)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

2. Problem analysis
This error is usually caused by an error in the SQL statement in my code. My code is as follows:

conn=DBHelper.getConnection();
			String sql="select userid, password,email,name,addr,userid,city,country,phone"     //userid,password,email,name,addr,city,country,phone
					+"from account where userid=?";
			pstmt=conn.prepareStatement(sql);
			pstmt.setString(1, id);
			rs=pstmt.executeQuery();

Where userid=’ J2EE ‘is an error. I thought I had a problem with id, but it turned out to be a space missing when concatenating the SQL string.
3. Summary
looked at other people’s blogs, and he made the wrong conclusion in this type of error check content:
1, check to see if the format of the SQL statement right
2, check the SQL statement whether the use of punctuation in English
3, “mark> connection, special attention to the SQL statement must add Spaces among

Centos8 solves the problem of “failed to set locale, defaulting to c.utf-8”

Problem description

>
>
>
>
>
>
>
>
>

systemctl status mysqld.service

journalctl -xe


Failed to set locale, defaulting to C.UTF-8
How to solve
To set the system locale, use the localectl command. For example, if you want to use UTF-8 encoded American English (US), run the following command.
download centos docker mirror system default is ISO/IEC 15897 character set
need to utf-8.
to install all of the first character set

dnf install langpacks-en glibc-all-langpacks -y

Set character set

localectl set-locale LANG=en_US.UTF-8

Restart the mysql
bingo!!!!!!
success

JSON data format net.sf.json .JSONException: A JSONObject text must begin with ‘{‘ at character 1 of Error:(f…

The substring (3) the use of the http://www.w3school.com.cn/jsref/jsref_substring.asp

Possibility 1: if sb is the data to be converted, let’s say sb is a String

 


The char
The STR [] = sb. ToString (). ToCharArray ();


for
(
The int
i=
0
; i< str.length; i++){


System.out.println(str[i]);


}

After can get into an array of form, check the array before any Spaces, such as if useful
sb.toString().trim().substring(
1
); Cut off


The String json = sb. ToString (). The trim (). The substring (
1
);


The // String json = "{\" success \ ": true, \" MSG \ ": \ \" successful "} ";


System.out.println(json);


System.out.println(json.length());


The JSONObject JSONObject = JSONObject. FromObject (json. The trim ());


System.out.println(jsonobject);



The

"Result" : [{}] ------ left less {

Possibility 2: No initialization, no initBmob () is likely to report this wrong Unregistered

Possibility 3: There is an extra space before the data in the database

 

Reproduced in: https://www.cnblogs.com/wth21-1314/p/7381575.html

[Jackson exception] com.fasterxml.jackson . databind.JsonMappingException Exception handling method

In the project, the parent layer is Car.java [Vehicle Entity] and the child layer is CarCommonParam.java [Vehicle Basic Entity], which is the basic information of a vehicle to multiple vehicles
But at the time of query library collection is a entity error: 【 com. Fasterxml. Jackson. Databind. JsonMappingException 】

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: cn.skyable.zulin.common.bean.CarCommonParam_$$_jvst95e_39["handler"])
X-Zc-Ack-->null
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59)
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:541)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:644)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1837)
	at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:261)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshalArray(ACObjectMarshaller.java:53)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshalObject(ACObjectMarshaller.java:37)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshal(ACObjectMarshaller.java:22)
	at com.ablecloud.common.ACObject.toString(ACObject.java:415)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at cn.skyable.zulin.BaseTest.dealResp(BaseTest.java:88)
	at cn.skyable.zulin.logistics.TestLogistics.TestlistCarsByLogId(TestLogistics.java:65)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)

Error description: A truncation is made in the entity where the child layer can look up information about the parent layer, but the parent layer cannot look up information about the child layer due to circular reference problem.
Solution:
Add to the parent car.java
Instead of

Just !!!!