我无法进行查找
项目结构: 动态Web项目(gss-web)和EJB项目(gss-ejb)在.ear(gss-ea)中一起部署到jboss 6服务器上
例外: javax.naming.NamingException:无法取消引用对象[根异常是javax.naming.NameNotFoundException:gss-ea未绑定]
代码 - 来自我的Web项目中的托管bean:
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.CorporateActionService[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)
非常感谢任何帮助。提前谢谢!
/埃里克
答案 0 :(得分:1)
尝试:
return ( CodesService )ctx.lookup( "java:global/gss-ea/gss-ejb/CodesBean" );
注意:“global”之前没有“/”。
答案 1 :(得分:0)
您是否检查过jmx控制台以查看是否正确部署了ejb。我认为您用于查找的名称不正确。它的ejb名称通常附加本地或远程。快速查看jmx控制台将为您提供正确的名称。
话虽如此,如果你使用的是ejb 3.x,你不必也不应该像这样查找ejb。只需使用@Ejb注释将Ejb注入到servlet中。
如果您使用的是Ejb3.1,则可以在战争中直接打包ejb。