Sé que hay algo mal con el managedBean, pero no puedo averiguar lo que esjavax.el.PropertyNotFoundException: Objetivo inalcanzable, 'nulo' volvió nulo en referencia de clave externa
Cuando intento departmentManagedBean.department.faculty.facultyName
de la página JSF da un puntero nulo como esto:
javax.el.PropertyNotFoundException: /administrator/department/DepartmentRegistration.xhtml @ 30260 value = "# {} departmentRequestBean.department.faculty.facultyName": destino inalcanzable, 'nulo' devolvió nulo
javax.el.PropertyNotFoundException: /administrator/department/DepartmentRegistration.xhtml @30,260 value="#{departmentRequestBean.department.faculty.facultyName}": Target Unreachable, 'null' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.richfaces.component.util.InputUtils.findConverter(InputUtils.java:123)
at org.richfaces.component.util.InputUtils$1.getConverterByProperty(InputUtils.java:56)
at org.richfaces.component.util.InputUtils.getConvertedValue(InputUtils.java:148)
at org.richfaces.component.util.InputUtils.getConvertedValue(InputUtils.java:137)
at org.richfaces.renderkit.InputRendererBase.getConvertedValue(InputRendererBase.java:50)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:636)
public class Department implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "DepartmentID")
private Integer departmentID;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 255)
@Column(name = "DepartmentName")
private String departmentName;
@JoinColumn(name = "FacultyName", referencedColumnName = "FacultyName")
@ManyToOne(optional = false, fetch = FetchType.EAGER)
public Faculty faculty;
public Faculty getFaculty() {
return faculty;
}
public void setFaculty(Faculty faculty) {
this.faculty = faculty;
}
public Department() {
}
public Department(Integer departmentID) {
this.departmentID = departmentID;
}
public Department(Integer departmentID, String departmentName) {
this.departmentID = departmentID;
this.departmentName = departmentName;
}
public Integer getDepartmentID() {
return departmentID;
}
public void setDepartmentID(Integer departmentID) {
this.departmentID = departmentID;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
}
public class DepartmentSessionBean {
@PersistenceContext(unitName = "ApplicationPU")
private EntityManager em;
public void persist(Department department) {
em.persist(department);
}
}
public class Faculty implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "FacultyID")
private Integer facultyID;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 255)
@Column(name = "FacultyName")
private String facultyName;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "faculty", fetch = FetchType.EAGER)
private List<Department> departmentList;
public Faculty() {
}
public Faculty(Integer facultyID) {
this.facultyID = facultyID;
}
public Faculty(Integer facultyID, String facultyName) {
this.facultyID = facultyID;
this.facultyName = facultyName;
}
public Integer getFacultyID() {
return facultyID;
}
public void setFacultyID(Integer facultyID) {
this.facultyID = facultyID;
}
public String getFacultyName() {
return facultyName;
}
public void setFacultyName(String facultyName) {
this.facultyName = facultyName;
}
public List<Department> getDepartmentList() {
return departmentList;
}
public void setDepartmentList(List<Department> departmentList) {
this.departmentList = departmentList;
}
}
Este es el ManagedBean que necesito una solución con por favor:
@ViewScoped public class DepartmentRequestBean {
@EJB
private DepartmentSessionBean departmentSessionBean;
private Department department = new Department();
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
public void save(){
departmentSessionBean.persist(department);
}
public DepartmentRequestBean() {
this.faculty = new Faculty();
}}