The Artima Developer Community
Sponsored Link

Java Answers Forum
inject entity manager in JSF managed bean

1 reply on 1 page. Most recent reply: Sep 26, 2007 12:45 AM by Dheeraj Kumar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Maria M

Posts: 1
Nickname: maria15
Registered: Sep, 2007

inject entity manager in JSF managed bean Posted: Sep 23, 2007 11:14 PM
Reply to this message Reply
Advertisement
Hi All,
I am learning JSF and EJB for first time, trying to make injection entity manager to JSF managed bean
but i have error like this :

javax.servlet.ServletException: #{loginBean.validate}: java.lang.NullPointerException
javax.faces.webapp.FacesServlet.service(FacesSer vlet.java:256)

root cause

javax.faces.FacesException: #{loginBean.validate}: java.lang.NullPointerException
com.sun.faces.application.ActionListenerImpl.pro cessAction(ActionListenerImpl.java:107)javax.faces.component.UICommand.broadcast (UICommand.java:383)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot .java:447)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:7 52)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhas e.java:97)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
c om.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces .webapp.FacesServlet.service(FacesServlet.java:244)

root cause


my JSF managed bean like this :
package com.login;

@Stateless(name = "loginpassword")
public class LoginBean implements LoginPassword{
@PersistenceContext
private EntityManager em;

String name;
ComplexPassword password;
public LoginBean() {
super();
password = new ComplexPassword();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ComplexPassword getPassword() {
return password;
}
public void setPassword(ComplexPassword password) {
this.password = password;
}
public static class ComplexPassword {
String convertedID;
public String getConvertedID() {
return convertedID;
}
public void setConvertedID(String convertedText) {
this.convertedID = convertedText;
}
}

public void validate() {
List getName = em.createQuery("Select name from ContactsEntity where name='Maria' ").getResultList();
System.out.println("test");
}
}

whenever i run this application, it returns error for line : List getName = em.createQuery("Select name from ContactsEntity where name='Maria' ").getResultList();

Does Anyone here can explain me what this error mean?
Thanks in advance..


my entity class like :

package com.login;

@Entity(name="contactsentity")
@Table(name = "contacts")

public class ContactsEntity implements Serializable {
@Id private Integer id;
private String name;
private String firstname;
private String lastname;
private String email;
private String password;

public ContactsEntity() {
}

//getter and setter
}


my JSF JSP page which call 'validate' function :

<h:commandButton value="#{msg.login}" action="#{
LoginBean.validate}"></h:commandButton>


please someone help me coz i'm quite desperate now.. I've spent couple of days to solve this but still i can't...


Thanks and regards,
Maria


Dheeraj Kumar

Posts: 1
Nickname: desitek
Registered: Sep, 2007

Re: inject entity manager in JSF managed bean Posted: Sep 26, 2007 12:45 AM
Reply to this message Reply
can you post the jsf code?

Flat View: This topic has 1 reply on 1 page
Topic: inject entity manager in JSF managed bean Previous Topic   Next Topic Topic: Debugging in java* / JNI evironments

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use