Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Remote vs Local deployment....difference???

 
Pradeep Bhat
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between deploying a stateless session bean with a remote and local interface.

This is my code :




I do the look up as
HelloUser user = (HelloUser)ctx.lookup("hhh/remote");

This works fine. But the same doesn't work for local interface.





If i do the lookup as HelloUser user = (HelloUser)ctx.lookup("hhh/local");...i get the following exception

Exception in thread "main" javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Could not find InvokerLocator URL at JNDI address "hhh/local"; looking up local Proxy from Remote JVM?]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1472)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:818)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at HelloWorldClient.main(HelloWorldClient.java:11)
Caused by: java.lang.RuntimeException: Could not find InvokerLocator URL at JNDI address "hhh/local"; looking up local Proxy from Remote JVM?
at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.createProxyFactoryProxy(ProxyObjectFactory.java:185)
at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:146)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1447)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1464)
... 4 more




If i do the look up as HelloUser user = (HelloUser)ctx.lookup("hhh"); ...i get the exception as

Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.NamingContext
at HelloWorldClient.main(HelloWorldClient.java:11)





I am using jdk1.5 and jboss-5.0.1.GA.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between deploying a stateless session bean with a remote and local interface.


Local interfaces are meant to be used from the same JVM as the application server on which your bean is deployed. Remote interfaces can be used from other (remote) JVMs too (example standalone clients).

Exception in thread "main" javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Could not find InvokerLocator URL at JNDI address "hhh/local"; looking up local Proxy from Remote JVM?]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1472)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:818)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at HelloWorldClient.main(HelloWorldClient.java:11)


This shows that you are using a local interface from a remote JVM (standalone client). This is not allowed and hence the exception.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic