Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Local home interfce accessing in EJB.....  RSS feed

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a small Application using EJB CMP2.0. I have successfully generated Local(will be used by client residing in same server as that of bean) & Remote(will be used by outside clients) Interfaces for my bean.
When I m trying to execute a client on My EJB using Remote Interfaces as follows:-
=====
home = (CartMasterHome)PortableRemoteObject.narrow(initialContext.lookup("ejb/CartMaster"),CartMasterHome.class);
=======
It works fine. But when I am trying to do same thing using Local interfaces as follow:-
=========
homelocal = (CartMasterLocalHome)initialContext.lookup("java:ejb/CartMaster");
=========
It gives me error like:-
=======
Cannot lookup : java.lang.ClassCastException: $Proxy0
=======

I don't know what is problem & where i m wrong.
Please tell me what is wrong here?

Thanx in advance.

Prash
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of object is being returned? Invoke getClass().getName() on it and tell us what you get.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
When I m trying
===================================
System.out.println(initialContext.lookup("java:ejb/CartMaster").getClass().getName());
=================
I got following output
=======
$Proxy0
===========
Please help me.

Thanx in advance.

Prash
 
Jorge Ribeiro
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that you're using the same JNDI name for looking up the local and remote homes. Could it be that you're looking up the remote home and then you're trying to cast it to a local home?
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using for remote access following code:-
=================================
home = (CartMasterHome)PortableRemoteObject.narrow(initialContext.lookup("ejb/CartMaster"),CartMasterHome.class);
=================================
& for local access following code:-
==================================
homelocal = (CartMasterLocalHome)initialContext.lookup("java:ejb/CartMaster");
==================================

For remote all thigs work fine but for local its not the case.

Where i m wrong pls tell me.
Thanx,
Prash
 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I think you are using jndi name of remote interface...

May be the JNDI name for Local Interface would be "CartMasterLocal". as u can't have same jndi name for both remote and local interface.

so instead of
homelocal = (CartMasterLocalHome)initialContext.lookup("java:ejb/CartMaster");

try

homelocal = (CartMasterLocalHome)initialContext.lookup("java:ejb/CartMasterLocal");
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kartik,
You are right. I got my mistake.
Thanx for your reply.
Prash
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I m trying to access my EJB through local interface
the part of content in my JBOSS.xml for bean is as follow:-
============
<entity>
<ejb-name>CartMaster</ejb-name>
<jndi-name>ejb/CartMaster</jndi-name>
<local-jndi-name>CartMasterLocal</local-jndi-name>
<method-attributes>
</method-attributes>
</entity>
============

Now in my client file i m writing following code for bean lookup:-
=============
cddhome.cmHome = (CartMasterLocalHome)initialContext.lookup("CartMasterLocal");
============

But i m getting error like:-
======================
Cannot lookup : javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb.plugins.local.LocalHomeProxy (no security manager: RMI class loader disabled)]
======================

Where i m wrong?
Please tell me.

Thanx
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Root exception is java.lang.ClassNotFoundException: org.jboss.ejb.plugins.local.LocalHomeProxy


Place the jboss.jar in your classpath. This jar can be found in %JBOSS_HOME%/server/default/lib directory.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanx for ur reply.
I tried ur above suggestion.
But now its giving me error while executing cluient file as:-
==============
CartDetailClient:modifyCartjava.lang.NullPointerExceptionjava.lang.NullPointerException
at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
at $Proxy0.findByPrimaryKey(Unknown Source)
at econify.cartdetail.ejb.ClientDetailLocal.modifyCart(ClientDetailLocal.java:75)
at econify.cartdetail.ejb.ClientDetailLocal.main(ClientDetailLocal.java:62)
================

& I m passing parameter for my findbyprimarykey(new Integer(4)); inside my client file.

Then y its giving me above error (nullpointerexception)?
Pls help me.
Thanx in advance.

Prash
 
Andreas Schaefer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are using a Local Interface from a remote client or from another application within the app server.
Please remember that the local interface has no means to invoke an EJB in another JVM. The original problem was caused because, I guess, that you used the local interface in another application and the local interface from the JNDI server was loaded by another class loader than the one your class (application) loaded.
 
hemant borole
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andreas,
I have my client which is just another project in the same workspace. I dont see why my workspace would have different JVM.(s) Yet I get this error. And I just cant figure out why.
This is what I did. I created the EJB as a EJB Project. In the same workspace I have a client which is a Java Project. The client has the localhome and local interface of the ejb in its classes (output directory).
After deploying, restarting jboss and running the application I get the error
Exception in thread "main" java.lang.NullPointerException
at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
at $Proxy0.create(Unknown Source)
at beanClient.UseBean.main(UseBean.java:22)


Can you help me with this
 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hemant

Don't know if this will be much use, but I had similar issues with Local interface invocation on WebSphere:

Java Ranch Websphere Forum

Details my sorry tail. My issue was down to the way WebSphere 'binds' the jndi reference of the local interface.

Hope this is of some use
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!