how to deploy ejb jar in application server

i created ejb session bean,home and remote classes and created jar using myeclipse export button.

1.can i deploy jar in the application server or do i need to create ear file and include the jar and deploy the ear.which one is correct approach?

2.can i look up ejb using standalone client .
LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sompol_kiatkamolchaiCommented:
Yes. You can.
0
sompol_kiatkamolchaiCommented:
What is your application server? I will give you some example code for lookup ejb.
0
chaitu chaituAuthor Commented:
oracle application server
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

sompol_kiatkamolchaiCommented:
JNDI with Enterprise Java Beans (EJB)
===============================
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/j2ee/jndi/index.html#JNDI with Enterprise Java Beans

Hope this help,
Sompol
0
sompol_kiatkamolchaiCommented:
JNDI with Enterprise Java Beans (EJB)
===============================
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/j2ee/jndi/index.html#JNDI%20with Enterprise%20Java%20Beans

Hope this help,
Sompol
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chaitu chaituAuthor Commented:
sompol,
my main intension is how can you say that stateful maintians conversational state and stateless cannot maintain conversational state .can you show me with some real examples?

if i see some real examples then i can understand better how conversational state works in session beans?
0
sompol_kiatkamolchaiCommented:
What is the version of oracle as?
0
chaitu chaituAuthor Commented:
(10.1.3)
0
sompol_kiatkamolchaiCommented:
Hi chaituu,

I think this link should match your request.
http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-ejb30-stateful-ejb/doc/how-to-ejb30-stateful-ejb.html

Hope this help,
Sompol
0
chaitu chaituAuthor Commented:
i  will try this example and let you know the result.please give me some time.
0
chaitu chaituAuthor Commented:
i will try the same example with one time with stateful and other time with stateless and find out the difference between.if i write sample example for stateless what changes do i need to make?
0
chaitu chaituAuthor Commented:
sompol,

i have implemented ejb's in our project but i want to understand what conversational  means by implementing one example.
0
sompol_kiatkamolchaiCommented:
Hi chaituu,

If you implement stateful (a.k.a. conversation), it means that client will invoke method on the same instance of ejb until it finishes the conversation.

From the example I gave you above, in the client program.

@EJB
private static Cart cart;
Step1. >> This two line of code will create instance of Cart at the server-side and pinned with this client only

cart.addItem("Item1");
Step 2 >> This method call will modify state of ejb instance that created by Step1.

cart.addItem("Item2");
Step 3 >> This method do the same thing in Step2 and modify on the same instance.

Collection items = cart.getItems();
Step 4 >> This method get the list of item added by Step2, 3

The point is ejb instance is pinned to client until it finishes the conversation.

In stateless session bean, the instance cannnot be pinned to client, so you don't know what instance at server-side will serve your request on each method call.

Hope this help,
Sompol

0
chaitu chaituAuthor Commented:
hi sompol,

thanks for the explaination.i will make same example by changing from stateful to stateless in deployment descriptor.in what way outputs will be defered?
0
sompol_kiatkamolchaiCommented:
Hi chiatuu,

Talk about out between stateful and stateless from this line of code.

System.out.println("  " + item);

In stateful, it guarantees that it will print out
>> Item1 Item2

But in stateless, the output is random, it depends on what instance in the pool at server-side serve your request at that time. So the possible output should be

>>
>> Item1
>> Item2
>> Item1 Item2

And if you execute client more times, you will see the different since the array list is growing. For example.

>> Item1 Item1 Item2 Item1 ....

So now, you may understand more that stateless has a pool of instance at server-side whereas stateful doesn't.

Hope this help,
Sompol
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.