wood burning stoves 2.0*
The moose likes Websphere and the fly likes Problem with Session Facade Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Problem with Session Facade" Watch "Problem with Session Facade" New topic
Author

Problem with Session Facade

Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
Hello,
somehow I have the problem of not beeing able to look up my Entity Bean's local home interface in my Session Facade Bean (=Session Bean).
I try to lookup the JNDI name of the local home interface as I have read in an article using the local scheme: local:ejb/.
First of all I have the following question:
When I use "stage.person.PersonBean" as my JNDI Name, in which schema is it located ? Usually lookup with .lookup("stage.person.PersonBean") works fine, but when I use the local home interface it can't be found.
So do i have to set the JNDI name to: "local:ejb/stage/person/PersonBean" in order to make it work ?
And why Websphere doesn't find the local Schema. Sorry that I can't provide the stacktrace, but I can tell you that the Server can't find the local Schema.
I appreciate any hints, in order to get my Session Facade pattern running.
-- Max


Student of Business Informatics<br />Kepler University Linz, Austria
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
Where did you find instructions telling you to use the "local:" scheme? It's not standard, and is not supported by WebSphere. Instead, after declaring an EJBReference to your local Entity home in your Session, you need to use "java:comp/env" as the namespace root to locate your entity.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
Kyle, thank you for the reply.
I found it in a review on theserverside.com, someone replied on the review:
here the link: http://www.theserverside.com/reviews/thread.jsp?thread_id=17947
Message #79783
" 2.1 It does not work. The SAME application is working UNMODIFIED on JBoss and weblogic, but not on websphere. For example have you tried to run local ejb calls in websphere ? If you want do it, you have to discover that there is a local namespace and use IN YOUR CODE. Since this, i have in my code (write once run anywhere BUT on websphere):
(WEBSPHERE SPECIFIC)
static final String WASLOCALJNDISTRING = "local:ejb/";
public static String getSequenceLocalHome() {
if (SystemProperties.isWebsphere())
return WASLOCALJNDISTRING + SEQUENCE_HOME;
return SEQUENCE_LOCAL_HOME;
}
...."
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
The guy who posted that is full of ****. He doesn't know what he's talking about. The java:comp/env namespace is all you need to use.
Kyle
Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
Hi Kyle,
is there any paper or article you can recommend that describes the jndi names I have to use when building a session fascade with Websphere 5.0 ?
This would help me a lot.
Many thanx,
Max
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
Well, the best reference would be my book, but unfortunately we're about a month out from having that released. In the meantime, though, you really don't need anything special for WebSphere -- this isn't a WebSphere specific issue.
The third edition of Richard Monson-Haefel's EJB book describes the use of ejb-references in detail, and that would be a good reference to use. Do you understand what I mean by using the "java:comp/env" namespace? Are you simply getting confused as to on what EJB you declare the local references? If so, you might want to look at the short little writeup on my blog (available from my webpage below).
Or would it be more instructive if I try to write you a short tutorial?
Kyle
Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
Unfortunately I don't have my box available at the moment.
So I can't tell you the exception I get when trying to look up my Entity Bean. But I may have a problem with understanding the need to use the java:comp/env namespace. In most articles I have read, the people use the following JNDI bindings "com/mycompany/somepackage/someclassname".
There is absolutely no sign of "java:comp/env", but as mentioned before I may not understand - maybe the "java:comp/env" is the standard namespace.
But on weekend I will be at home (where my box is standing) and I will post my exception, maybe you can help me again.
Really many many thank yous !!!
Max
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
Maximilian,
The JNDI references like "com/ibm/yada/MyBean" are old-style "Global References". They were what was advocated before the introduction of EJB 1.1. Ever since then the method that has been advocated has been the use of "ejb-references", as described in Monson-Haefel, or in the EJB spec. You can gain some insight into how this works by reading this sidebar to one of my articles. However, I would strongly suggest you pick up a copy of Monson-Haefel's 3rd Edition and start there.
Kyle
Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
Many thanx Kyle.
This hint was what I needed and I hope I can resolve my problem on friday.
In case it doesn't work, I will post a new message with the stacktrace.
Max
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Maximillian
The main reason you are not able to find your local ejb or whichever ejb you are trying to reference is bcos, you need to mention in your deployment descriptor that "One ejb is referring to the other". ejb-ref links...
And as far as I have been doing it, you dont have to use java:comp/env but it is always a good practice not to use jndi names directly in ur code which will lose the flexibility of changing the jndi names while installing the application.
What does java:comp/env does is:
You will have a jndi name, say for example for your local entity bean, call it as x/ejbA
Now, your ejbB calls this ejbA with this name. Now if anytime if anyone change this name in the deployment descriptor you will end up changing your code or property file or whatever. so, inorder to avoid this, you can give a reference to your jndi names through binding files in websphere. The name which you are using to bind with the original jndi name is the one you should use with java:comp/env/doundJndiName
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Session Facade
 
Similar Threads
was5.0 local CMP problem
JNDI for local and remote interfaces: which works?
JNDI lookup of local and remote home interfaces
cannot access sessionLocal
Local Entity Bean not bound in EJB 2.1 on JBoss 4.2.3 server