Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tomcat8 changed the trampling record of jar loading order.

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report