I try to connect my web application with CDI but it don't want to work... There is an beans.xml file in WEB-INF. When I try to access fields from the CDI-Bean I get an javax.el.PropertyNotFoundException
index.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Simple JSF Facelets page</title>
</h:head>
<h:body>
<h:form >
<p:panelGrid columns="2">
<h:outputLabel for="username" value="Username: "/>
<p:inputText id="username" value="#{credentials.username}" />
</p:panelGrid>
<p:commandButton value="Login" action="#{credentials.login}" />
</h:form>
</h:body>
</html>
Credentials.java
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
#Named
#RequestScoped
public class Credentials{
private String username;
private String password;
#Inject
AuthController authController;
public String login(){
authController.authenticate(username);
return "start";
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
AuthController.java
import addressbook.baselibs.enterprise.stereotype.Current;
import addressbook.user.entity.User;
import addressbook.user.repository.UserRepository;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
#Named
#RequestScoped
public class AuthController implements Serializable{
#Inject
private Authentication authentication;
#Inject
private UserRepository userRepository;
#Inject
private FacesContext facesContext;
#Inject
private Conversation conversation;
#Produces
#Named
#Current
public User getCurrentUser() {
return authentication.getCurrentUser();
}
public void authenticate(String username) {
if(isLogged()) {
throw new IllegalStateException("User is logged and tries to authenticate again");
}
User user = userRepository.getForUserName(username);
if(user == null) {
// User not Found
}
authentication.setCurrentUser(user);
conversation.begin();
}
public void logout() {
authentication.setCurrentUser(null);
conversation.end();
}
public boolean isLogged() {
return authentication.getCurrentUser() != null;
}
}
Stacktrace
00:58:49,975 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) /index.xhtml #15,86 value="#{credentials.username}": Target Unreachable, identifier 'credentials' resolved to null: javax.el.PropertyNotFoundException: /index.xhtml #15,86 value="#{credentials.username}": Target Unreachable, identifier 'credentials' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) [jsf-impl-2.1.7-jbossorg-2.jar:]
at org.primefaces.renderkit.InputRenderer.getConverter(InputRenderer.java:154) [primefaces-3.1.1.jar:]
at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:167) [primefaces-3.1.1.jar:]
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIInput.validate(UIInput.java:960) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIInput.processValidators(UIInput.java:698) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIForm.processValidators(UIForm.java:253) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.primefaces.component.layout.Layout.processValidators(Layout.java:245) [primefaces-3.1.1.jar:]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
Looks like you are injecting "conversation" scoped component in AuthController (private Conversation conversation)... Conversation scoped component is processed by Seam if
#Inject is used to perform injection after the RESTORE_VIEW phase..So during the "RESTORE_VIEW" phase this CONVERSATION scoped component will not be able to be instantiated and throws up
this error...Can you try to use
Component.getInstance() instead of
#inject for this conversation component and see if it helped resolved the issue?
Related
I have a data table in my xhtml file. The data table is using live scroll with lazy loading. The data table also have some editable fields (cell editing). after doing some scrolling and loading more rows, when I edit the cell having selectOneMenu, it throws following exception:
8:42:12,775 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/nextwrapper].[Faces Servlet]] (http--0.0.0.0-8080-4) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:441) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:71) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:582) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:160) [primefaces-5.3.jar:5.3]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:199) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.nextcontrol.utility.CustomExceptionHandler.handle(CustomExceptionHandler.java:40) [classes:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) [primefaces-5.3.jar:5.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
the actual exception is as follows (using Exception handling in JSF ajax requests)
18:42:12,741 ERROR [stderr] (http--0.0.0.0-8080-4) java.lang.IllegalArgumentException: null source
18:42:12,741 ERROR [stderr] (http--0.0.0.0-8080-4) at java.util.EventObject.<init>(EventObject.java:56)
18:42:12,742 ERROR [stderr] (http--0.0.0.0-8080-4) at javax.faces.event.SystemEvent.<init>(SystemEvent.java:71)
18:42:12,746 ERROR [stderr] (http--0.0.0.0-8080-4) at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:73)
18:42:12,748 ERROR [stderr] (http--0.0.0.0-8080-4) at javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:73)
18:42:12,749 ERROR [stderr] (http--0.0.0.0-8080-4) at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:271)
18:42:12,750 ERROR [stderr] (http--0.0.0.0-8080-4) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:257)
18:42:12,752 ERROR [stderr] (http--0.0.0.0-8080-4) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
18:42:12,755 ERROR [stderr] (http--0.0.0.0-8080-4) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
18:42:12,756 ERROR [stderr] (http--0.0.0.0-8080-4) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
18:42:12,756 ERROR [stderr] (http--0.0.0.0-8080-4) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
18:42:12,757 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
18:42:12,758 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
18:42:12,759 ERROR [stderr] (http--0.0.0.0-8080-4) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
18:42:12,760 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
18:42:12,763 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
18:42:12,765 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
18:42:12,766 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
18:42:12,767 ERROR [stderr] (http--0.0.0.0-8080-4) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
18:42:12,768 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
18:42:12,768 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
18:42:12,769 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
18:42:12,770 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
18:42:12,771 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
18:42:12,774 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
18:42:12,774 ERROR [stderr] (http--0.0.0.0-8080-4) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
18:42:12,775 ERROR [stderr] (http--0.0.0.0-8080-4) at java.lang.Thread.run(Thread.java:745)
xhtml is:
<h:form id="frmItemsPage">
<p:panel id="tblPanel">
<p:dataTable widgetVar="TbItems" id="tbItemsList" var="row"
value="#{unavailableItems.itemsModel}" scrollable="true"
scrollRows="20"
liveScroll="true" rowKey="#{row.upId}"
lazy="true"
scrollHeight="500" style="width:98%; margin:0 auto;"
emptyMessage="No Items." editable="true" editMode="cell" resizableColumns="true"
rowIndexVar="rowIndex">
<p:ajax event="cellEdit" listener="#{unavailableItems.onCellEdit2}" />
<p:column width="12" style="text-align:right;">
<f:facet name="header">
<h:outputText id="codeLabel" value="Item Code" />
</f:facet>
<h:outputText id="itemCode" value="#{row.itemCode}">
</h:outputText>
</p:column>
<p:column headerText="Description" width="115">
<p:cellEditor>
<f:facet name="output"><h:outputText id="desOutpt" value="#{row.description}" />
</f:facet>
<f:facet name="input">
<p:selectOneMenu id="desciprtion" value="#{row.description}"
required="false" style="width:185px;">
<f:selectItems value="#{unavailableItems.descriptions}" />
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<f:facet name="footer"></f:facet>
</p:dataTable>
</p:panel>
</h:form>
and my bean is:
#ManagedBean(name = "unavailableItems")
#ViewScoped
public class UnavailableItemsBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<String> descriptionsStrings;
private List<SelectItem> descriptions;
private LazyDataModel<Item> itemsModel;
public UnavailableAssetsPageBean() {
this.loadItems();
this.setDescriptionsStrings(DescriptionDAO.getInstance().getAllDescriptions());
}
public void loadItems() {
this.itemsModel = new LazyDataModel<Item>() {
private static final long serialVersionUID = 1L;
#Override
public List<Item> load(int first, int pageSize, String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
List<Item> items = ItemDAO.getInstance().getUnavailableItems(first,
pageSize + first);
int totalRecords = ItemDAO.getInstance().getUnavailableItemsCount();
itemsModel.setRowCount(totalRecords);
RequestContext.getCurrentInstance().update("frmItemsPage:tbItemsList");
return items;
}
};
}
public void onCellEdit2(CellEditEvent event) {
DataTable dataTable = (DataTable) event.getSource();
Item item = (Item) dataTable.getRowData();
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
System.out.println("old value: "+oldValue);
System.out.println("new value: "+newValue);
}
public List<SelectItem> getDescriptions() {
setDescriptions();
return descriptions;
}
public void setDescriptions() {
descriptions = new ArrayList<SelectItem>();
descriptions.add(new SelectItem("", ""));
for (String des : descriptionsStrings) {
descriptions.add(new SelectItem(des, des));
}
}
public List<String> getDescriptionsStrings() {
return descriptionsStrings;
}
public void setDescriptionsStrings(List<String> descriptionsStrings) {
this.descriptionsStrings = descriptionsStrings;
}
public LazyDataModel<Item> getItemsModel() {
return itemsModel;
}
public void setItemsModel(LazyDataModel<Item> itemsModel) {
this.itemsModel = itemsModel;
}
}
the error sometimes also appears while scrolling (live scroll). I am using primefaces 5.3, JSF 2.0.4, JBoss AS-7.1.1.Final
I've got a question regarding Primefaces orderList.
I have an orderList which looks like this:
<p:orderList id="technikersTable"
value="#{systemlandschaftRessourceHandler.entity.technikers}"
var="_techniker"
itemValue="#{_techniker}"
converter="#{entityConverter}"
controlsLocation="none">
<f:facet name="caption">Techniker</f:facet>
<p:column>
<p:commandButton styleClass="colButton"
icon="ui-icon-trash"
action="#{systemlandschaftRessourceHandler.removeTechniker(_techniker)}"
update=":systemLandschaftTabView:sysObjektDetailPanelForm:technikersTable"/>
</p:column>
<p:column style="width:75%;">
<p:outputLabel value="#{_techniker.verantwortlich.displayName}" />
</p:column>
</p:orderList>
My problem is, that the commandButton in the first column throws a null pointer exception.
The request never reaches my bean.
Is it possible that the commandButton is not working inside the orderList?
I have done the same thing with dataTables a lot of time successfully.
StackTrace:
ERROR 2013-10-15 14:37:55,009 [MmnetExceptionHandler] Fehler auf der Seite: /views/protected/systemlandschaft/systemlandschaftHome.xhtml, isAjaxRequest=true
ERROR 2013-10-15 14:37:55,010 [MmnetExceptionHandler] [SCUE070] Allgemeiner Anwendungsfehler! : java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:319)
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:185)
at org.apache.el.parser.AstValue.invoke(AstValue.java:257)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at org.apache.myfaces.extensions.cdi.jsf.impl.security.SecurityViolationAwareActionListener.processAction(SecurityViolationAwareActionListener.java:56)
at org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewControllerActionListener.processAction(ViewControllerActionListener.java:68)
at org.apache.myfaces.extensions.cdi.jsf.impl.listener.action.CodiActionListener.processAction(CodiActionListener.java:58)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIData.broadcast(UIData.java:1093)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at de.company.mmnet.sessioninfo.HttpSessionUserFilter.doFilter(HttpSessionUserFilter.java:42)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)
at java.lang.Thread.run(Thread.java:722)
DEBUG 2013-10-15 14:37:55,094 [EntityManagerProducer] EntityManager geschlossen.
You can use a commandbutton inside an orderList. Your problem is that you are using the #{_techniker} var as a parameter. The action property is evaluating the EL expression on serverside when you click the button, and this is causing the nullpointer.
It does indeed work in a dataTable, but the datatable component is designed differently.
I would consider using a different component, but if you really need to use the orderlist, you could use the p:remoteCommand for sending the id of the techniker to the backing bean.
Primefaces RemoteCommand
Expanding LStrike comment, here is the relevant content from https://forum.primefaces.org/viewtopic.php?f=3&t=34424
Bean:
#ManagedBean
#RequestScoped
public class TechnikersBean {
public List<String> getPersons() {
List<String> result = new ArrayList<String>();
result.add("Person1");
result.add("person2");
return result;
}
public void setPersons(List<String> persons) {
}
public void removeTechniker(ActionEvent event) {
Map<String, String> parameterMap = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap();
String name = parameterMap.get("name");
System.out.println(name);
}
}
xhtml:
<h:form id="form">
<p:remoteCommand name="removeTechniker" actionListener="#{technikersBean.removeTechniker}"
out="technikersTable" />
<p:orderList id="technikersTable"
value="#{technikersBean.persons}"
var="_techniker"
itemValue="#{_techniker}"
controlsLocation="none">
<f:facet name="caption">Techniker</f:facet>
<p:column>
<p:commandButton styleClass="colButton"
icon="ui-icon-trash"
type="button" onclick="removeTechniker([{name:'name', value:'#{_techniker}'}]);">
</p:commandButton>
</p:column>
<p:column style="width:75%;">
<p:outputLabel value="#{_techniker}"/>
</p:column>
</p:orderList>
</h:form>
Basically, a remoteComand is called by a client side callback to send the required information to the bean function.
I would like to create a form to simply modify the fields of some project entity.
To do so I created a request scoped bean and a view that uses together with a converter to tell the bean which entity is being edited.
Bean
#Named
#RequestScoped
public class Bean {
private Project selectedProject;
public void setSelectedProject(Project project) {
selectedProject= project;
}
public Project getSelectedProject() {
return selectedProject;
}
public String save() {
// Persist selectedProject...
return null;
}
}
View
<ui:composition template="/templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:define name="metadata">
<f:metadata>
<f:viewParam id="projectParam" name="project"
value="#{bean.selectedProject}" converter="#{projectConverter}" />
</f:metadata>
</ui:define>
<ui:define name="content">
<h:form id="projectForm">
<p:panel header="Project details">
<h:panelGrid columns="2">
<p:outputLabel for="title" value="Title" />
<h:inputText id="title" value="#{bean.selectedProject.title}" />
<p:outputLabel for="desc" value="Description" />
<h:inputTextarea id="desc" value="#{bean.selectedProject.description}" />
</h:panelGrid>
<p:commandButton id="submitButton" type="submit"
value="Save" action="#{bean.save}">
<f:param name="project" value="#{bean.selectedProject.id}" />
</p:commandButton>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
Loading the view initially works fine, the chosen project is loaded and the form fields are filled with the project's properties. However when saving the form I receive the following stack trace:
11:00:58,837 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--0.0.0.0-8080-3) /user/project.xhtml #42,70 value="#{bean.selectedProject.title}": Target Unreachable, 'selectedProject' returned null: javax.el.PropertyNotFoundException: /user/project.xhtml #42,70 value="#{bean.selectedProject.title}": Target Unreachable, 'selectedProject' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIInput.validate(UIInput.java:960) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIInput.processValidators(UIInput.java:698) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.primefaces.component.panel.Panel.processValidators(Panel.java:297) [primefaces-3.5.jar:]
at javax.faces.component.UIForm.processValidators(UIForm.java:253) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.primefaces.component.layout.Layout.processValidators(Layout.java:246) [primefaces-3.5.jar:]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_51]
While debugging the problem I found out that the converter is indeed called, but the returned project is not set on the bean before the above lifecycle occurs. If I return a dummy project in the bean, everything works fine, the selected project is eventually set I can be persisted with the updated values.
Is this expected behaviour? Can I get this running without returning a dummy project?
I've seen approaches with view scoped beans. Since we're using CDI I'd prefer to stick to javax.enterprise annotations. If you think the rest of the code (template, converter) are of any relevance I'm happy to add them.
It is an expected behaviour. With <f:viewParam /> you're setting the value in the bean during GET request. Value is set, that's why your page is rendered properly, however your bean is #RequestScoped, so its state is lost from one request to the other one. When you perform the POST request with your p:commandButton, its value is actually null. To solve it, you should use #ViewScoped bean.
I'am trying to run simple example of my web app. I'am using JSF + CDI bean.
My facelet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:outputLabel value="#{testBEan.tekst}" />
<h:form>
<h:commandButton actionListener="#{testBEan.dodajCos}" value="guzik" />
</h:form>
</h:body>
</h:html>
My CDI BEAN:
package pl.com.hrms.pages;
import javax.faces.bean.ApplicationScoped;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
#Named
#ApplicationScoped
public class TestBEan
{
String tekst = "1";
public String getTekst()
{
tekst = tekst+"2";
return tekst;
}
public void setTekst(String tekst)
{
this.tekst = tekst;
}
public void dodajCos(ActionEvent e)
{
tekst = tekst+"p";
}
}
When i run it web browser show the label with value "12" and button. If i press the button threse is an Exception throwing
19:05:05,903 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/H&RMSWeb].[Faces Servlet]] (http-0.0.0.0-0.0.0.0-8080-1) Servlet.service() for servlet Faces Servlet threw exception: javax.faces.application.ViewExpiredException: viewId:/pages/test.jsf - View /pages/test.jsf could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:205) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_03]
If i use #ManagedBean instead of of #Named it works fine (i mean pressing the button causes adding "p" to the label).
I have beans.xml file in a WEB-INF.
Does anyone have idea what am i doing wrong?
Please do not mix the JSF Scope and CDI Scope.
The JSF
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
#ApplicationScoped
#ManagedBean
public class MyBean {
}
The CDI
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
#ApplicationScoped
#Named
public class MyBean {
}
I hope this may help.
I am working on small project and after everything was correctly working suddenly I started to get a javax.el.PropertyNotFoundException: and I still don't what caused the problem, the only changed that I did to the code between its last working version, was a new xhtml, document, that called the categoryController. I don't really know what happened and don't know how to approach the solution. Does anyone has a idea how to tackle this?
I did some research and found that adding the beans.xml, however, I do have have the beans.xml before the problem happened. This is the content of 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>
This is the 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";
}
This is the form that is being called:
<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>
This is the complete stack I'm getting:
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)
EDIT:
#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;
}
The exception says, the property of your bean could not be found. Do you have correct and visible getter/setter methods for category in your bean and the field name in the category object?
Edit:
I just saw, the PropertyNotFoundException does refer to the bean itself, not to fields in the bean. Does your bean have a name? Your #Named should be something like #Named("categoryController") to be found in the context.