小编Jam*_*s.Y的帖子

注入上下文HttpServletRequest导致"接口org.glassfish.hk2.api.ProxyCtl在类加载器中不可见"(jersey 2.21,weblogic 12.1.3)

我在weblogic 12c(12.1.3)上使用jersey 2.21来提供Rest.Rest类工作正常,无需注入上下文HTTPServeletRequest/HTTPServletResponse.但是一旦注入上下文,它会在调用服务时抛出"接口org.glassfish.hk2.api.ProxyCtl在类加载器中不可见"错误.

这是班级:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Path("test")
public class TestResource {
Logger logger = LoggerFactory.getLogger(TestResource.class);


@Context HttpServletResponse resp; 
@Context HttpServletRequest request; 


/**
 * Test site connectivity. Return parameter txt's content in reply
 * @param content
 * @return 
 */
@GET
@Path("/tryMe")
@Produces(MediaType.TEXT_PLAIN)
public String echoTest(@QueryParam("txt") String content) { 
    System.out.println("Try me reach.");
    System.out.println("from client: "+request.getRemoteAddr()); 


    return content;
}

}
Run Code Online (Sandbox Code Playgroud)

如果注释掉这两个上下文,则在调用tryMe Restful时没有错误. …

java weblogic12c jersey-2.0

6
推荐指数
1
解决办法
2575
查看次数

标签 统计

java ×1

jersey-2.0 ×1

weblogic12c ×1