alibaba / jvm-sandbox-repeater

A Java server-side recording and playback solution based on JVM-Sandbox
Apache License 2.0
2.51k stars 700 forks source link

HttpServletRequest是如何不被SandboxClassLoader加载的 #193

Open yihengwang4 opened 1 year ago

yihengwang4 commented 1 year ago

sandbox中javax.servlet下的类都由SandboxClassLoader加载。在我自己的demo项目中,以增强HttpServlet中service为例,如果直接将入参对象转化为HttpServletRequest会出现由于classLoader不一样而引发的java.lang.ClassCastException。想请教一下sandbox-repeater中是怎么做到可以直接进行类型转化的呀 private ModuleJarClassLoader(final File moduleJarFile, final File tempModuleJarFile, final Routing... specialRouting) throws IOException { super( new URL[]{new URL("file:" + tempModuleJarFile.getPath())}, assembleRouting(new Routing( ModuleJarClassLoader.class.getClassLoader(), "^com\\.alibaba\\.jvm\\.sandbox\\.api\\..*$", "^javax\\.servlet\\..*$", "^javax\\.annotation\\.Resource.*$" ), specialRouting) ); // ... }

reducm commented 11 months ago

相同疑问 +1

haimachl commented 10 months ago

+1 也遇到相同问题