我正在尝试创建一个灰熊web服务引擎,但是缺少一些元素。
这里是我想做的事情:
我已经知道的:
我想知道的是:
这里是我对类加载器所做的工作
File file = new File("c:\\Users\\User\\Desktop\\myresource.jar");
URL url = file.toURI().toURL();
URL[] urls = new URL[]{url};
ClassLoader cl = new URLClassLoader(urls);
URLClassLoader child = new URLClassLoader (urls, this.getClass().getClassLoader());
Class<?> classToLoad = Class.forName ("Test.ExternalWS.MyResource", true, child);
Method method = classToLoad.getDeclaredMethod ("getIt");
Object instance = classToLoad.newInstance ();
Object result = method.invoke (instance);
this.WSInstance = classToLoad.newInstance();当我试图到达localhost:8080/./myresource时,什么都不会发生。
我试过所有可能的urls并放置一个断点..。一直没到。
发布于 2014-01-27 18:49:11
不知道你用的是哪个泽西版本。在泽西岛,我让它这样运作:
File file = new File("/path/resource1.jar");
URL url = file.toURI().toURL();
URL[] urls = new URL[]{url};
ClassLoader cl = new URLClassLoader(urls, Main.class.getClassLoader());
ResourceConfig rc = new ResourceConfig()
.setClassLoader(cl)
.files("/path/resource1.jar");
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(
BASE_URI, rc);也许还有更优雅的方式..。
发布于 2015-07-28 21:39:37
你用的是灰熊1.x还是2.x分支?
我在灰熊1.x里开发灰熊Deployer。如果源代码能满足您的需要,您应该检查它。
https://stackoverflow.com/questions/21381305
复制相似问题