2016-03-25 23 views
0

Başka bir JBoss sunucusu altında bir JBoss sunucusu ve bir istemci altında çalışan bir EJB vatansızlığına sahibim. istemci tarafında context.lookup (...) dökümünü döndürme nesnesini ejb3 uzak nesne arabirimine döndürdü

, ben aşağıdaki kodu kullanıyorum:

org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to my.ejb.remote.MyEjbRemoteInterface 

Bu bağımlılıklar istemci tarafında sınıf yolunda şunlardır: Bu kodu çalışırken

final Properties initialContextProperties = new Properties(); 
initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
initialContextProperties.put(Context.PROVIDER_URL, "remote://127.0.0.1:8083"); 
initialContextProperties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); 
initialContextProperties.put("jboss.naming.client.ejb.context", true); 

final InitialContext contexte = new InitialContext(initialContextProperties); 
Object remoteObj = contexte.lookup("ejb:my-web-app/MyEjbRemoteImpl!my.ejb.remote.MyEjbRemoteInterface"); 
MyEjbRemoteInterface myEjb = (my.ejb.remote.MyEjbRemoteInterface) remoteObj; 

, bu istisna var :

<dependency> 
    <groupId>org.jboss</groupId> 
    <artifactId>jboss-remote-naming</artifactId> 
    <version>2.0.4.Final</version> 
</dependency> 
<dependency> 
    <groupId>org.jboss.xnio</groupId> 
    <artifactId>xnio-nio</artifactId> 
    <version>3.3.6.Final</version> 
</dependency> 

bir fikrin var mı? Yardımlarınız

+0

[uzaktan erişilebilir Jndi nesnelerin Ön koşul] (https://docs.jboss.org/author/display/AS72/ JBoss'un belgelerinin uzaktan + EJB + çağrıları + + JNDI + - + EJB + istemci + API + veya + uzaktan adlandırma + projesi), uzaktan adlandırma projesini kullanırken kullanılan JNDI adları her zaman ** java'ya göre: jboss/exported/** namespace *. Bu nedenle, 'ejb:' arama dizinizden kaldırmalısınız. – aribeiro

cevap

0

sorun için

sayesinde arama yöntemi dize parametresinde oldu. Olması gereken: ejb:/my-web-app//MyEjbRemoteImpl!my.ejb.remote.MyEjbRemoteInterface. Genellikle ejb:AppName/EjbModuleName/DistinctName/EjbRemoteBeanImpName!ejb.remote.interface.Name

Ve tüm gerekli bağımlılıkları gibi: bölümündeki belirtildiği gibi

<dependency> 
     <groupId>org.jboss.as</groupId> 
     <artifactId>jboss-as-ejb-client-bom</artifactId> 
     <version>7.2.0.Final</version> 
     <type>pom</type> 
    </dependency> 
İlgili konular