• 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 ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

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

I add my EJB module to my WAR module

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

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

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

Here are my files:


****************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?
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

remote.create(wnUser); (calling method from remote interface ....
Paterne Gaye-Guingnido
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!