2013-01-14 23 views
5

Z powodzeniem zintegrowałem Grizzly v2.1.9 z Jersey i Spring. Ale nie można go uruchomić podczas próby przeniesienia Grizzly do wersji 2.2.19.Integracja Grizzly2.2.X z Jersey i wiosną

Oryginalny kod z Grizzly v2.1.9 jest jak poniżej.

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.ContextLoaderListener"); 
sa.addServletListener("org.springframework.web.context.request.RequestContextListener");     

ServerConfiguration config = server.getServerConfiguration(); 
config.addHttpHandler(sa, new String[] {"/"}); 
server.start(); 

A nowy kod z Grizzly v2.2.19 jest poniżej

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.RequestContextListener"); 
ctx.deploy(server); 
server.start(); 

Nowy kod może być kompilowany i wykonywany bez wyjątku. Jednak wszystkie adresy URL, które powinny zostać przekazane do różnych metod przez Jersey, są teraz przekierowywane na domyślną stronę "/".

UPDATE

Dla kogoś, kto spotyka ten sam problem.

To jest ustalona po Grizzly2.2.20

Odpowiedz

3

Wreszcie mam obejście po wysłaniu e-maila do java.net.

Zmień

WebappContext ctx = new WebappContext("ctx","/"); 

do

WebappContext ctx = new WebappContext("ctx",""); 

może obserwować tą link więcej szczegółów.