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 8131089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:58:21+00:00 2026-06-06T08:58:21+00:00

I have two servlets that access two corresponding Axis2 web services on the same

  • 0

I have two servlets that access two corresponding Axis2 web services on the same host. One of the servlets is read-only, while the other writes to a database.

Each of the Axis2 web services uses BASIC authentication. The read-only web service uses a system account, while the write web service uses the user’s credentials (which are submitted as part of a web form).

The problem I’m running into is that the servlet called second always fails authentication to its web service. For example, I can query the read-only service through it’s servlet all I want, but I get a “401: Authorization Required” when I try to use the write service. If I call the write service first, I get the same error when I try to use the read-only service.

Here is how I am setting the credentials for the connections in the servlets:

Stub service = new Stub(serviceUrl);
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(username);
auth.setPassword(password);
auth.setPreemptiveAuthentication(true);

service._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);

The servlet that accesses the read-only service has this code in it’s constructor. The servlet that accesses the write service has this code in it’s doGet/doPost method.

It seems that the credentials for the first service called are getting cached somewhere, but I can’t find where that could be. I saw a possible solution here, but I can’t find where WSClientConstants.CACHED_HTTP_STATE is defined. The comments in this JIRA issue seems to imply that it’s part of org.apache.axis2.transport.http.HTTPConstants but it’s not there.

Specifics:

  • Axis version: 1.5.1
  • Tomcat Version: 6.0.26
  • Java version: 1.6.0_23
  • 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-06T08:58:23+00:00Added an answer on June 6, 2026 at 8:58 am

    It turns out the connections to the two different services were using the same JSESSIONID. Thus, the connection to the second web service was trying to use a session authenticated for the first web service, causing the error.

    My solution for this was to define an HttpClient for each service, done by the following

    MultiThreadedHttpConnectionManager manager = new MuliThreadedHttpConnectionManager();
    HttpClient client = new HttpClient(manager);
    
    ConfigurationContext context = ConfigurationContextFactory.createDefaultConfigurationContext();
    context.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, client);
    context.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true);
    
    Stub service = new Stub(context, serviceUrl);
    

    This allows both servlets to have a separate session for their corresponding services.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application which has two servlets that exchange information through context
I have the following urls that need mapping to two different servlets. Can anyone
I want to define two servlets in my Spring web.xml - one for the
I am developing a Java application that is to have two web interfaces: a
I have two systems I'm trying to integrate. One is built on raw servlets,
i have two view folder how can i manage a same resolver that can
I have two problems. The first one is that I'm using JSP and that
i have one login.jsp web page where i have two textboxes for username and
I am going through one web development process in which, I have two parameters
I have two JSP pages that can access a Servlet. Now, I want when

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.