You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Servlet重复URL模式报错求助:RegistrationRequesterPortImpl与RegistrationPortImpl冲突

解决GlassFish中Servlet URL模式重复冲突的问题

问题根源

你碰到的这个IllegalArgumentException是典型的Web服务部署冲突——两个Servlet类RegistrationRequesterPortImpl和RegistrationPortImpl被配置了完全相同的URL模式/RegistrationService_V11,GlassFish容器要求每个URL模式只能绑定到唯一的Servlet,所以直接抛出了这个错误。

完整报错信息

Caused by: java.lang.IllegalArgumentException: Servlet [RegistrationRequesterPortImpl] 和 Servlet [RegistrationPortImpl] 具有相同的URL模式:[/RegistrationService_V11]

调用栈详情

at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addWebComponentDescriptor(WebBundleDescriptorImpl.java:396)
at org.glassfish.webservices.connector.annotation.handlers.WebServiceHandler.processAnnotation(WebServiceHandler.java:473)
at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:174)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:350)
... 59 more

具体解决办法

给你几个实用的解决方向,按需选择:

  • 修改其中一个Servlet的URL映射:找到这两个类对应的配置(要么是类上的@WebService/@WebServlet注解,要么是web.xml里的<servlet-mapping>节点),把其中一个的URL模式改成唯一值,比如把RegistrationRequesterPortImpl的映射改成/RegistrationService_V11_Requester就行。
  • 清理重复生成的Port类:如果这两个类是通过wsimport这类Web服务工具自动生成的,很大概率是重复生成了相同服务的Port实现。建议先清理项目的生成目录(比如target/generated-sources),然后重新生成一次。
  • 排查重复的配置项:仔细核对两个Servlet类上的注解,确认有没有不小心给它们设置了相同的urlPatterns属性;如果是用web.xml配置的,也要检查是否存在重复的<url-pattern>条目指向同一个URL。

内容的提问来源于stack exchange,提问作者lakhder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:45:14