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

GlassFish部署Java Web应用失败:Servlet URL模式冲突求助

GlassFish部署Java Web应用时Servlet URL模式冲突问题

问题详情

在GlassFish 4.1上部署Java Web应用EnterpriseApplication2-war时失败,核心错误是两个WSAT相关Servlet的URL模式重复:CoordinatorPortTypePortImpl与ParticipantPortTypePortImpl均使用/WSAT10Service作为URL映射路径。

错误日志

[2024-03-07T00:59:06.795+0800] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=43 _ThreadName=admin-listener(2)] [timeMillis: 1709744346795] [levelValue: 1000] [[
Exception while deploying the app [EnterpriseApplication2-war] : Servlet [CoordinatorPortTypePortImpl] and Servlet [ParticipantPortTypePortImpl] have the same url pattern: [/WSAT10Service]. Related annotation information: annotation [@javax.jws.WebService(wsdlLocation=/wsdls/wsat10/wsat.wsdl, name=, endpointInterface=com.sun.xml.ws.tx.at.v10.types.ParticipantPortType, portName=ParticipantPortTypePort, serviceName=WSAT10Service, targetNamespace=http://schemas.xmlsoap.org/ws/2004/10/wsat)] on annotated element [class com.sun.xml.ws.tx.at.v10.endpoint.ParticipantPortTypePortImpl] of type [TYPE]
Servlet [CoordinatorPortTypePortImpl] and Servlet [ParticipantPortTypePortImpl] have the same url pattern: [/WSAT10Service]. Related annotation information: annotation [@javax.jws.WebService(wsdlLocation=/wsdls/wsat10/wsat.wsdl, name=, endpointInterface=com.sun.xml.ws.tx.at.v10.types.ParticipantPortType, portName=ParticipantPortTypePort, serviceName=WSAT10Service, targetNamespace=http://schemas.xmlsoap.org/ws/2004/10/wsat)] on annotated element [class com.sun.xml.ws.tx.at.v10.endpoint.ParticipantPortTypePortImpl] of type [TYPE]
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:373)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:381)
at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:195)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:627)
at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:463)
at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:447)
at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:338)
at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:91)
at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:421)
at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:241)
at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:161)
at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:203)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)
at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:881)
at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Servlet [CoordinatorPortTypePortImpl] and Servlet [ParticipantPortTypePortImpl] have the same url pattern: [/WSAT10Service]
at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.addWebComponentDescriptor(WebBundleDescriptorImpl.java:362)
at org.glassfish.webservices.connector.annotation.handlers.WebServiceHandler.processAnnotation(WebServiceHandler.java:461)
at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:148)
at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:350)
... 59 more
]]

解决方案

  • 清理重复依赖:检查项目依赖配置(Maven pom.xml/Gradle build.gradle),移除重复引入的WSAT相关依赖(如com.sun.xml.ws:txw2或GlassFish WS扩展包),避免Servlet被重复注册。
  • 显式区分URL模式:修改其中一个Servlet的@WebService注解,指定不同的serviceName并配合@WebServlet显式声明URL路径:
    @WebService(
        wsdlLocation = "/wsdls/wsat10/wsat.wsdl",
        endpointInterface = "com.sun.xml.ws.tx.at.v10.types.CoordinatorPortType",
        portName = "CoordinatorPortTypePort",
        serviceName = "WSAT10CoordinatorService",
        targetNamespace = "http://schemas.xmlsoap.org/ws/2004/10/wsat"
    )
    @WebServlet(urlPatterns = "/WSAT10CoordinatorService")
    public class CoordinatorPortTypePortImpl implements CoordinatorPortType {
        // 业务逻辑实现
    }
    
  • 禁用WSAT自动注册:如果应用不需要WS-Atomic Transaction功能,可在GlassFish的domain.xml中禁用WSAT模块,或在项目依赖中排除相关组件。
  • 检查部署描述符:查看web.xml文件,确认是否手动注册了这两个Servlet,确保它们的<url-pattern>配置不重复。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 08:33:14