2016-03-31 25 views
0

Arka plan: EJB'leri kullanan eski bir uygulamayı miras alıyorum. Projenin yüzünde 3.0 EJB olarak listeleniyor. EJB, WebSphere 6.1'i çalıştırırken yazılmıştır. Burada iki jvms, biri UI/Sunu Katmanı ve JPJ kullanan EJB/"veri katmanı" nı barındıran ikinci bir JVM vardı. Biz WebSphere Liberty 8.5.5.8 taşınıyorlar ve Başvurumu ve erişime o başlattığınızda, ben şu istisna olsun: verilen dize jndiName: İşte WebSphere Liberty'de EJB'yi Bağlama Hatası Hatası 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) 

bağlam nesnesi erişen koddur eksikliktir: "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; 
} 

Biz iki ambalajlı KULAK dosyaları çoğunu içerir CHNew.war adlı bir .WAR içerir (CHNew.ear) olarak adlandırılan Kulak dosya A ön uç mantığı ve dağıtım derlemesinde CHService.jar dosyası başvuruyor. (CHService.ear) adlı B adlı dosya, CHService.war adında bir savaş projesinde EJB kodunu barındırır. Her ikisi de aynı uygulama sunucusunda ve dolayısıyla aynı jvm'de bulunurlar fakat aynı kulak dosyasında açık bir şekilde paketlenmezler.

<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> 

DÜZENLEME:

<?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> 

* vardır: İşte ibm-web bnx.xml dosyasının içeriği olan

Kulak A aşağıdaki web.xml pasajı vardır Geçmişte göz ardı edildiğine inandığım .xmi (not not .xml) dosyaları Kulak App B İçeride

şu dörtlük içeren bir ibm-ejb-kavanoz-bnd.xml dosyasıdır:

<!-- 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> 
: Burada

<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> 

benim Liberty server.xml dosyasıdır

Sorular:

  1. Bu EJB'yi bağlamak için başka ne yapmam gerekir?
  2. ben java kullanarak denedi: (aynı EJB Applcation olarak) iki EJB'ler başvurmak için genel ad aşağıdaki Jndi adlarla (JNDI adlandırma istisnalar attı tümü):
    1. java: Küresel/CHServiceEAR/CHService
    2. java /CHServiceBean!com.xxx.xxx.service.CHSerivceBean: küresel/CHServiceEAR/CHService/CHServiceBean
Sen ibm-ejb-kavanoz-bnd.xml gösterdik
+0

EAR'lerinizi dağıttığınızda, Websphere JNDI bağlamlarını sunucu konsoluna veya günlük dosyasına yazdırmıyor mu? – aribeiro

+0

Liberty'de bir geliştirme alanında yaşıyorum, aslında kulakları (veya Uygulamaları Ekle/Kaldır) kullanın ve Liberty bunları yükler. Görebildiğim kadarıyla isim kaydını bir kütüğe dökmüyor. Doug

cevap

1

ama size ibm-web-bnd.xml dosyasını CHNew.war'dan göstermeniz gerekir. Hata mesajı şöyle bir şey yapılandırılmış bağlayıcı olması öneriyor:

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

... ya böyle bir şey ibm-web BND kullanıyorsanız.xmi:

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

The Liberty profil yalnızca java: ad ve asla (com.xxx.xxx.service.CHServiceRemote gibi isimler bulunuyor) varsayılan ad alanına EJB'ler bağlayan, bu nedenle bu arama her zaman başarısız olur. Bilgi Merkezi'nde Using enterprise JavaBeans with remote interfaces on Liberty konusunun "Adlandırma" bölümüne bakın. Bağlama adını java:global/CHService/CHService/CHServiceBean gibi bir şeye güncellemeniz gerekir. Kullanılacak tam dize için messages.log dosyasındaki CNTR0167I mesajına bakın.

+0

Merhaba Brett, ibm-web-bnd.xml dosyasının içeriğini ekledim. Java: global namespace'i kullanmak için ibm-web-bnd.xml dosyasını güncellemem gerektiğini mi söylüyorsun, örneğin: ? – Doug

+0

@Doug Peki, ibm-web-bnd.xmi (.xml değil) kullandığınız için, 'jndiName = "java: global/CHService/CHService/CHServiceBean" 'ya da Messages.log içinde CNTR0167I mesajı, ama evet, 'java: global' kullanmak için bağlama adını güncellemeniz gerekiyor. Ben de temelde aynı şeyi yazdığım Bilgi Merkezine bir bağlantı vermek için cevabı güncelledim. (FYI, ibm-web-bnd.xmi snippet'indeki arayüz adını gizlemeyi unutmuştunuz.) –

+0

tüm bilgiler yardımcı oldu. İletileri "CNTR0167I" başlığı altındaki messages.log dosyasında izledikten sonra bağlayıcı isimleri buldum. Bunları ibm-web-bnd.xmi dosyasına ekledim ve bir ibm-web-bnd.xml dosyası oluşturdum ve jndi adına işaret eden etiketini ekledim. Yeniden başlattıktan sonra artık yukarıdaki hatayı göremiyorum. Kalıcılık hizmetiyle ilgili yeni bir hata alıyorum ancak orijinal sorun çözülüyor. Yardım ettiğin için teşekkür ederim! – Doug