Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8581507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:04:07+00:00 2026-06-11T21:04:07+00:00

I have an extension of this question . I have that exact code running

  • 0

I have an extension of this question. I have that exact code running on a Jetty Server, and other SOAP web services work perfectly. However, on this line:

HttpServletRequest req = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST); 
System.out.println("Client IP = " + req.getRemoteAddr()); 

The server crashes with a null pointer exception. mc.get(MessageContext.SERVLET_REQUEST) is returning null.

By comparison, mc.get(MessageContext.HTTP_REQUEST_METHOD) returns “POST”, so I assume that’s working.

What can I do to fix this?

EDIT:
I’ve tried this fix to no avail.

I’ve also tried using the @Context annotation instead and got the same issue.

A System.out.println(mc) yields this:

{javax.xml.ws.wsdl.port={http://my.test.namespace.com/}testWSDLPort,
 javax.xml.ws.soap.http.soapaction.uri="", 
 com.sun.xml.internal.ws.server.OneWayOperation=null, 
 javax.xml.ws.http.request.pathinfo=null, 
 ...
 ...

and so on, and the list of values does NOT include javax.xml.ws.servlet.request, which is the value of MessageContext.SERVLET_REQUEST. What do I need to do to make sure the MessageContext has this value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:04:08+00:00Added an answer on June 11, 2026 at 9:04 pm

    Currently the Jetty HTTP SPI JAX-WS implementation doesn’t appear to properly inject the MessageContext into a web service. Try switching to Apache CXF instead. Once you have

    1. cxf-2.6.2.jar
    2. neethi-3.0.2.jar
    3. xmlschema-core-2.0.3.jar

    on your project build path, you have to create a servlet class that extends the CXFNonSpringServlet and overrides the loadBus function like so:

    public class SOAPServlet extends CXFNonSpringServlet {
    
        private static final long serialVersionUID = 1L;
        private Map<String, Object> endpoints;
    
    
        public SOAPServlet(){
            endpoints = new HashMap<String, Object>();
        }
    
        @Override
        public void loadBus(ServletConfig servletConfig) {
            super.loadBus(servletConfig);        
    
            // You could add the endpoint publish codes here
            Bus bus = getBus();
            BusFactory.setDefaultBus(bus);
            Set s = endpoints.entrySet();
            Iterator p = s.iterator();
            while(p.hasNext()){
                Map.Entry m = (Map.Entry)p.next();
                String address = (String)m.getKey();
                Object impl = (Object)m.getValue();
                System.out.println("Publishing " + address);
                Endpoint.publish(address, impl);
            }
        }
        public void publish(String address, Object impl){
            endpoints.put(address, impl);
        }
    }
    

    And then where you are configuring your server, add these lines:

        Server server = new Server(8080);
    
        // Configure SOAP servlet
        SOAPServlet servlet = new SOAPServlet();
        ServletHolder SOAPServletHolder = new ServletHolder(servlet);
    
        ServletContextHandler SOAPContext = new ServletContextHandler(server,"/",ServletContextHandler.SESSIONS);
        SOAPContext.addServlet(SOAPServletHolder, "/*");
    
        // Set server context handlers
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler []{SOAPContext});
        server.setHandler(contexts);
    
        // Publish SOAP Web service endpoints
        servlet.publish("/MyWebServiceRelativeURL", new MyWebServiceImpl());
    
        server.start();
        server.join();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that's somewhat of an extension of this thread . I
This is an extension of this question . I have searched on the web
This is an extension of the question I asked here I have a relationship
I have a chrome extension which have a server-side javascript and I need this
Update: This does work, I was being stupid :( i have the following extension
I have an extension to this question: Vb6 "Tag" property equivalent in ASP.Net? The
This question is an extension of this question . It is good that I
This is a question that is an extension of my previous Free 3 of
We have a small project that involves automatically parsing some server/mail logs (among other
this question is an extension of my previous question that you can find here:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.