1
我試圖通過使用JNDI命名實現ejb調用。JNDI查找只返回「javax.naming.NameNotFoundException」
設置:
- JBoss-6.1.0.Final
- 耳部署:
- gwt.war
- ejb.jar
我的問題是,儘管JNDIView顯示我現有的ejb,但我無法達到它。
在我的RemoteServiceServlet中,我嘗試訪問ejb,該ejb部署在同一個ear-package中的ejb.jar中。
我已經嘗試了幾次電話,因爲我不確定正確的jndi代碼。
try
{
productLocal = (ProductLocal) context.lookup("ProductHome/local");
}
catch (NamingException e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
也試過:
productLocal = (ProductLocal) context.lookup("ProductLocal");
productLocal = (ProductLocal) context.lookup("sung_app_kylintv/ProductHome/local");
的無狀態EJB是這樣分配:
@Stateless
@Local(ProductLocal.class)
@Remote(ProductRemote.class)
@LocalBinding(jndiBinding="ProductLocal")
@RemoteBinding(jndiBinding="ProductRemote")
public class ProductHome extends HomeBase<ProductEntity> implements SessionBean, Serializable, ProductLocal
的啓動上下文:
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);
我關於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)
有什麼要求JNDI來在這樣的情況下正常工作?
'java:comp/env/ProductHome/local'? – EJP