Get the App
SLTechnology News&Howtos  ›  Servers  › 

Tomcat8 changed the trampling record of jar loading order.

Shulou Source: shulou.com Published: 2022-06-02 02:14:15 10月09日 Update

Record a debugging experience

cause

With the same jar, the server is normal and the local project keeps reporting the error in the following figure.

explain

First of all, this code is caused by the error reported by hibernate during the execution of the parameterized hql, which is caused by the uppermost layer of the string.

Looking at the hql and java objects, it is found that the parameter is string, while the field type in the java object corresponding to the parameter is BigDcimal. Guess may be the cause of the problem, but the relevant code can not be found, continue to look at the code, debugging

The function of the bind () method in the stack information (related to the error report), get type and value from the, and make a strong turn to value, where type is set in the parameter setting stage, as shown in the following figure, first find the type in the corresponding java object according to the mapping relationship, but cannot find the value.getclass ().

In org.hibernate.impl.AbstractQueryImpl

Intermediate conclusion

I have no problem locally, that's how the code is written, it's right to report an error, how does the server run?

Go ahead

Take advantage of no one in the morning, remotely debug the server project, in the process, think of whether someone rewrote the source code of hibernate, search it, sure enough.

Hibernate source code

The rewritten code has been modified to ensure that the parameters are string compatible.

Imagine that the loading order of tomcat's jar packages has changed from 8 to 8, instead of loading first in alphabetical order. After 8, we should use another way, which leads to different results of different operating systems, although both use 8, and I am mac, it is linux. At that time, when I read that blog, I felt that there was a hole. I didn't expect it to come so soon.

As for the specific loading methods of different operating systems, you need to see the tomcat source code, but have not seen it yet.

Conclusion

Because the effective class is different, the results of the local and server are different. If you do not want to see the source code, you can delete the duplicate class of hibernate first. It should be possible to modify the source code, such as alphabetical order.

I have to complain about why tomcat changed the loading order of jar, and how clear it was in alphabetical order.

Well, the above is the whole content of this article. I hope the content of this article has a certain reference and learning value for your study or work. Thank you for your support.

Tags: Order difference code parameter source code server service letter object way operating system content namely type system result conclusion process problem project Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MySQL Linux MariaDB Microsoft