IndexOutOfBoundsException after switching from myfaces to mojarra - jsf-2

I was forced to switch from myfaces (2.1.7) to mojarra (2.1.7). After this I'm getting exceptions like this one below all over the place.
I'm submitting a form, that gives me validation errors. This is correct so far. I submit the form again, that gives me validation errors. This is correct so far. Now I submit the form again and I get the IndexOutOfBoundsException.
javax.faces.FacesException: Unexpected error restoring state for component with id someForm:someField. Cause: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1.
at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:272)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1612)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:251)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:453)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:142)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
at javax.faces.component.UIInput.restoreState(UIInput.java:1411)
at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:264)
... 35 more
I googled this, but haven't found any clue yet.
Jonny

The stacktrace hints that you're using PrimeFaces.
This problem is known in older versions of PrimeFaces and is actually a bug in PrimeFaces, not in Mojarra. Make sure that you're using the latest PrimeFaces version. As of now that's 2.2.1 when you're using PF2 or 3.2 when you're using PF3.

I have the exact same problem and it is easy to reproduce.
You can reproduce it with the following classes:
Validator:
#FacesValidator("testValidator")
public class TestValidator implements Validator {
#Override
public void validate(FacesContext fc, UIComponent uic, Object o) throws ValidatorException {
if (!(o instanceof Integer)) {
throw new ValidatorException(new FacesMessage("validation message!"));
}
}
}
FacesComponent:
#ListenerFor(systemEventClass = PreValidateEvent.class)
#FacesComponent("testField")
public class TestField extends UIComponentBase implements NamingContainer {
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
#Override
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
super.processEvent(event);
UIComponent findComponent = findComponent("input");
if (findComponent instanceof UIInput) {
UIInput i = (UIInput) findComponent;
boolean notFound = true;
for (Validator v : i.getValidators()) {
if (v instanceof TestValidator) {
notFound = false;
}
}
if (notFound) {
i.addValidator(new TestValidator());
}
}
}
}
Custom Component:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<cc:interface componentType="testField">
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
field: <h:inputText id="input" value="#{testController.inputText}" />
</cc:implementation>
</html>
ManagedBean:
#SessionScoped
#Named("testController")
public class TestController implements Serializable {
private static final long serialVersionUID = 1L;
private String inputText = "";
public TestController() {
}
public void actionListener(ActionEvent event) {
}
public String myAction() {
return "";
}
public String getInputText() {
return inputText;
}
public void setInputText(String inputText) {
this.inputText = inputText;
}
}
index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://java.sun.com/jsf/composite/test"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Jsf Problem</title>
</h:head>
<h:body>
<h:form>
<h:messages />
<t:field />
<h:commandButton value="Submit" action="#{testController.myAction()}" />
</h:form>
</h:body>
</html>
The inputText inside the custom component field gets an new Validator added at PreValidateEvent inside the processEvent() method.
If the submit button is now pressed three times in a row with an validation error the ArrayIndexOutOfBoundException will be thrown. I tried to debug and found out that the exception is throwed inside AttachedObjectListHolder#restoreState(FacesContext, Object), afterward my eclipse debugger got crazy...
I think this is a JSF Bug!
I wanted to leave a comment but I'am not allowed yet... :(

Related

why when I start my JSF2 application on jboss EAP 6.3 it doesn't display in the inputText the value i set in the Managed Bean?

