繁体   English   中英

为什么不能将WebServiceContext注入到Jax-WS逻辑处理程序中

[英]Why can't I inject a WebServiceContext into a Jax-WS logical Handler

我有一个用于Web服务的逻辑处理程序,我需要访问Servlet的上下文(我在考虑通过Web服务上下文)。

package test;

public class NewLogicalHandler implements LogicalHandler<LogicalMessageContext> {

   @Resource
   private WebServiceContext context; 

部署时发生错误:

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

如果我正确地注入Web服务:

@WebService(..stuff...)
@HandlerChain(file = "handler.xml")
public class ws1 {

   @Resource
   private WebServiceContext context;      

很好

没关系。 可以从LogicalMessageContext.get(MessageContext.SERVLET_CONTEXT);获取servlet上下文。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM