[英]Why can't I inject a WebServiceContext into a Jax-WS logical Handler
I have this logical handler for a web service that I need to get access to the servlet's context (via the web service context, I am thinking). 我有一个用于Web服务的逻辑处理程序,我需要访问Servlet的上下文(我在考虑通过Web服务上下文)。
package test;
public class NewLogicalHandler implements LogicalHandler<LogicalMessageContext> {
@Resource
private WebServiceContext context;
Error when I deploy: 部署时发生错误:
<Servlet: "test.ws1" failed to preload on startup in Web application: "web".
java.lang.ClassNotFoundException: test.NewLogicalHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
If I inject into the web service proper: 如果我正确地注入Web服务:
@WebService(..stuff...)
@HandlerChain(file = "handler.xml")
public class ws1 {
@Resource
private WebServiceContext context;
That works fine. 很好
Never mind. 没关系。 Can get servlet context from LogicalMessageContext.get(MessageContext.SERVLET_CONTEXT);
可以从LogicalMessageContext.get(MessageContext.SERVLET_CONTEXT);获取servlet上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.