Java EE servlet 错误 - 重复 URL 模式

Java EE servlet error - duplicate URL pattern

我正在为我的一项任务制作原型银行应用程序。我已成功创建持久性 API、EJB 和所有必需的表。但是,当我为我的应用程序创建 WebClient 并将其与企业应用程序集成并尝试 运行 它时,我收到以下错误:

java.lang.IllegalArgumentException: Servlet [RegistrationPortImpl] and Servlet [RegistrationRequesterPortImpl] have the same url pattern

WebClient 只有默认的 index.xhtml 文件,我还没有用它集成到托管 beans。

我只是想检查我的应用程序在与企业应用程序集成后是否会 运行,然后再进行任何改进。

@WebServlet 中放置一个唯一的 url 路径,例如 @WebServlet("/port") @WebServlet("/requestport")

像这样注释您的每个 servlet,然后我相信这个问题不会发生。

您可以像这样在 web-app 标签中添加条目 metadata-complete=true

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  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_3_0.xsd"
  version="3.0"
  metadata-complete="true">

这个 post 暗示了类似的东西。 此条目在 /WEB-INF/lib 中禁用了对 Servlet 3.0 特定注释和 Web 片段的扫描。参见 here, here and here

也许您可以检查 web.xml 中的 URL 模式以及您的应用使用的库。