i have a simple file.xhtml in a JSF2.2 application, that's its code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ez="http://xmlns.jcp.org/jsf/composite/ezcomp">
<head>
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:form id="greeting">
<h:inputText id="num1" value="#{jSFeatBean.num1}" />
<h:inputText id="num2" value="#{jSFeatBean.num2}"/>
<h:commandButton type="submit"
value="Submit"
action="#{jSFeatBean.addNumbers()}"/>
<h:outputText value="#{jSFeatBean.result}"/>!
</h:form>
</f:view>
</body>
</html>
and this is my #ManagedBean:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean(name = "jSFeatBean", eager = true)
#SessionScoped
public class JSFeatursBean {
private String result;
public int num1 = 1;
int num2;
public int getNum1() {
return num1;
}
public void setNum1(int num1) {
this.num1 = num1;
}
public int getNum2() {
return num2;
}
public void setNum2(int num2) {
this.num2 = num2;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public Object addNumbers() {
setResult("il risultato e': "+ Integer.toString(num1+num2));
return null;
}
}
after i start jboss from Eclipse the browser display all elements of my file.xhtml properly but the values in the first (id = num1) inputText is 0 and not 1. Why this happens? If i put new values in the inputText boxes everything works fine, so i think that the Mbean is instantiated and working.
I have the same problem with a h:SelectOneListbox element, that doesn't show the list i create when i call the MBean constructor.
It looks like the MBean gets instatiated right after the display of html page.
The code looks fine to me with just one thing that might cause the problem.
Try remove "eager = true" attribute in your ManagedBean annotation. "eager = true" only works with ApplicationScoped Beans.

jsf2 ViewScoped bean initialization

I'm new to jsf technology and I'm trying to understand when and how the ViewScoped jsf bean is initialized.
I have a sample app with 2 beans
ApplicationScopedBean.java
#ManagedBean
#ApplicationScoped
public class ApplicationScopedBean implements Serializable {
private int incrementedCounter =0;
public int getIncrementedCounter() {
incrementedCounter += 1;
return incrementedCounter;
}
}
ViewScopedBean.java
#ManagedBean
#ViewScoped
public class ViewScopedBean implements Serializable {
#ManagedProperty(value = "#{applicationScopedBean}")
private ApplicationScopedBean applicationScopedBean;
private int reincarnationNumber;
private int accessCounter;
#PostConstruct
public void initialize() {
accessCounter = 0;
reincarnationNumber = applicationScopedBean.getIncrementedCounter();
System.out.println("Initializing viewScoped stateManager with reincarnationNumber value = " + String.valueOf(reincarnationNumber));
}
public void noAction() {
//do nothing
}
public int getReincarnationNumber() {
return reincarnationNumber;
}
public int getAccessCounter() {
accessCounter += 1;
return accessCounter;
}
public ApplicationScopedBean getApplicationScopedBean() {
return applicationScopedBean;
}
public void setApplicationScopedBean(ApplicationScopedBean applicationScopedBean) {
this.applicationScopedBean = applicationScopedBean;
}
}
ApplicationScoped bean is created only once for the application launch.
Every time ViewScoped bean is being created, the reincarnationNumber is being increased by 1.
I also have a simple jsf page to display these values:
index.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>View Scoped bean test</title>
</h:head>
<h:body>
<h:form>
<p>ViewScoped bean reincarnation is <h:outputText value="#{viewScopedBean.reincarnationNumber}"/></p>
<p>ViewScoped bean access counter is <h:outputText value="#{viewScopedBean.accessCounter}"/></p>
<h:commandButton type="submit" value="no action" action="#{viewScopedBean.noAction()}"/>
<h:commandButton type="submit" value="reload this page" action="index"/>
</h:form>
</h:body>
</html>
The problem:
When I launch the application the first time, I already have reincarnationNumber value equal to 3.
In other words, I have this info displayed in browser:
ViewScoped bean reincarnation is 3
ViewScoped bean access counter is 1
Why is that?
Why ViewScoped bean has bean created 3 times?
Thanks in advance!
SOLUTION
As it is stated in the comments, the cause was "start browser" checkbox checked in Run Configurations in my IntelliJ IDEA. The trick is when browser is auto-started from IDE I have viewScopedBean initialized 3 times.
It's not created 3 times, just called the getter several times... and that's because... you can check this answer:
Why JSF calls getters multiple times

Deltaspikes #WindowScoped working with TomEE?

I'm struggeling how to get Deltaspikes #WindowScoped working with TomEE (did try 1.5.2, 1.5.3-SNAPSHOT and 1.6.0-SNAPSHOT)
Its a very minimal war, with deltaspike 0.4 core+jsf dependencies.
Now, i did create a HelloWorldBean like this:
#Named("HW")
#WindowScoped
public class HelloWorldBean implements PassivationCapable,Serializable{
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#PostConstruct
public void test() {
System.out.println("Bean did get constructed");
}
....
}
There's an empty beans.xml, empty faces-config.xml and a very minimal web.xml.
on a very simple page i have.
<h:form>
<h:inputText value="#{HW.name}"></h:inputText>
<h:commandButton value="Welcome Me" actionListener="#{HW.printIt}"></h:commandButton>
</h:form>
The page works fine, a windowId is added to the request and when i refresh the page i see that the bean is not instanciated (i.e. test() gets only called once).
But as soon i press the commandButton i get an ContextNotActiveException exception:
org.apache.myfaces.view.facelets.el.ContextAwareELException: javax.el.ELException: Error reading 'name' on type de.glauche.beans.HelloWorldBean$$OwbNormalScopeProxy0
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:104)
at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:249)
at javax.faces.component.UIOutput.getValue(UIOutput.java:67)
at javax.faces.component.UIInput.getValue(UIInput.java:151)
at javax.faces.component.UIInput.validate(UIInput.java:618)
at javax.faces.component.UIInput.processValidators(UIInput.java:274)
at javax.faces.component.UIForm.processValidators(UIForm.java:213)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1456)
at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:74)
at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1563)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1412)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:812)
at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:38)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeLifecycleWrapper.execute(DeltaSpikeLifecycleWrapper.java:75)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: javax.el.ELException: Error reading 'name' on type de.glauche.beans.HelloWorldBean$$OwbNormalScopeProxy0
at javax.el.BeanELResolver.getValue(BeanELResolver.java:68)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:58)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at org.apache.webbeans.el22.WrappedValueExpression.getValue(WrappedValueExpression.java:70)
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96)
... 35 more
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation #WindowScoped does not exist within current thread
at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:299)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:88)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
at de.glauche.beans.HelloWorldBean$$OwbNormalScopeProxy0.getName(de/glauche/beans/HelloWorldBean.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:64)
... 41 more
Am i missing something obvious? Or is it a bug in DeltaSpike? (or TomEE?)
This Exception indicates that the windowId is not set in the WindowContext. Did you add the proper DeltaSpike tag into your fragment?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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:c="http://java.sun.com/jsp/jstl/core"
xmlns:ds="http://deltaspike.apache.org/jsf">
<h:head></h:head>
<h:body>
<ds:windowId/>
...
The ds:windowId part is important.
You can debug into DeltaSpikeLifecycleWrapper#execute to see if the windowId gets detected properly.

