1

我正在尝试访问托管在 Tomcat 6 服务器上的 Web 服务。当我在浏览器中输入 wsdl url 时,系统会提示我输入凭据。

我收到一个弹出窗口来输入用户名和密码。

A user name and password are being requested by http://localhost:8080. The site says: MyApplicationName

我提供了我的应用程序登录详细信息。但它一次又一次地提示着我。当我单击取消时,我收到 401 未经授权的异常。

tomcat-users.xml

   <?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
   <user name="admin" password="" roles="manager"/>
</tomcat-users>

server.xml有一些细节如下

<Server port="8205" shutdown="SHUTDOWN" debug="2">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <Service name="Catalina" debug="2">

    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" 
               scheme="http"
               secure="false"
               SSLEnabled="false"
               debug="2"
               emptySessionPath="true"
               URIEncoding="UTF-8" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost"
         debug="2">

      <Realm className="org.apache.catalina.realm.MemoryRealm"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false"
            debug="2">

             <Context path="" docBase="C:\mypath\app.war" debug="2"></Context>        

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>

      </Host>
    </Engine>
  </Service>
</Server>

Web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">


    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>


    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>

</web-app>

有人可以告诉我如何删除此弹出窗口或我需要输入什么用户名和密码。它是我的应用程序特定的还是 tomcat 特定的?

4

2 回答 2

3

我也面临同样的问题。经过数小时的故障排除并尝试了此线程和其他类似线程中提到的所有可能的解决方案,我无法解决问题。然后我可以确定我突然开始面临这个问题,因为我最近在我的机器上安装了 Oracle,它使用了相同的端口 8080。我已经更改了 server.xml 文件中的端口号,现在工作正常..

以下是更改的片段:

 <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
于 2014-07-24T18:48:10.197 回答
0

尝试将以下内容放在服务标记上方的最后一个侦听器标记下方:

<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
          type="org.apache.catalina.UserDatabase"
          description="User database that can be updated and saved"
          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

然后在下面

<Engine name="Catalina" defaultHost="localhost"
     debug="2">

添加:

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

确保将 UserDatabase 资源中的路径名更改为 tomcat-users.xml 文件的正确路径。您需要重新启动 tomcat 才能使更改生效。

于 2013-01-23T13:57:40.370 回答