簡體   English   中英

嘗試在WebSphere Liberty 8.5.5.8中綁定EJB時出錯

[英]Error Attempting to Bind EJB in WebSphere Liberty 8.5.5.8

背景:我正在繼承一個利用EJB的古老應用程序。 在項目的方面,它列為3.0 EJB。 EJB是在運行WebSphere 6.1時編寫的,其中我們有兩個jvm,一個用於UI /表示層,另一個用於托管EJB /“數據層”(也使用JPA)的JVM。 我們正在轉向WebSphere Liberty 8.5.5.8,當我啟動應用程序並訪問它時,出現以下異常:

....
Caused by: 
com.ibm.wsspi.injectionengine.InjectionException: CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/ejb/CHServiceBean reference.  The exception message was: CWNEN1003E: The server was unable to find the com.xxx.xxx.service.CHServiceRemote binding with the com.xxx.xxx.service.CHService type for the java:comp/env/ejb/CHServiceBean reference.
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1458)
    at com.ibm.ws.ejb.injection.processor.EJBInjectionBinding.getInjectionObject(EJBInjectionBinding.java:1047)
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1389)
    at com.ibm.ws.injectionengine.osgi.internal.naming.InjectionJavaColonHelper.getObjectInstance(InjectionJavaColonHelper.java:116)
    ... 44 more
Caused by: 
com.ibm.wsspi.injectionengine.InjectionException: CWNEN1003E: The server was unable to find the com.xxx.xxxx.service.CHServiceRemote binding with the com.xxx.xxxxx.service.CHService type for the java:comp/env/ejb/CHServiceBean reference.
    at com.ibm.ws.injectionengine.osgi.internal.IndirectJndiLookupObjectFactory.getObjectInstance(IndirectJndiLookupObjectFactory.java:202)

這是訪問上下文對象的代碼:失敗的提供的String jndiName是:“ java:comp / env / ejb / CHServiceBean”

