【问题标题】:JNDI lookup of web service fails in Websphere web applicationWebsphere Web 应用程序中 Web 服务的 JNDI 查找失败
【发布时间】:2014-12-10 09:36:19
【问题描述】:

我正在尝试从在 Websphere 7 上运行的 Web 应用程序中调用 SAP Web 服务。

客户端是从 WSDL 生成的,我使用 JNDI 查找来查找服务。查找失败并返回 NameNotFoundException

web.xml:

<service-ref>
    <description>
    WSDL Service ZSDWebAddressPrinting</description>
    <service-ref-name>service/ZSDWebAddressPrinting</service-ref-name>
    <service-interface>sap_com.document.sap.soap.functions.mc_style.ZSDWebAddressPrinting_Service</service-interface>
    <wsdl-file>WEB-INF/wsdl/ZSDWebAddressPrinting.wsdl</wsdl-file>
    <jaxrpc-mapping-file>WEB-INF/ZSDWebAddressPrinting_mapping.xml</jaxrpc-mapping-file>
    <service-qname xmlns:pfx="urn:sap-com:document:sap:soap:functions:mc-style">
    pfx:ZSDWebAddressPrinting</service-qname>
    <port-component-ref>
        <service-endpoint-interface>sap_com.document.sap.soap.functions.mc_style.ZSDWebAddressPrinting_PortType</service-endpoint-interface>
    </port-component-ref>
</service-ref>

JNDI 查找:

InitialContext ctx = new InitialContext();
return (Service)ctx.lookup("java:comp/env/service/ZSDWebAddressPrinting");

例外:

[10.12.14 10:24:03:645 CET] 00000024 SystemOut     O |2014-12-10 10:24:03,645|ERROR|r : 0|ws.WebServiceLocator.getService - Lookup of service reference with jndi name =  ZSDWebAddressPrinting failed !
javax.naming.NameNotFoundException: Name comp/env/service not found in context "java:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1837)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1166)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1095)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1235)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:395)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:221)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:161)
    at javax.naming.InitialContext.lookup(InitialContext.java:436)
    at com.acme.ws.WebServiceLocator.getService(WebServiceLocator.java:26)

我已使用dumpnamespace 显示所有名称,但我看不到ZSDWebAddressPrinting

还有许多 JDBC 资源也可以通过 JNDI 访问。这些在转储中可见并且工作正常。

我在这里忘记了什么吗?

【问题讨论】:

    标签: java web-services websphere jndi


    【解决方案1】:

    将类加载从 PARENT_LAST 更改为 PARENT_FIRST 有帮助。服务查找现在可以工作了。

    我不知道为什么这会对 JNDI 产生影响。 JDBC 查找在这两种情况下都有效。

    任何人都可以对此发表评论吗?

    【讨论】:

      猜你喜欢
      • 2013-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 2023-04-05
      • 2012-02-25
      相关资源
      最近更新 更多