|
Hi,
I have successfully integrated Grizzly2.1.9 with Jersey and Spring. But could not make it work when trying to migrate Grizzly to version 2.2.19. The original code with Grizzly2.1.9 is as below. HttpServer server = new HttpServer(); NetworkListener listener = new NetworkListener("grizzly2", "localhost", 3388); server.addListener(listener); ServletHandler sa = new ServletHandler(); sa.setContextPath("/"); sa.setServletInstance(new SpringServlet()); sa.addContextParameter("contextConfigLocation", "classpath:spring-context.xml"); sa.addServletListener("org.springframework.web.context.ContextLoaderLis tener"); sa.addServletListener("org.springframework.web.context.request.RequestC ontextListener"); ServerConfiguration config = server.getServerConfiguration(); config.addHttpHandler(sa, new String[] {"/"}); server.start(); And the new code with Grizzly2.2.19 is as below HttpServer server = new HttpServer(); NetworkListener listener = new NetworkListener("grizzly2", "localhost", 3388); WebappContext ctx = new WebappContext("ctx","/"); final ServletRegistration reg = ctx.addServlet("spring", new SpringServlet()); reg.addMapping("/"); ctx.addContextInitParameter("contextConfigLocation", "classpath:spring-context.xml"); ctx.addListener("org.springframework.web.context.ContextLoaderListener" ); ctx.addListener("org.springframework.web.context.request.RequestContext Listener"); ctx.deploy(server); server.start(); The new code could be compiled and executed with no exception. However all urls which should be forwarded to different methods by Jersey are now all forwarded to the default page "/". I want to know what I miss with the new code. Thanks so much! |
|
Administrator
|
Hi,
can you pls. elaborate which urls used to work w/ Grizzly 2.1.9? It would be also great if you can attach simple maven project so we can quickly reproduce the issue. Thanks. WBR, Alexey. On 01/14/2013 01:48 PM, [hidden email] wrote: > Hi, > > I have successfully integrated Grizzly2.1.9 with Jersey and Spring. But > could not make it work when trying to migrate Grizzly to version > 2.2.19. > > The original code with Grizzly2.1.9 is as below. > > HttpServer server = new HttpServer(); > NetworkListener listener = new NetworkListener("grizzly2", "localhost", > 3388); > server.addListener(listener); > > ServletHandler sa = new ServletHandler(); > sa.setContextPath("/"); > sa.setServletInstance(new SpringServlet()); > sa.addContextParameter("contextConfigLocation", > "classpath:spring-context.xml"); > sa.addServletListener("org.springframework.web.context.ContextLoaderLis > tener"); > sa.addServletListener("org.springframework.web.context.request.RequestC > ontextListener"); > > ServerConfiguration config = server.getServerConfiguration(); > config.addHttpHandler(sa, new String[] {"/"}); > server.start(); > > And the new code with Grizzly2.2.19 is as below > > HttpServer server = new HttpServer(); > NetworkListener listener = new NetworkListener("grizzly2", "localhost", > 3388); > WebappContext ctx = new WebappContext("ctx","/"); > final ServletRegistration reg = ctx.addServlet("spring", new > SpringServlet()); > reg.addMapping("/"); > ctx.addContextInitParameter("contextConfigLocation", > "classpath:spring-context.xml"); > ctx.addListener("org.springframework.web.context.ContextLoaderListener" > ); > ctx.addListener("org.springframework.web.context.request.RequestContext > Listener"); > ctx.deploy(server); > server.start(); > > The new code could be compiled and executed with no exception. However > all urls which should be forwarded to different methods by Jersey are > now all forwarded to the default page "/". > > I want to know what I miss with the new code. > > Thanks so much! |
|
Hi, Thanks for the amazing fast response. Here are two attachments within two maven projects. g2.1js.7z is with Grizzly 2.1.9
And g2.2js.7z is with Grizzly 2.2.19 You can try localhost:3388, localhost:3388/test, localhost:3388/test2 with each project and can see the difference. Best, Willy 2013/1/14 Oleksiy Stashok <[hidden email]> Hi, |
|
Administrator
|
Hi Willy,
looks like there is a small mapping issue, but you can workaround it for now like this: public static void main(String[] args) throws IOException { HttpServer server = new HttpServer(); NetworkListener listener = new NetworkListener("grizzly2", "localhost", 3388); server.addListener(listener); WebappContext ctx = new WebappContext("ctx", ""); final ServletRegistration reg = ctx.addServlet("spring", new SpringServlet()); reg.addMapping("/*"); ctx.addContextInitParameter("contextConfigLocation", "classpath:spring-context.xml"); ctx.addListener("org.springframework.web.context.ContextLoaderListener"); ctx.addListener("org.springframework.web.context.request.RequestContextListener"); ctx.deploy(server); server.start(); System.in.read(); } The first change is a temporary workaround, theoretically WebappContext("ctx", "/') has to work as well. Will appreciate if you can file an issue in grizzly and attach 2 usecases there. The second change is a proper fix for your usecase. Thanks. WBR, Alexey. On 01/14/2013 02:12 PM, Willy Hung
wrote:
|
|
Hi Oleksiy,
Thanks for your help. The workaround works well ! And I have filed this issue. Thanks, Willy 2013/1/14 Oleksiy Stashok <[hidden email]>
|
| Powered by Nabble | Edit this page |
