• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Trouble in using @EJB in a ManagedBean...  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I'm using Netbeans 6.1 + Glassfish v2 + JSF
I working on an Java EE project with 3 module (war, ejb and swing client)
My app-client and my ejb module work without difficulty.

Now I'm trying to create an jsf page with will show the data of my database


=1==============
I add my EJB module to my WAR module

=2==============
I create a managedbean EvaluationController in my war project
In the managedbean, I declare an EJB with @EJB

=3==============
I the face-config.xml I declare my managedbean with I call "evaluationLocal"

=4===============
I create an page evaluations.jsp where I use the managedbean "evaluationLocal"


Here are my files:
****************face-config.xml**************************


****************sun-web.xml*******************************


****************The managedbean : EvaluationController*************




When I execute the page, I have the message:




I use the "verify" tool of Netbans and I have the message


Please can you tell me where is my mistake?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead @EJB you must use lookup

here is a working example

private BeanRemote remote;//remote interface of your session bean

public String start() throws NamingException {
String navigation = "null";
try {
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext context = new InitialContext(environment);
remote = (BeanRemote) context.lookup("wn/Bean/remote"); // wn project name , Bean - name of session bean
System.out.println("-->> lookup object successfully");
wnUser = new WnUser();/// ----------> your entity bean

this.wnUser.setEmail(email);
this.wnUser.setPassword(password);
this.wnUser.setFirstname(firstname);
this.wnUser.setLastname(lastname);
this.wnUser.setGender(gender);
this.wnUser.setBirthday(birthdate);
this.wnUser.setMobilePhone(mobilePhone);
this.wnUser.setCreateDatetime(createDatetime);
this.wnUser.setCreateDatetime(createDatetime);
remote.create(wnUser); (calling method from remote interface ....
 
Paterne Gaye-Guingnido
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer Armen Arzumanyan
But if I choose your proposal, I'll use
remote interface instead of local.

I also want to know which mistake I make.
Or if it is a bug of Glassfis/Netbeans.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!