2 Replies Latest reply on May 3, 2012 1:46 PM by João Marques

    Custom 401 Error on Webservices (JBoss)

    João Marques Newbie



      I have a jboss webservice like this:


      @WebContext(urlPattern = "/*", authMethod = "BASIC", secureWSDLAccess = true)
      @EndpointConfig(configName = "Standard WSSecurity Endpoint")
      @WebService(name = "WebServiceName", targetNamespace = "http://webserviceName")

      public class WebserviceName (...)



      When i invoke this webservice with wrong credentials i´m getting the following error:


      <title>JBoss Web/2.1.3.GA - Error report</title>
      <!--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;}
      {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;}
      {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>JBoss Web/2.1.3.GA</h3>


      I would like to know if there is way to custom this 401 response?

      Notice that my webservice works fine (my problem is only in this customization).

      I already try, unsucessefully,  to put the following code on web.xml (in several modules like jbossws.sar) (and login-config.xml)





      Also, i´ve try the following:






      Thanks a lot.

        • 1. Re: Custom 401 Error on Webservices (JBoss)
          João Marques Newbie

          I found something very similar of what i pretend in this link : https://community.jboss.org/thread/80628?tstart=0 ... but this doesn't work on JBoss (Native) webservices.. I just want remove the version (JBoss Web/2.1.3.GA)

          • 2. Re: Custom 401 Error on Webservices (JBoss)
            João Marques Newbie

            The Webservice use the JBoss Web component to authenticate the username and password (with Basic Authentication). (Note that i'm using JBoss-ESB)


            For this motive, we need to change this jar (jbossweb.jar) in \jboss-esb\server\<server-name>\deploy\jbossweb.sar.


            We must edit the file "ServerInfo.properties" (in org\apache\catalina\util\) and change the property "server.info=2.1.3.GA" to "server.info=XPTO".


            Alternatively, it´s also possible to re-build this jar and replace the tag @VERSION@ to XPTO (in the task Ant, i believe).


            During this analysis, was also identified the possible implementation of our BasicAuthenticator. Thus it is possible to configure the error message (401) so as to make it more configurable (ultimately we can return other error).


            To do this, you must change the configuration



                <property name="authenticators">



                <value> MyClass </value>



            in file war-deployers-jboss-beans.xml (in \jboss-esb\server\<server-name>\deployers\jbossweb.deployer\META-INF).