• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJB 3.0 local lookup fails with OC4J & JDK 1.5.x

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Local Interface


2) Remote Interface


3) EJB


4) Registring a reference to CircuitServiceSLSB EJB under the logical name CircuitServicesRef
In the ReportingServiceSlsb EJB, I am trying to lookup the local ejb interface CircuitServiceLocal.



Here in the createReport() method the lookup fails throwing the NameNotFoundException. (try catch is there in the code but not shown.)
In createReport() method I want the reference of the CircuitService EJB (local).

Exception:
javax.naming.NameNotFoundException: java:comp/env/CircuitServicesRef not found in ReportingServiceSlsb

Can anybody explain what is going wrong here.
I am using OC4J 10.1.3.4.0 and JDK 1.5.0_16

I know here I can inject the ejb using @EJB annotation, (and that works fine in my code) but for different reason, I have to use the JNDI lookup method.

One more thing is that I am using the lookup method to lookup the remote interface by passing the ejb name CircuitServiceSLSB, it is working fine.

the remote Lookup


Thanks & Regards,
Mahesh
 
Km Mahesh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All!

Can anybody please explain me why the JNDI lookup method is not able to find the the local interface reference which is defined through annotation in another ebj?
Any help would be appreciated.

Thnx & Rgds,
Mahesh
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing is obvious.
In one part of your code you put @EJB above class xyz.

I've been working with this for a couple weeks and this is not how I use the EJB annotation.

You should put the @EJB above an instance variable that represents the Bean you wish to inject.
And keep it inside the class.

I use it in a web app or a client app to replace this code :

with this code :



 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not use OC4J, but if you still have any issues take a close look at the server log to ensure your project was deploying, then I would take a look at the JNDI browser.

Good luck,
Stu
 
Km Mahesh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan Kempten wrote:
You should put the @EJB above an instance variable that represents the Bean you wish to inject.
And keep it inside the class.



As I already explained above, that I don't want to inject the ejb. (For there is no way to inject the ejb conditionally.)
That's why I am using the JNDI lookup.

Dan Kempten wrote:
I use it in a web app or a client app to replace this code :



Does your above code works? Where did you define the JNDI name "MyJNDINameOfMyBean"?
Or did you replace the above code b'coz it was not working?

Dan Kempten wrote:
with this code :



By this you are actually injecting the bean, which I don't want to.
If this optional element "mappedName" is not defined, still the ejb does gets injected.
Is there any specific reason for defining this element?

Finally I want to get the ejb reference through JNDI lookup and not by DI.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mahesh,

Your @EJB usage on the EJB class looks correct. The only reason i can think of it not working is if the createReport() method gets called before the @EJB reference is made available in the ENC. When is the createReport() method being called? Does it get called in the constructor of the bean or is it a business method which the client of the bean calls? If it's the latter, please post the client code where you are calling the method.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you might also want to check if this is some known bug with the version of OC4J server you are using.
 
Km Mahesh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the client code calling the createReport() method...



Is anything going wrong here?
 
Their achilles heel is the noogie! Give them noogies tiny ad!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic