2013-01-14 2 views
5

Grizzly v2.1.9JerseySpring으로 성공적으로 통합했습니다. 그러나 Grizzly2.2.19으로 마이그레이션하려고 할 때 작동하지 않을 수 있습니다.통합 저지와 스프링이있는 Grizzly2.2.X

Grizzly v2.1.9의 원본 코드는 다음과 같습니다.

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

그리고 Grizzly v2.2.19 갖는 새로운 코드

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

새로운 코드 아래와 같다 컴파일 않고, 예외로 실행될 수있다. 그러나 Jersey에 의해 다른 방법으로 전달되어야하는 모든 URL은 이제 모두 기본 페이지 "/"로 전달됩니다. 같은 문제를 충족하는 사람을

UPDATE

. Grizzly2.2.20

답변

3

마지막으로 내가 java.net에 이메일을 보낸 후 해결 방법을 얻을 후

그것은 고정됩니다.

변경

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

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

에 더 자세히이 link을 따를 수 있습니다.