public Object getResource(String jndiName) throws Exception {
    Object obj = null;
    if (obj == null) {
        try {
            obj = new InitialContext().lookup(jndiName);
            return obj;
        } catch (Exception e) {
            XXXXXX.error("ServiceLocator.getResource(...) ERROR, "");
            throw e;
        }
    }
    return obj;
}

我們有兩個打包的EAR文件,一個稱為(CHNew.ear)的Ear文件A,其中包含一個名為CHNew.war的.war,其中包含大多數前端邏輯,並且在部署程序集中引用了CHService.jar文件。 名為(CHService.ear)的Ear文件B在名為CHService.war的war項目中包含EJB代碼。 它們都位於相同的應用程序服務器上,因此位於相同的jvm,但顯然沒有打包在相同的ear文件中。

耳朵A具有以下web.xml代碼段:

<ejb-ref id="EjbRef_1430884948507">
  <description>
  </description>
  <ejb-ref-name>ejb/CHServiceBean</ejb-ref-name>
  <ejb-ref-type>Session</ejb-ref-type>
  <home>com.xxx.xxx.service.CHService</home>
  <remote>com.xxx.xxx.service.CHServiceRemote</remote>
</ejb-ref>
<ejb-ref id="EjbRef_1430885115133">
  <ejb-ref-name>ejb/CHServiceBeanRO</ejb-ref-name>
  <ejb-ref-type>Session</ejb-ref-type>
  <home>com.xxx.xxxx.service.CHServiceRO</home>
  <remote>com.xxx.xxx.service.CHServiceRemoteRO</remote>
</ejb-ref>

編輯:這是ibm-web-bnx.xml文件的內容:

<?xml version="1.0" encoding="UTF-8"?>
<webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1430419801447" virtualHostName="default_host">
  <webapp href="WEB-INF/web.xml#WebApp_ID"/>
  <resRefBindings xmi:id="ResourceRefBinding_1430749102271" jndiName="services/cache/CHContacts">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1430749102271"/>
  </resRefBindings>
  <resRefBindings xmi:id="ResourceRefBinding_1436377001246" jndiName="jdbc/nextgen">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1436377001246"/>
  </resRefBindings>
  <resRefBindings xmi:id="ResourceRefBinding_1436377001247" jndiName="jdbc/nextgen_RO">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1436377001247"/>
  </resRefBindings>
  <resRefBindings xmi:id="ResourceRefBinding_1456409466488" jndiName="services/cache/CHGeneric">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1456409466488"/>
  </resRefBindings>
  <ejbRefBindings xmi:id="EjbRefBinding_1430884948507" jndiName="com.xxx.xxx.service.CHServiceRemote">
    <bindingEjbRef href="WEB-INF/web.xml#EjbRef_1430884948507"/>
  </ejbRefBindings>
  <ejbRefBindings xmi:id="EjbRefBinding_1430885115133" jndiName="com.xxx.xxx.service.CHServiceRemoteRO">
    <bindingEjbRef href="WEB-INF/web.xml#EjbRef_1430885115133"/>
  </ejbRefBindings>
</webappbnd:WebAppBinding>

*過去有綁定的.xmi(注意不是.xml)文件,我認為這些文件會被忽略嗎?

在Ear App B中,有一個ibm-ejb-jar-bnd.xml文件,其中包含以下節:

<session name="CHServiceBean">
  <resource-ref name="jdbc/db" binding-name="jdbc/db"></resource-ref>
  <resource-ref name="services/cache/CacheA" binding-name="services/cache/CHBluepages"></resource-ref>
  <resource-ref name="services/cache/CacheB" binding-name="services/cache/CHGeneric" ></resource-ref>
</session>

<session name="CHServiceBeanRO">
  <resource-ref name="jdbc/db_RO"
      binding-name="jdbc/db_RO">
  </resource-ref>
  <resource-ref name="jdbc/db" binding-name="jdbc/db"></resource-ref>
  <resource-ref name="services/cache/CHGeneric" binding-name="services/cache/CHGeneric"></resource-ref>
  <resource-ref name="services/cache/CacheA" binding-name="services/cache/CacheB"></resource-ref>
</session>

這是我的Liberty server.xml文件:

<!-- Enable features -->
    <featureManager>
        <feature>javaee-7.0</feature>
        <feature>localConnector-1.0</feature>
        <feature>distributedMap-1.0</feature>
        <feature>adminCenter-1.0</feature> 
        <feature>ssl-1.0</feature>
        <feature>usr:webCacheMonitor-1.0</feature>
        <feature>webCache-1.0</feature>
        <feature>ldapRegistry-3.0</feature>
    </featureManager>

    <!--  Admin Center Config Start -->
    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>

    <keyStore id="defaultKeyStore" password="xxxxxx"/> 

    <basicRegistry id="basic"> 
          <user name="wpsadmin" password="xxxxxx"/> 
    </basicRegistry> 

    <administrator-role> 
      <user>wpsadmin</user>
    </administrator-role>

    <remoteFileAccess> 
       <writeDir>${server.config.dir}</writeDir> 
    </remoteFileAccess>

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>
    <applicationMonitor updateTrigger="mbean"/>

    <enterpriseApplication id="CHNewCHRDMEAR" location="CHNewCHRDMEAR.ear" name="CHNewCHRDMEAR">
        <application-bnd>
            <security-role name="AllAuthenticated">
                <special-subject type="ALL_AUTHENTICATED_USERS"/>
            </security-role>
        </application-bnd>
    </enterpriseApplication>
    <enterpriseApplication id="CHServiceEAR" location="CHServiceEAR.ear" name="CHServiceEAR"/>

    <!--  JAAS Authentication Alias (Global) Config -->
    <authData id="r4dba" password="{xor}MzhmJT06ajI=" user="r4dba"/>

    <!--  JDBC Driver and Datasource Config -->
    <library id="DB2JCC4Lib">
        <fileset dir="C:\DB2\Jars" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
    </library>
</server>

問題:

  1. 綁定該EJB還需要做什么?
  2. 我嘗試使用java:global命名空間來引用具有以下JNDI名稱(都拋出JNDI命名異常)的兩個EJB(在同一EJB應用程序中):
    1. java:global / CHServiceEAR / CHService / CHServiceBean!com.xxx.xxx.service.CHSerivceBean
    2. java:global / CHServiceEAR / CHService / CHServiceBean

您已經顯示了ibm-ejb-jar-bnd.xml,但是需要顯示CHNew.war中的ibm-web-bnd.xml。 該錯誤消息表明您具有如下配置的綁定:

<ejb-ref name="ejb/CHServiceBean" binding-name="com.xxx.xxx.service.CHServiceRemote">

...或者如果您使用ibm-web-bnd.xmi,則類似這樣:

  <ejbRefBindings xmi:id="EjbRefBinding_1430884948507" jndiName="com.xxx.xxx.service.CHServiceRemote">
    <bindingEjbRef href="WEB-INF/web.xml#EjbRef_1430884948507"/>
  </ejbRefBindings>

Liberty配置文件僅將EJB綁定到java:命名空間, com.xxx.xxx.service.CHServiceRemote綁定到默認命名空間(默認名稱空間包括com.xxx.xxx.service.CHServiceRemote ),因此此查找將始終失敗。 請參閱知識中心中Liberty上的“ 將企業JavaBean與遠程接口一起使用”主題的“命名”部分。 您需要將綁定名稱更新為java:global/CHService/CHService/CHServiceBean 請參閱messages.log中的CNTR0167I消息以獲取要使用的確切字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM