New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use NarClassLoader in protocol hander callbacks. #11270
Labels
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Comments
Jason918
added
the
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
label
Jul 9, 2021
@Jason918 Do you expect to get the class loader in this way
see This is how the dubbo2.7 metadata module obtains the class loader |
1 task
@complone Yes, I am currently using |
This was referenced Dec 25, 2021
BewareMyPower
pushed a commit
that referenced
this issue
Jan 4, 2022
) ### Motivation It's ``AddtionalServlet`` side change, like #11270 ### Modifications Change context class loader through Thread.currentThread().setContextClassLoader(classLoader) before every protocol handler callback, and change it back to original class loader afterwards.
wuzhanpeng
pushed a commit
to wuzhanpeng/pulsar
that referenced
this issue
Jan 5, 2022
…che#13501) ### Motivation It's ``AddtionalServlet`` side change, like apache#11270 ### Modifications Change context class loader through Thread.currentThread().setContextClassLoader(classLoader) before every protocol handler callback, and change it back to original class loader afterwards.
codelipenghui
pushed a commit
that referenced
this issue
Jan 6, 2022
) ### Motivation It's ``AddtionalServlet`` side change, like #11270 ### Modifications Change context class loader through Thread.currentThread().setContextClassLoader(classLoader) before every protocol handler callback, and change it back to original class loader afterwards. (cherry picked from commit 40ac793)
codelipenghui
pushed a commit
that referenced
this issue
Jan 10, 2022
) ### Motivation It's ``AddtionalServlet`` side change, like #11270 ### Modifications Change context class loader through Thread.currentThread().setContextClassLoader(classLoader) before every protocol handler callback, and change it back to original class loader afterwards. (cherry picked from commit 40ac793)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Is your enhancement request related to a problem? Please describe.
I am working on a new protocol handler for an existing mq implementation.
ClassNotFoundException occurs when I am calling methods like
com.fastjson.JSON.parseObject("some json str", MyConfig.class)
. This happens because the MyConfig.class is dynamically loaded by a NarClassLoader in protocol hander mechanism, but current thread callingProtocolHandler::initialize
uses the default class load in pulsar.Describe the solution you'd like
IMHO, Maybe it's not very elegant for protocol handler to handle class loader issue in its own project?
As there is an ProtocolHandlerWithClassLoader object in each protocol handlers, I am suggesting change the thread default class loader to the NarClassLoader before we call interfaces in ProtocolHandler.
Describe alternatives you've considered
Currently, I am getting the NarClassLoader through
MyProtocolHandler.class.getClassLoader()
.I think it's a bit of tricky.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: