La recherche JNDI ne renvoie que " javax.nommer.Nomnotfoundexception"


J'essaie d'implémenter un appel ejb en utilisant JNDI-naming.

Configuration:

  • JBoss-6.1.0.Finale
  • oreille-déployer:
    • gwt.guerre
    • ejb.jar

Mon problème est, bien que le JNDIView me montre l'ejb existant, je ne suis pas en mesure de l'atteindre.

Dans mon RemoteServiceServlet j'essaie d'atteindre les ejb, qui est déployé dans l'ejb.pot à l'intérieur de la même oreille-paquet.

J'ai déjà essayé plusieurs appels, car je n'étais pas sûr de le code jndi correct.

try 
{
    productLocal = (ProductLocal) context.lookup("ProductHome/local");
} 
catch (NamingException e) 
{
    System.err.println(e.getMessage());
    e.printStackTrace();
}

Également essayé:

productLocal = (ProductLocal) context.lookup("ProductLocal");
productLocal = (ProductLocal) context.lookup("sung_app_kylintv/ProductHome/local");

Le ejb apatride est assigné comme ceci:

@Stateless
@Local(ProductLocal.class)
@Remote(ProductRemote.class)
@LocalBinding(jndiBinding="ProductLocal")
@RemoteBinding(jndiBinding="ProductRemote")
public class ProductHome extends HomeBase<ProductEntity> implements SessionBean, Serializable, ProductLocal

L'initiation du contexte :

Properties p = new Properties();
p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
p.put("java.naming.provider.url","jnp://localhost:1099");

context = new InitialContext(p);

Mon JNDIView:

  +- sung_app_kylintv (class: org.jnp.interfaces.NamingContext)
  |   +- CategoryHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (class: Proxy for: sung.app.kylintv.ejbclient.product.CategoryLocal)
  |   |   +- local-sung.app.kylintv.ejbclient.product.CategoryLocal (class: Proxy for: sung.app.kylintv.ejbclient.product.CategoryLocal)
  |   |   +- remote-sung.app.kylintv.ejbclient.product.CategoryRemote (class: Proxy for: sung.app.kylintv.ejbclient.product.CategoryRemote)
  |   |   +- remote (class: Proxy for: sung.app.kylintv.ejbclient.product.CategoryRemote)
  |   +- ProductHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (class: Proxy for: sung.app.kylintv.ejbclient.product.ProductLocal)
  |   |   +- remote (class: Proxy for: sung.app.kylintv.ejbclient.product.ProductRemote)
  |   |   +- remote-sung.app.kylintv.ejbclient.product.ProductRemote (class: Proxy for: sung.app.kylintv.ejbclient.product.ProductRemote)
  |   |   +- local-sung.app.kylintv.ejbclient.product.ProductLocal (class: Proxy for: sung.app.kylintv.ejbclient.product.ProductLocal)
  |   +- CustomerHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- local-sung.common.behavior.FindAllBehaviour (class: Proxy for: sung.common.behavior.FindAllBehaviour)
  |   |   +- local (class: Proxy for: sung.common.behavior.FindAllBehaviour)
  |   +- Option (class: org.jnp.interfaces.NamingContext)
  |   |   +- local-sung.app.kylintv.ejbclient.product.OptionLocal (class: Proxy for: sung.app.kylintv.ejbclient.product.OptionLocal)
  |   |   +- local (class: Proxy for: sung.app.kylintv.ejbclient.product.OptionLocal)
  |   |   +- remote-sung.app.kylintv.ejbclient.product.OptionRemote (class: Proxy for: sung.app.kylintv.ejbclient.product.OptionRemote)
  |   |   +- remote (class: Proxy for: sung.app.kylintv.ejbclient.product.OptionRemote)
  |   +- DurationHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (class: Proxy for: sung.app.kylintv.ejbclient.product.DurationLocal)
  |   |   +- local-sung.app.kylintv.ejbclient.product.DurationLocal (class: Proxy for: sung.app.kylintv.ejbclient.product.DurationLocal)
  |   |   +- remote (class: Proxy for: sung.app.kylintv.ejbclient.product.DurationRemote)
  |   |   +- remote-sung.app.kylintv.ejbclient.product.DurationRemote (class: Proxy for: sung.app.kylintv.ejbclient.product.DurationRemote)
  |   +- VariantHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (class: Proxy for: sung.app.kylintv.ejbclient.product.VariantLocal)
  |   |   +- local-sung.app.kylintv.ejbclient.product.VariantLocal (class: Proxy for: sung.app.kylintv.ejbclient.product.VariantLocal)
  |   |   +- remote (class: Proxy for: sung.app.kylintv.ejbclient.product.VariantRemote)
  |   |   +- remote-sung.app.kylintv.ejbclient.product.VariantRemote (class: Proxy for: sung.app.kylintv.ejbclient.product.VariantRemote)
  |   +- VelocityBean (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (class: Proxy for: sung.app.kylintv.ejb.velocity.Velocity)
  |   |   +- local-sung.app.kylintv.ejb.velocity.Velocity (class: Proxy for: sung.app.kylintv.ejb.velocity.Velocity)
  |   +- CustomerAddressHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- local-sung.common.behavior.FindAllBehaviour (class: Proxy for: sung.common.behavior.FindAllBehaviour)
  |   |   +- local (class: Proxy for: sung.common.behavior.FindAllBehaviour)
  |   +- OrderEntityHome (class: org.jnp.interfaces.NamingContext)
  |   |   +- no-interface (class: sung.app.kylintv.ejbclient.order.OrderEntityHome_$$_javassist_50)

Y a-t-il des exigences pour que jndi fonctionne correctement dans un cas comme celui-ci?

Author: bezmax, 2011-11-23

1 answers

En utilisant

productLocal = (ProductLocal) context.lookup("sung_app_kylintv/ProductHome/local")

A renvoyé un message d'erreur légèrement différent:

2011-11-24 12:37:07,893 INFO  [STDOUT] (http-0.0.0.0-8080-2) productLocal called successfully.
2011-11-24 12:37:07,893 INFO  [STDOUT] (http-0.0.0.0-8080-2) productLocal calling createTestEntry().
2011-11-24 12:37:07,950 ERROR [STDERR] (http-0.0.0.0-8080-2) org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: sung not bound]

Après qu'un de mes collègues ait jeté un coup d'œil, l'erreur a été identifiée: j'ai essayé une injection en utilisant @EJB à l'intérieur de cette classe ProductHome, qui utilisait mappedName="sung/...". Le mappedName n'est pas correct et même pas nécessaire du tout, à l'intérieur du projet ejb, les connexions existent déjà et fonctionnent. J'espère que cela peut aider les autres aussi.

Solution: J'ai dû réparer mon ProductHome par suppression de l'attribut mappedName sur mon appel ejb. Après que la classe peut être instanciée et les fonctions sont appelées.

 0
Author: Norman, 2011-11-24 15:17:48