私は小さなプロジェクトに取り組んでいますが、すべてが正しく機能していた後、突然javax.el.PropertyNotFoundException:
、問題の原因がわかりません.最後の作業バージョンの間でコードに加えた唯一の変更は、新しいxhtmlドキュメントでした. 、categoryController を呼び出します。何が起こったのかわからず、解決策にアプローチする方法もわかりません。誰もこれに取り組む方法を知っていますか?
私はいくつかの調査を行い、beans.xml を追加することを発見しましたが、問題が発生する前に beans.xml を持っています。これは、beans.xml の内容です。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
これは、categoryController Bean です。
@Named
@RequestScoped
public class CategoryController {
@EJB
private CategoryEJB categoryEjb;
private Category category = new Category();
private List<Category> categories = new ArrayList<Category>();
// ------------------------------------------------------------- Constructor
public CategoryController() {
}
// -------------------------------------------------------- Business Methods
public String doCreateCategory()
{
category = categoryEjb.createCategory(category);
categories = categoryEjb.findAllCategory();
return "listCategory?faces-redirect=true";
}
これは呼び出されているフォームです:
<h:form>
<h1><h:outputText value="Create New Catergory"/></h1>
<h:panelGrid columns="2">
<h:outputLabel value="Name:" for="name" />
<h:inputText id="name" value="#{categoryController.category.name}" title="Name" />
<h:outputLabel value="Description:" for="description" />
<h:inputText id="description" value="#{categoryController.category.description}" title="Description" />
</h:panelGrid>
<h:commandButton value="Create Category" action="#{categoryController.doCreateCategory()}"/>
</h:form>
これは私が得ている完全なスタックです:
javax.el.PropertyNotFoundException: /product/createCategory.xhtml @15,103 value="#{categoryController.category.name}": Target Unreachable, identifier 'categoryController' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
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.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:1550)
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:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
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:722)
編集:
@Entity
@NamedQueries({
@NamedQuery(name= "findAllCategory", query="SELECT c FROM Category c")
})
public class Category implements Serializable
{
private static final long serialVersionUID = 1L;
@Id @GeneratedValue(strategy= GenerationType.AUTO)
private int category_id;
private String name;
private String description;
@OneToMany(mappedBy = "category_fk")
private List<Product> product_fk;
// ------------------------------------------------------------- Constructor
public Category() {
}
public Category(String name, String description, List<Product> product_fk) {
this.name = name;
this.description = description;
this.product_fk = product_fk;
}
// ---------------------------------------------------- Getters and Setters
public int getCategory_id() {
return category_id;
}
public void setCategory_id(int category_id) {
this.category_id = category_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Product> getProduct_fk() {
return product_fk;
}
public void setProduct_fk(List<Product> product_fk) {
this.product_fk = product_fk;
}