• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Considering Injection i EJB 3.0

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

My environment is:
Using JBoss ver. 4.2.1 and %JAVA_HOME% IS 'C:\Program Files\Java\jdk1.5.0_12', my JRE is 'java version "1.6.0_02" ' which should not cause any harm.

Reading Debu Panda's article on DI from 2006 on ONJava.
Still, having problem using the @EJB.
The example in Pandas article ( page 4 ) is like this:

He never tells where the ProcessManager is coming from, it must be from a ejb-jar.xml ( or another DD ) - but how is the syntax ?

Another example:
From O'Reillys workbook (Enterprise Javabeans 3.0, 5th edition ) there is an example of a Stateless 'TravelagentBean' that is using 'ProcessPaymentBean' which implements both a Local and a Remote interface ( ch. 11_5 ).
The 'TravelAgentBean' is using 'ProcessPaymentBean', and the code within the 'TravelAgentBean' is like this:

and the ejb-jar.xml is like this:

But the syntax is not correct.
I am getting the following error:


And finally:


is there an obvious answer here or am I totally missing the point ?

regards, i

ps.
My ejb-jar.xml starts with these lines:

Is this the correct information to my JBoss ?
ds.

[ October 12, 2007: Message edited by: ing erl ]

[ October 12, 2007: Message edited by: ing erl ]

[ October 12, 2007: Message edited by: ing erl ]

[ October 12, 2007: Message edited by: ing erl ]
[ October 12, 2007: Message edited by: ing erl ]
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ing,

ProcessManager is an interface that contains business methods. If you have @Local annotation on ProcessManager then "ProcessManager" will be registered as the jndi name. It is all done through injections... no more ejb-jar.xml file required.

In your second case...

Is that your complete ejb-jar.xml file? If yes then it is not complete. In this sample you do not need to use ejb-jar.xml... just make sure that PaymentProcessLocal interface has @local annotation.

The same argument applies for TravelAgentBean.
 
ing erl
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Shailesh Kini!!!

You saved me here, thank you so much.
Well, one is puzzled these days; I bought 3 pair of books regarding EJB 3.0.
Everyone of them has so many errors that you loose faith in the end.

The O'Reilly where the example is from, here is their ejb-jar.xml file:


So, from this example - how am I to know that this is the wrong way to do things ?
As you said, I had it all from the start with the '@Local' annotation.
My ejb-jar.xml is only these few lines:


And it is just for the sake of testing.

So I am very greatful for your help.
Are there any books out the covering EJB 3.0 for a newcomer in the Enterprise JavaBeans world in the sence that I am not coming from EJB 2.1, but from J2SE ? A book where nothing is taken for granted?

Going to follow this up by looking at JMS and Transactions, within EJB 3.0.
If you have any tips regarding the subject, you are welcome.

regards, i
[ October 12, 2007: Message edited by: ing erl ]
 
ing erl
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Using Local interfaces with the annotation @EJB.
Is that only possible to use from other Enterprise Javabeans.
I am not able to use the @EJB from within a servlet
though the servlet is running in the same JVM as the EJB ?
When using an EJB from within a Servlet I must always use 'lookup' ?

regards, i
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ing,

I have read very good reviews about Pro EJB3 but haven't read it myself. I think you should give it a try.

You should be able to use @EJB from within a servlet. Servlet 2.5 spec does not require you to perform a lookup. It will resolve @EJB annotation for you.

These link might help.
web page
 
reply
    Bookmark Topic Watch Topic
  • New Topic