EJB CLietn

S

sss

I am trying to call EJB from client application, but seems like it can't
find the ejb
I also download a stub file from the admin page and add to the ejb client
path. but still without the luck.

I am using netbeans to develop with JAVAEE5

@EJB
private static ConverterBean converterBean;

public static void main(String[] args) {
// TODO code application logic here

BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount = converterBean.dollarToYen(param);
System.out.println( amount );
}
 
W

Wesley Hall

sss said:
I am trying to call EJB from client application, but seems like it can't
find the ejb
I also download a stub file from the admin page and add to the ejb client
path. but still without the luck.

I am using netbeans to develop with JAVAEE5

@EJB
private static ConverterBean converterBean;

public static void main(String[] args) {
// TODO code application logic here

BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount = converterBean.dollarToYen(param);
System.out.println( amount );
}

Unless I am quite mistaken, I dont believe you can use the @EJB
annotation on the client. This is used to pass bean references inside
the EJB container.

To get a reference to a ConverterBean from your client you will need to
include the relevant jars in your client classpath and do something like
this...

InitialContext context = new InitialContext();
ConverterBean converterBean = context.lookup("ConverterBean/remote");

I cant help with what jars you will need, and I am not sure if the
lookup string will be correct because these things dependant on your
application server and how you have configured your beans but starting
from here, with a little trial and error you should be able to get it
working.
 
S

sss

To get a reference to a ConverterBean from your client you will need to
include the relevant jars in your client classpath and do something like
this...

InitialContext context = new InitialContext();
ConverterBean converterBean = context.lookup("ConverterBean/remote");

I cant help with what jars you will need, and I am not sure if the
lookup string will be correct because these things dependant on your
application server and how you have configured your beans but starting
from here, with a little trial and error you should be able to get it
working.

I know you can use jndi for ejb 2.0.
but i want to try to do in the EJB3.0 way

Please follow the instruction from the link and let me know
what do you think.
http://java.sun.com/javaee/5/docs/tutorial/doc/EJB2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top