• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

JNDI naming and DI in EJB 3

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

I really new to EJB 3. I try some example code of EJB 3. I found some problem

1. Aboout standart default JNDI naming in, Its look different for each app.server in. Is not it?
in Jboss for session
context.lookup("shortnameClass/remote");
in sjas for session
context.lookup("fullnameClass/remote");
which one will be use as srandart ans also being asked in SCBCD 5?

2. I try this snippet
package ejb3inaction.example;

import javax.ejb.EJB;

public class HelloUserClient {
@EJB
private static HelloUser helloUser;

public static void main(String[] args) {


helloUser.sayHello("Curious George");
System.out.println("Invoked EJB successfully .. see server console for output");
}
}


and i got null pointer Exception. Is it because I used Dependency Injection in stand alone aplication in @EJB to inject the bean?

thank's before for all rancher

Mujoko
Never Ending Improvement
 
joko mujoko
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The both questions, I try for Session Stateless Bean
 
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Dependency injection is only allowed for Application Client also for servlets and ejb's.

It is not allowed for standalone java client.

Regards.
 
joko mujoko
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Shivani,

Its clear now about null pointer in stand alone client.
How about standart naming in JNDI for EJB 3?
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Joko,

Well I have used jboss and it uses class<shortname>/remote as you rightly mentioned. In in Head First SCBCD they mention a look with complete naming context i.e java:comp/env/ejb/<MyEJBName>, where ejb/MyEJBName is specified name for ejb ref in the DD.

In my test jboss application I could look up using the following:


For each application server, there are different provisions in addition for lookups. Like jboss has @RemoteBinding to specify the jndi name for bean lookup etc.

Regards,
Shivani
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic