Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBOSS5.0 EJB3 lookup issue

 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all of you,

Well, can anyone tell me why I am getting instance of javax.naming.Reference instead of javax.naming.Remote when i perform jndi lookup.


properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
properties.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces");


Thanks in advance.....
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the entire exception stacktrace

Just a guess - Are you including the jbossall-client.jar and the jar files referenced in its MANIFEST.MF, in your client classpath? Ensure that these jar files are the same as that on the server. You will find these jars in the %JBOSS_HOME%/client folder.
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran Pai ,

Can you please tell me which jar files do I need to place at client side...

Thanks
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


These are the one's you need to have in the client classpath. I took this list from the MANIFEST.MF of jbossall-client.jar. You can find these jars in %JBOSS_HOME%/client folder.
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for your help,
I placed all the jar in classpath, but now I am getting following Exception.

Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy1.createProxyBusiness(Unknown Source)
at org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:133)
at org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:151)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1315)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1332)
... 7 more
Caused by: java.lang.Exception: Can not make remoting client invocation due to not being connected to server.
at org.jboss.remoting.Client.invoke(Client.java:1713)
at org.jboss.remoting.Client.invoke(Client.java:612)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
... 14 more
com.dylt.exception.BaseException: Error in communication with EJB server
at com.dylt.commondelegate.servicelocator.ServiceLocator.getRemoteObject(ServiceLocator.java:55)
at com.dylt.commondelegate.CommonDelegate.getController(CommonDelegate.java:266)
at com.dylt.commondelegate.CommonDelegate.performOperation(CommonDelegate.java:158)
at com.dylt.Test.main(Test.java:32)
Caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1340)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:765)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.dylt.commondelegate.servicelocator.ServiceLocator.getRemoteObject(ServiceLocator.java:40)
... 3 more
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy1.createProxyBusiness(Unknown Source)
at org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:133)
at org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:151)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1315)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1332)
... 7 more
Caused by: java.lang.Exception: Can not make remoting client invocation due to not being connected to server.
at org.jboss.remoting.Client.invoke(Client.java:1713)
at org.jboss.remoting.Client.invoke(Client.java:612)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
... 14 more


Thanks in advance.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your client and EJB code. Remember to wrap it in a code block, using the Code button in the message editor window.
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope that the value for the java.naming.provider.url is a typo (leading 's'). It should be "jnp://10.100.112.72:1099", assuming 10.100.112.72 is your server's IP address.

Also, did you remember to start the server using "-b 0.0.0.0"?
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Peter Johnson,

I made changes as you suggested, but now JNDI lookup returns instance of type SessionProxy instead of java.rmi.Remote.

My server startup option also includes -b 0.0.0.0.

Thansk in advance.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to post the client code that looks up the object in question., What you posted earlier was the code the looked up the initial context. Also, since the exception changed, please post the new exception stack trace. Also, indicate which source line is causing the exception.
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson,

Thanks for your replay. I managed to resolve the issue.
In fact , when my client application performs JNDI lookup, I was getting instance of proxy and my code was casting it to java.rmi.Remote and so the ClassCastException was thrown.

When I took a closer look at the object I was getting from JNDI lookup, I found that the returned object implements my remote interface ( i.e SearchEngineRemote). So , I skipped casting and problem is resolved.

Thank you again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic