0 Replies Latest reply on May 18, 2007 6:27 AM by Tremal Naik

    Error 401 and server redirection

    Tremal Naik Newbie

      Hello, I have a problem with my Jax-Rpc style WS: A client is accessing a remote server using the following code:

      // setting up the authenticator (BasicAuthenticator extends java.net.Authenticator)
      BasicAuthenticator ba = new BasicAuthenticator(username, password);
      Authenticator.setDefault(ba);
      // setting a relaxed host verifier (to avoid too strict the server name checking)
      HttpsURLConnection.setDefaultHostnameVerifier(new NiceVerifier());
      // get service
      String urlstr = "https://cor319.cor-fs.com:8443/bitatraveller/TravellerSynchronizer";
      URL url = new URL(urlstr);
      String ns = "https://ws.web.bitastar.bitaplus.com/";
      QName qname = new QName(ns, "TravellerSynchronizer");
      QName port = new QName(ns, "TravellerSynchronizerIfacePort");
      QName operation = new QName(ns, "synchronize");
      ServiceFactoryImpl sfi = new ServiceFactoryImpl();
      // read mapping file
      File mapping = new File("mapping.xml");
      Service service = sfi.createService(url, qname, mapping.toURL());
      // call service
      Call call = service.createCall(port, operation);
      ClientCharacteristics cc = (ClientCharacteristics) call.invoke(new Object[] { characters });


      I receive the error 401 and the client keep going on trying many times. Tomcat Axis Tcpmon gives the following output:

      GET /bitatraveller/TravellerSynchronizer?wsdl HTTP/1.1
      User-Agent: Java/1.5.0_09
      Host: 127.0.0.1:9999
      Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
      Connection: keep-alive
      Content-type: application/x-www-form-urlencoded
      
      HTTP/1.1 401 Unauthorized
      Server: Apache-Coyote/1.1
      Pragma: No-cache
      Cache-Control: no-cache
      Expires: Thu, 01 Jan 1970 01:00:00 GMT
      WWW-Authenticate: Basic realm="127.0.0.1:9999"
      Content-Type: text/html;charset=utf-8
      Content-Length: 952
      Date: Fri, 18 May 2007 09:45:39 GMT
      
      <html><head><title>Apache Tomcat/5.5.9 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.9</h3></body></html>


      Well, everything is working fine, except when the password issued by the client is wrong.

      All I see in my application output, after 20 repetitions of the above request/response:

      2007-05-18 10:06:43,878 [http-8443-Processor23] ERROR [ROM] [_system_] com.bitaplus.bitastar.common.exception.InvalidPasswordException: Invalid password or username.
       at com.bitaplus.bitastar.traveller.util.FileUserHelper.validateLogin(FileUserHelper.java:73)
       at com.bitaplus.bitastar.traveller.security.auth.tomcat.TomcatXmlDbLoginModule.validate(TomcatXmlDbLoginModule.java:27)
       at com.bitaplus.bitastar.common.security.auth.tomcat.TomcatLoginModule.login(TomcatLoginModule.java:122)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at javax.security.auth.login.LoginContext.invoke(Unknown Source)
       at javax.security.auth.login.LoginContext.access$000(Unknown Source)
       at javax.security.auth.login.LoginContext$4.run(Unknown Source)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext.invokePriv(Unknown Source)
       at javax.security.auth.login.LoginContext.login(Unknown Source)
       at org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:365)
       at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:257)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:416)
       at com.bitaplus.bitastar.web.valve.TomcatFixValve.invoke(TomcatFixValve.java:181)
       at com.bitaplus.bitastar.web.valve.LicenseRequirementsValve.invoke(LicenseRequirementsValve.java:408)
       at com.bitaplus.bitastar.web.valve.LoginErrorMessageValve.invoke(LoginErrorMessageValve.java:35)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Unknown Source)
      


      I wonder how can I catch the HTTP errors sent by the remote server and avoid the client repeat many times the request?

      I've looked for the answer in the documentation, but I was not able to find it. Sorry

      Your help would be appreciated