NullPointerException from RestoreViewPhase.notifyAfter - jsf

I'm getting the following error whenever I try to view JSF pages that contain forms.
java.lang.NullPointerException
com.sun.faces.lifecycle.RestoreViewPhase.notifyAfter(RestoreViewPhase.java:288)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
What does this mean?
This problem started when I tried to use validators on my form fields. So I removed all the validators, but still the problem is not going away.
Thanks for the help.

Could be this logged issue: http://java.net/jira/browse/JAVASERVERFACES-1764
If that is the case then it should be fixed in JSF version 2.1.

Related

Bean lost their object values when change the tab on tabview and refresh the page

i hope you can help me with that!!!
I can't offer deeper examples but i can try to explain or reproduce something similar on notepad to show you.
Imagine that i've a .xhtml page with tabview component and two tabs inside. When i press "F5" without change between these tabs my page works normally , but if i change the active tab and hit F5, the java bean on the backend get lost it values and can't get parameters from the JSF context.
Could you imagine something about it ?
OOOpps... i had almost forget to mention that my java bean belongs to the ViewScoped.
An example of the stackTrace .:
javax.el.ELException: //C:/work/project/.metadata/.plugins/org.eclipse.core.resources/.projects/MyProject/beadep/dev_domain/webProject/report/financial/edition/financial_data.xhtml #23,68 value="#{financialDataBean.customerData.customerGroups}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
...
Caused by: javax.el.ELException: java.lang.NullPointerException

Null Pointer Exception in render response phase, JSF/Primefaces

In server log multiple errors can be found like below
java.lang.NullPointerException at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:95)
What can be the possible reason for this? Though I tried to recreate in I am unable to recreate after several attempt. Any possible reason or any idea related to this issue?
I need to understand why can we get null pointer exception while rendering response in JSF/Primeface?
primefaces v.3.4.1
javax.faces v.2.1.18
if I check the source code of JSF issue is at this line of source code
ViewDeclarationLanguage vdl =
vh.getViewDeclarationLanguage(facesContext,
facesContext.getViewRoot().getViewId());
javax.faces.STATE_SAVING_METHOD is set to server.
Check you xhtml file for any not closed tags or other xml/html issues. For example divs. Id your IDE doesn't do that, then change IDE or use online XML validators.

Does RichFaces 4.0 contain notifyMessages?

I am following this link to learn about richfaces: http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=notify&sample=notifyMessages&skin=blueSky
But the problem is, when i try rich:notify or rich:notifyMessages, i get an error saying that "The component library http://richfaces.org/rich does not contain component notifyMessages". Can anyone tell me why? I can use other components of richfaces but there is no notify component here.
Thanks
rich:notify* components where introduce in RichFaces 4.1.
Refer to docs:
http://docs.jboss.org/richfaces/latest_4_0_X/Component_Reference/en-US/html/ (rich:notify is not listed)
http://docs.jboss.org/richfaces/latest_4_1_X/Component_Reference/en-US/html/ (rich:notify is there)

JSF 2 - Using a custom action-listener to reset ajax submitted values so new values are pulled from model attributes

