• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Connecting to ejb 3 session bean from struts 2 ActionSupport

 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I get a reference to an ejb 3 local session bean from a struts 2 ActionSupport subclass?

E.g. is injection possible?

I did try to inject but got null.

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In theory, you're supposed to be able to use the @EJB annotation in a web client. In practice, most web containers don't support it. The best way I know of to get an EJB3 reference that works fairly consistently is:
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like the other variations I tried with lookups, it also threw exception on that statement.



Just to note that when using servlet without struts, the annotation works. But now I need to use the session bean inside struts ActionSupport.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suggest reading this link from the WAS 6.1 Infocenter.
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Merrill Higginson:
In theory, you're supposed to be able to use the @EJB annotation in a web client. In practice, most web containers don't support it. The best way I know of to get an EJB3 reference that works fairly consistently is:



Thank you for the link. It helped clear things up.

And thanks, the code you gave above worked! (after I changed @Local to @Remote in session bean.

For why WAS wants it like that is another mystery; but good enough for now for my purpose.

The injection @EJB still didnt work; but anyway I have that code above to get the bean.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm glad you got it working.

Just for the record, according to the link I gave you, it should still be possible to use the local interface if you append "ejblocal:" to the beginning of the lookup name.
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. I will try that out when I have time.
 
You can't expect to wield supreme executive power just because
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic