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

exception accessing ejb from servlet in OCj4

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm aving a problem accessing a stateful session bean from a servlet. I'm using a jndi lookup to do it because I need that a client has its own bean reference...

My code is:



and I have a reference to EJB into web.xml:

<ejb-local-ref>
<ejb-ref-name>ejb/Carrello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home></local-home>
<local>carrello.model.CarrelloLocal</local>
</ejb-local-ref>

If I use @EJB annotation to inject the servlet, it works fine.
Instead using jndi lookup throws a NamingException because it doesn't find java:comp/env/ejb/Carrello entry.

Any idea about the problem?

[edit]Add code tags. CR[/edit]
[ July 14, 2008: Message edited by: Campbell Ritchie ]
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Valerio,
Pardon me if I am stating the obvious, but first of all, in order to lookup an EJB from a servlet, both the EJB and servlet usually need to be in the same EAR, i.e. same JEE application.
Also, it looks like you are using the EJB's local interface, in which case I believe your lookup string is wrong.
I don't recall the correct format, but I believe it is detailed in the OC4J documentation, which is available from:

http://www.oracle.com/technology

Good Luck,
Avi.
 
BWA HA HA HA HA HA HA! Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic