简体   繁体   中英

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

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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