I'm using JSF 2 Mojarra, RichFaces 4.1, and EL 2.2, deployed to a Tomcat 7 server.
On my page, I have two a4j:regions contained in the same form. The top region is a dataTable list of entities. The bottom region is a detail editor panel. You select an entity from the list, and its details load in the edit panel. The detail panel has its own validation rules and submit buttons. I've now run into the reasonably well-known issue of JSF not resetting the submitted values with validation errors when I load a second entity into the detail form.
In researching to solve this problem, I came across this blog from BalusC. He breaks the reset problem down very well and recommends this JSF 2 action-listener to solve the issue.
I incorporated the ResetInputAjaxActionListener into my project as a action-listener defined in my faces-config.xml. Now, however, the code is failing where without the listener, it is working (just not resetting the submitted/local/model values).
My JSF page contains a dataTable and each row has an edit commandLink to load the row's entity into the editor:
<a4j:commandLink action="#{editController.load(entity.id)}" render="#form" execute="#this" value="Edit"/>
Since I'm using EL 2.2, I'm passing the entity's primary key directly into the load method. Without the action-listener, this works as expected. However, when I enable the action-listener, the code throws the following exception:
Caused by: javax.faces.FacesException: #{editController.load(entity.id)}: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
at com.buksoft.automaint.web.util.ResetInputAjaxActionListener.processAction(ResetInputAjaxActionListener.java:163)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at org.richfaces.component.RowKeyContextEventWrapper.broadcast(RowKeyContextEventWrapper.java:104)
at org.richfaces.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:452)
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)
... 51 more
Caused by: javax.faces.el.MethodNotFoundException: java.lang.NullPointerException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:104)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 58 more
Caused by: java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:299)
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:172)
at org.apache.el.parser.AstValue.invoke(AstValue.java:251)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 59 more
It looks to me like the the EL argument value is getting set to null, which is causing a NullPointerException when EL tries to bind null to the action method's parameter, which is expected an Long value.
Now for the part that's really got me stumped. To narrow down the error, I commented out the functionality of the ResetInputAjaxActionListener so that it was basically read-only. What I found is that if these lines of the findAndAddEditableValueHolders() method execute, then the exception is thrown by the ActionListenerImpl.processAction() called after the ResetInputAjaxActionListener completes:
if (target instanceof EditableValueHolder) {
inputs.add((EditableValueHolder) target);
}
else if (context.getIdsToVisit() != VisitContext.ALL_IDS) {
// Render ID didn't point an EditableValueHolder. Visit all children as well.
findAndAddEditableValueHolders(VisitContext.createVisitContext(
context.getFacesContext(), null, context.getHints()), target, inputs);
}
See the findAndAddEditableValueHolders() method in the ResetInputAjaxActionListener class linked above.
And the trouble code is really only in the else if, which really confuses me because it's a recursive call back to the method itself. It's almost if the createVisitContext() method is somehoe modifying the backing view tree. As I said, if I strip out all mutating code that makes any real changes, and just execute this tree visit code (read-only), the exception is thrown down the line.
Can anyone explain how visiting the component tree (and not modifying anything in it), could break the EL method argument functionality?

Core Java Faces - 3rd edition (Cay Horstmann) : Chapter 4 selection tags pg 165 example not working

I'm not sure how i should put this question cos' there are couple of files (.java, .xhtml, etc) involved. Anyway this programs involves couple of checkboxes (selectmanycheckbox) and others. There is a onchange=submit() on this selectmanycheckboxes.
Here's what i noticed:
The generated html for each of those checkboxes there is a onchange=submit(). Kind of funny that by checking a checkboxes, it is submitting the form everytime.
The real issue is when i check one of the checkboxes, there is an error exactly as printed.
======================================================================
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
Caused by:
java.lang.ClassCastException - [I cannot be cast to [Ljava.lang.Object;
I don't understand the [I here. Any idea?
What i did after that was to remove all the checkboxes and submit the form. Still getting the same error.
Any idea?
The source code is available on their site. Your particular code is provided in javaee/ch04/select folder.
The generated html for each of those checkboxes there is a onchange=submit(). Kind of funny that by checking a checkboxes, it is submitting the form everytime.
It's been set by the <h:selectManyCheckbox onchange="submit()" /> in the code example. The onchange attribute is indeed totally unnecessary. It's likely an oversight of the author.
The real issue is when i check one of the checkboxes, there is an error exactly as printed.
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
I don't understand the [I here. Any idea?
The [I is the signature of an int[] type. The exception is telling that an instance of int[] type cannot be cast to an instance of Object[]. This makes in turn no sense, it should work fine. This particular problem is caused by something else.
What i did after that was to remove all the checkboxes and submit the form. Still getting the same error.
The <h:selectManyMenu> in the code example is also bound to an int[] property.
However removing them is not the right solution. It should work fine. Your problem is caused by something else deeper under the hoods. It's likely a bug in the EL implementation used. What servletcontainer make/version are you using? What servlet API version is your web.xml declared to? Did you try upgrading the servletcontainer?
I assume you are trying to run the example on Tomcat 6
Your WEB-INF/lib folder should have only these files: jsf-api.jar, jsf-impl.jar. You can download them from http://javaserverfaces.dev.java.net/
On your Tomcat/lib folder, you should replace the file el-api.jar by the file el-api2.2.jar. You can download it from http://download.java.net/maven/2/javax/el/el-api/2.2/

Resources