Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to lookup Business Interface in EJB 3.0?  RSS feed

 
Suhas Saheer
Greenhorn
Posts: 17
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have written an application in EJB3.0
The app server used is Weblogic10.3

Please find below the Business Interface and Bean class.

<u><b>Business Interface</b></u>
@Local
public interface MySessionLocal
{
public int add(int x, int y);
}


<u><b>Bean Classs</b></u>
@Stateless
@Session(transactionType=SessionTransactionType.CONTAINER,ejbName="MySessionEJB")
@JndiName(local="MySessionLocal")
public class MySessionEJB implements MySessionLocal
{
public int add(int x, int y) {
return x+y;
}
}


Now the challenge that i face is that i need to lookup the Business Interface.
How to do that? I want to do a lookup based on JNDI NAME.

Also, please tell me whether the values that i have given for @JndiName annotation and @Session annotations are right or wrong.

Thanks in advance.


 
Suhas Saheer
Greenhorn
Posts: 17
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I got the solution.
I m sharing that with you all here.

Its should be

{BusinessInterface Name}#{jndiName}

initialContext.lookup({BusinessInterfaceName}#{jndiName});

For example
Please find below the Business Interface and Bean class.

<u><b>Business Interface</b></u>
@Local
public interface MySessionLocal
{
public int add(int x, int y);
}


<u><b>Bean Classs</b></u>
@Stateless(mappedName = "MySessionEJB ")
public class MySessionEJB implements MySessionLocal
{
public int add(int x, int y) {
return x+y;
}
}


So the Bean lookup would be like this
initialContext.lookup("MySessionLocal#MySessionEJB ");
 
bhupender kaur
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i use this in oc4j application server then will it work ? and do we need to give any entry somewhere for local interface and session bean.




thanks
Bhupender
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!