File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Need a *working* EJB 3 tutorial!! 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 » Java » EJB and other Java EE Technologies
Bookmark "Need a *working* EJB 3 tutorial!!" Watch "Need a *working* EJB 3 tutorial!!" New topic
Author

Need a *working* EJB 3 tutorial!!

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
I busted my butt at least half of the day, today, trying to find a working example of an EJB 3.0 Application to run on JBoss 4.0.4RC1.

I've tried this example:

http://docs.jboss.org/ejb3/app-server/tutorial/stateless/stateless.html

It's incomplete, all of the code isn't there, therefore it doesn't work.

I've tried this tutorial from Sun:

http://java.sun.com/javaee/5/docs/tutorial/doc/EJB.html#wp80471

When I deploy it to JBoss and run it, I get this exception:



I tried doing the following:

My local interface:



My stateless session bean:



...using it in a servlet:



Of course, I get the aforementioned JNDI error.

I also tried doing parts of the TrailBlazer application example from JBoss but obviously it's out of date and JNDI has changed in the EJB3 spec since the time that app was created.

I'm puzzled, this all appears very simple yet I can't find one, single working example app! Can someone help me out?

I don't know squat about EJB (2.x *or* 3.0) and I don't know anything about JNDI except what it is, conceptually. I'm literally starting from the very beginning. I want to use JBoss because I'm familiar w/ Hibernate and would prefer to stick w/ a Hibernate-backed EJB3 implementation. I also like the look of Seam and will try and use it when I get comfortable w/ basic EJB3 concepts.

Thanks!
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
I was able to fenagle this into working by packaging it as an EAR project in MyEclipse and by tweaking the JNDI lookup to use the EAR name in the path.

EJB 3.0 is pretty neat! I hope the spec is finalized soon!

Thanks!

-v
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Cool. Yeah the idea of putting everything in an ear makes things easier.

Yeah EJB3 is very nice.

What we do here is create the interface with no annotations. Then create two seperate interfaces that extend the first interface, each of these will be the local and remote interfaces. Then we create the bean class that implements both the local and remote interfaces. I am still using the bean as a thin facade to the actual POJOs that provide the service. So the service class implements just the first interface that has no annotations.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
Sounds like you've got a nice, simple design for keeping clean boundaries.

I'm trying to decide on a basic design for a storefront I've got to build at work. By all means, it's your basic shopping cart but w/ some heavier integration on the back-end. We'll be tying into PeopleSoft Financials, our bank (cc processing), and a remote inventory system hosted on a different platform - should be a fun project and a good one to take EJB3 out on the road and open 'er up.

I figured I'd use JAX-WS 2.0 for some of the integration tasks...it looks so damn easy to use! I'll be more convinced when I've got a working example.

I'm shocked at how well EJB3 works in JBoss...I've been playing w/ examples and testing it out all day and I'm *really* impressed. I thought Hibernate made life easy - this is a great leap forward!

Anyhow, I'm trying to figure out how to proceed w/ this project...obviously a stateful session bean for shopping cart functionality would work (and I've seen plenty of examples of that now.) Since I'm new to EJB style development I'm just trying to figure out how to package it all up. Should I put my domain model and all of my other EJB3 code in a single ejb-jar? What's the best way to abstract JSF from my session beans? (i.e. - what's a good facade/proxy approach?)

Thanks!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I thought Hibernate made life easy


OK, now I am shocked.

I still remember those comments you made when you first started with Hibernate.

Yes using Web Services for your integration is key. Look also at JDom, and now Java 1.4 has aslo the XMLEncoder and XMLDecoder objects to transform you DTO POJO object into an XML document and back using Serialization.

I would still recommend not using a Stateful Session Bean. Makes for more interesting.

Mark
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
OK, let me rephrase that then, hibernate makes life easy once you get around all of the initial headaches such as; session management & application design *around* Hibernate.

For me, the only way to correctly learn Hibernate is to go out and buy the Hibernate in Action book...at least to get started.

Once over the initial screaming and ripping-out of the hair...it's a great tool for 3/4 of your projects. The rest is still best-suited to JDBC (i.e. complex report queries.)

I'll also go as far as to say that EJB3 is Hibernate done right...or whatever persistence technology you want to put in the place of Hibernate, I love it!

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need a *working* EJB 3 tutorial!!
 
Similar Threads
ejb hanging
EJB Application Client Clarification
How to run the ConverterClient app?
Issue Whie Deploying EJB on JBoss AS 5.1.0...
Developing EJB in J2EE1.4 (New in EJB)