PrimePush counter implementation

I am trying to implement prime push counter in my project. I am using PrimeFaces3.5, Jboss7.0 and Eclipse Indigo version.
I have added jars related to prime push:
atmosphere-annotations-1.0.1.jar
atmosphere-compat-jbossweb-1.0.1.jar
atmosphere-compat-tomcat-1.0.1.jar
atmosphere-compat-tomcat7-1.0.1.jar
atmosphere-runtime-1.0.1.jar
primefaces-3.5.jar and jsf and slf4j jars
My xhtml code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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">
<h:head></h:head>
<h:body>
<h:form id="form">
<h:outputText id="out" value="#{pushBean.count}" />
<p:commandButton value="Click" actionListener="#{pushBean.increment}" />
</h:form>
<p:socket onMessage="handleMessage" channel="/counter" />
<script type="text/javascript">
function handleMessage(data) {
$('.display').html(data);
}
</script>
</h:body>
</html>
My managed bean:
#ManagedBean(name = "pushBean")
#ApplicationScoped
public class PushBean {
public PushBean() {
}
private int count;
public int getCount() {
return this.count;
}
public void setCount(final int count) {
this.count = count;
}
public synchronized void increment() {
this.count++;
PushContext pushContext = PushContextFactory.getDefault().getPushContext();
pushContext.push("/counter", String.valueOf(this.count));
}
}
When I click the button in UI, the count is incremented on the server, but it is not reflected in UI automatically, because it is not updated. But when I refresh the page, the count is incremented as expected.
Exception I am getting is:
13:00:02,298 ERROR [stderr] (http--0.0.0.0-8080-5) [http--0.0.0.0-8080-5] ERROR org.atmosphere.cpr.AtmosphereFramework - AtmosphereFramework exception
13:00:02,298 ERROR [stderr] (http--0.0.0.0-8080-5) java.lang.IllegalStateException: The servlet or filters that are being used by this request do not support async operation
This exception happens when your web app is run in Servlet 3 compliant containers. The correct web.xml must have the async-supported element set to true, for example:
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
Reference: Installing Atmosphere
I'm not very sure about push framework but i think the problem is with your javascript.
you are trying to refresh ".display" control but there is nothing like .display.
Try '.out' instead of .display

PrimeFaces autocomplete 3.3.1 not working for me

I have set up a test page using the PrimeFaces showcase labs code to test out the component. When I start typing in the autocomplete box, I receive an exception. Note that depending on whether I have client or server state saving turned on, the exceptions are different. I am using WebLogic 11g, PrimeFaces 3.3.1, Apache Tomahawk 1.1.13 and Mojarra 2.1.8. Any ideas?
AutoCompleteBean.java
#ManagedBean
public class AutoCompleteBean {
private String txt1;
public List<String> complete(String query) {
List<String> results = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
results.add(query + i);
}
return results;
}
public String getTxt1() {
return txt1;
}
public void setTxt1(String txt1) {
this.txt1 = txt1;
}
}
autocomplete.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:form id="form">
<p:panel header="AutoComplete" toggleable="true" id="panel">
<h:outputLabel value="Simple :" for="acSimple" />
<p:autoComplete id="acSimple" value="#{autoCompleteBean.txt1}"
completeMethod="#{autoCompleteBean.complete}"/>
</p:panel>
</h:form>
</html>
Exception when javax.faces.STATE_SAVING_METHOD = client
Jul 3, 2012 10:00:03 AM com.sun.faces.renderkit.ClientSideStateHelper doGetState
SEVERE: Not in GZIP format
java.io.IOException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:137)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
at com.sun.faces.renderkit.ClientSideStateHelper.doGetState(ClientSideStateHelper.java:244)
at com.sun.faces.renderkit.ClientSideStateHelper.getState(ClientSideStateHelper.java:211)
at com.sun.faces.renderkit.ResponseStateManagerImpl.getState(ResponseStateManagerImpl.java:100)
at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagemen
tStrategy.java:331)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:513)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:142)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Exception when javax.faces.STATE_SAVING_METHOD = server
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1937)
at com.sun.faces.renderkit.ServerSideStateHelper.getState(ServerSideStateHelper.java:277)
at com.sun.faces.renderkit.ResponseStateManagerImpl.getState(ResponseStateManagerImpl.java:100)
at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:331)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:513)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:142)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
The problem was caused by the Apache Tomahawk library. Once I removed the Tomahawk JAR (I luckily can do without it), the issue went away. It appears as though Tomahawk and PrimeFaces do not play nicely together, which is a shame. I was using the latest Tomahawk JAR as of today (1.1.13).

Resources