2013-01-14 16 views
5

Grizzly v2.1.9 ürününü Jersey ve Spring ile başarıyla entegre ettim. Ancak, Grizzly sürümünü 2.2.19 sürümüne geçirmeye çalışırken işe yaramaz.Forma ve Yay ile Entegrasyon Grizzly2.2.X

Grizzly v2.1.9 ile özgün kod aşağıdaki gibidir.

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(); 

Ve Grizzly v2.2.19 ile yeni kod

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(); 

yeni kod aşağıda gibidir derlenmiş ve hiçbir istisna ile infaz edilebilir. Ancak, Jersey tarafından farklı yöntemlere yönlendirilmesi gereken tüm URL'ler artık tümü varsayılan sayfaya "/" yönlendirilmektedir. Aynı sorun karşılayan birisi için

GÜNCELLEME

. Grizzly2.2.20

cevap

3

Sonunda java.net bir e-posta gönderdikten sonra geçici bir çözüm aldıktan sonra

O sabittir.

Değişim

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

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

için daha fazla ayrıntı için bu link takip edebilir.