Open yihengwang4 opened 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) ); // ... }
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) ); // ... }
相同疑问 +1
+1 也遇到相同问题
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) ); // ... }