开发者

Problem doing jndi lookup for EJB

开发者 https://www.devze.com 2023-02-22 17:47 出处:网络
Im having trouble doing a lookup Project Structure: a dynamic web project (gss-web) and an EJB project (gss-ejb) deployed together inside an .ear (gss-ea) onto a jboss 6 server

Im having trouble doing a lookup

Project Structure: a dynamic web project (gss-web) and an EJB project (gss-ejb) deployed together inside an .ear (gss-ea) onto a jboss 6 server

Exception: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: gss-ea not bound]

Code - From inside a managed bean in my web project:

InitialContext ctx = new InitialContext( );
return ( CodesService )ctx.lookup( "java:/global/gss-ea/gss-ejb/CodesBean" );

java Namespace : jndi tree (from jmx console on jboss):
 +- global (class: org.jnp.interfaces.NamingContext)
  |   +- jmx-console (class: org.jnp.interfaces.NamingContext)
  |   +- ROOT (class: org.jnp.interfaces.NamingContext)
  |   +- uuid-key-generator (class: org.jnp.interfaces.NamingContext)
  |   +- http-invoker (class: org.jnp.interfaces.NamingContext)
  |   |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   +- gss-ea (class: org.jnp.interfaces.NamingContext)
  |   |   +- gss-web (class: org.jnp.interfaces.NamingContext)
  |   |   +- gss-ejb (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- CorporateActionBean!com.comp.gss.session.CorporateActionS开发者_如何学JAVAervice[link -> gss-ea/CorporateActionBean/local-com.comp.gss.session.CorporateActionService] (class: javax.naming.LinkRef)
  |   |   |   +- CodesBean!com.comp.gss.session.CodesService[link -> gss-ea/CodesBean/local-com.comp.gss.session.CodesService] (class: javax.naming.LinkRef)
  |   |   |   +- BasketBean!com.comp.gss.session.BasketService[link -> gss-ea/BasketBean/local-com.comp.gss.session.BasketService] (class: javax.naming.LinkRef)
  |   |   |   +- FPBean[link -> gss-ea/FPBean/local-com.comp.gss.session.FPService] (class: javax.naming.LinkRef)
  |   |   |   +- CodesBean[link -> gss-ea/CodesBean/local-com.comp.gss.session.CodesService] (class: javax.naming.LinkRef)
  |   |   |   +- PopulationBasketBean!com.comp.gss.session.PopulationBasketBean[link -> gss-ea/PopulationBasketBean/no-interface] (class: javax.naming.LinkRef)
  |   |   |   +- CorporateActionBean[link -> gss-ea/CorporateActionBean/local-com.comp.gss.session.CorporateActionService] (class: javax.naming.LinkRef)
  |   |   |   +- OutputBean!com.comp.gss.session.OutputService[link -> gss-ea/OutputBean/local-com.comp.gss.session.OutputService] (class: javax.naming.LinkRef)
  |   |   |   +- FPBean!com.comp.gss.session.FPService[link -> gss-ea/FPBean/local-com.comp.gss.session.FPService] (class: javax.naming.LinkRef)
  |   |   |   +- PopulationBean[link -> gss-ea/PopulationBean/local-com.comp.gss.session.PopulationService] (class: javax.naming.LinkRef)
  |   |   |   +- BasketBean[link -> gss-ea/BasketBean/local-com.comp.gss.session.BasketService] (class: javax.naming.LinkRef)
  |   |   |   +- PopulationBean!com.comp.gss.session.PopulationService[link -> gss-ea/PopulationBean/local-com.comp.gss.session.PopulationService] (class: javax.naming.LinkRef)
  |   |   |   +- PopulationBasketBean!com.comp.gss.session.PopulationBasketService[link -> gss-ea/PopulationBasketBean/local-com.comp.gss.session.PopulationBasketService] (class: javax.naming.LinkRef)
  |   |   |   +- OutputBean[link -> gss-ea/OutputBean/local-com.comp.gss.session.OutputService] (class: javax.naming.LinkRef)

Any help would be greatly appreciated. Thanks in advance!

/Eric


Try:

return ( CodesService )ctx.lookup( "java:global/gss-ea/gss-ejb/CodesBean" );

Note: no "/" before "global".


Have you checked your jmx console to see if the ejb's are deployed properly. I think the name you have used to lookup is not correct. Its usually ejb name appended with local or remote. A quick look in to your jmx console will give you the correct name.

Having said that, you do not have to and probably should not lookup ejb like this, if you are using ejb 3.x. Just inject your Ejb in to your servlet using @Ejb annotation.

If you are using Ejb3.1, you can package ejb directly in your war.

0

精彩评论

暂无评论...
验证码 换一张
取 消