This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble in using @EJB in a ManagedBean...

 
Paterne Gaye-Guingnido
Greenhorn
Posts: 5
  • 0
  • 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?
 
Armen Arzumanyan
Greenhorn
Posts: 13
  • 0
  • 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
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic