【问题标题】:NameAlreadyBoundException if use of @Stateless in a webservice with web.xmlNameAlreadyBoundException 如果在带有 web.xml 的 web 服务中使用 @Stateless
【发布时间】:2016-07-18 16:55:17
【问题描述】:

我正在尝试使用以下注释在 Weblogic 12c 中部署 Web 服务:

@SchemaValidation
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
@WebService(serviceName = "xxxxx",
        targetNamespace = "http://bla/BusinessServices/yyy/xxxxx/V1",
        wsdlLocation = "META-INF/wsdl/zzz/yyy/xxxxx/V1/xxxxxConcrete.wsdl",
        portName = "xxxxxPort",
        endpointInterface = "ble.businessservices.yyy.xxxxx.v1.xxxxx")
//@Transactional(value= Transactional.TransactionFlowType.SUPPORTS, version= Transactional.Version.WSAT12)
@Stateless
@SecurityPolicies(@SecurityPolicy(uri = "my_policy"))
@DeclareRoles("my-role")
@Interceptors({InterceptorClass1.class, InterceptorClass2.class, InterceptorClass3.class})
public class xxxxxV1 extends HttpServlet implements xxxxx {...}

我正在使用 web.xml 来定义 servlet 别名,并使用 weblogic.xml 文件来定义我想要使用的上下文根。

问题是,如果我留下@Stateless 注解,部署时会出现以下异常:

Target state: deploy failed on Server services_server
javax.naming.NameAlreadyBoundException: my-webservice-name-impl-1.0.0.0-SNAPSHOT.war#MyWebServiceName is already bound; remaining name 'app/wsee'
    at weblogic.deploy.api.tools.deployer.Jsr88Operation.report(Jsr88Operation.java:547)
    at weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:140)
    at weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.Deployer.run(Deployer.java:74)
    ... 15 more

另一方面,如果我删除 web.xml,我可以毫无错误地进行部署,但是我的 web 服务的 URL 当然不是我想要定义的:它使用 /portName/serviceName URL .

而且,如果我删除@Stateless 注解,我会得到所需的 URL,但 拦截器被忽略,这在逻辑上是不可接受的。

我尝试过使用 @Transactional 注释(参见上面的注释代码),但拦截器一直被忽略。

有人知道我缺少什么吗?理想情况下,我会使用 web.xml 和 @Transactional 并进入拦截器。

谢谢大家!

【问题讨论】:

    标签: web-services weblogic web-deployment weblogic12c stateless


    【解决方案1】:

    找到了一种解决方法,让一切都按需要运行:the delegation pattern

    webservice 类现在具有以下注释:

    @SchemaValidation
    @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
    @WebService(serviceName = "xxxxx",
            targetNamespace = "http://bla/BusinessServices/yyy/xxxxx/V1",
            wsdlLocation = "META-INF/wsdl/zzz/yyy/xxxxx/V1/xxxxxConcrete.wsdl",
            portName = "xxxxxPort",
            endpointInterface = "ble.businessservices.yyy.xxxxx.v1.xxxxx")
    @Transactional(value= Transactional.TransactionFlowType.SUPPORTS, version= Transactional.Version.WSAT12)
    @SecurityPolicies(@SecurityPolicy(uri = "my_policy"))
    public class xxxxxV1 extends HttpServlet implements xxxxx {...}
    

    然后我使用带有以下注释的委托类xxxxxV1Delegate

    @Stateless
    @DeclareRoles("my-role")
    @Interceptors({InterceptorClass1.class, InterceptorClass2.class, InterceptorClass3.class})
    public class xxxxxV1Delegate {...}
    

    在这个类中所有的实现都完成了(基本上是复制粘贴 webservice 类中的内容并删除@Overrides)

    webservice 类将注入一个xxxxxV1Delegate 并包含所有@Override 方法。每个方法只会调用委托类中完全相同的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-15
      • 1970-01-01
      • 2011-11-02
      • 1970-01-01
      • 2011-01-14
      • 1970-01-01
      • 2011-05-13
      相关资源
      最近更新 更多