3

For my current project I'm working with JSF, Seam and Hibernate and I have an issue with seam.

I created an XHTML-file with an input field (for productionMonth) and I defined a validator on it to ensure the correct user-input. I also enabled ajax support on the field to make the validation more user-friendly.

Then I created my action class (referenced from my XHTML) and added the property 'productionMonth' and the validator that I need.

Now when I deploy this case everything seems just fine. BUT: I enter a value in the productionMonth field and press enter to have my form submitted. Sometimes (when I'm fast enough and my pc is slow enough) I get an exception:

Target Unreachable, identifier 'sateiFileHome' resolved to null"

The strange thing is that

  1. This is only reproducable in IE (I'm using IE8)
  2. When I remove the ajax support tag I don't have the error so it must be really ajax-related

My best guess to the cause of the problem is that an AJAX call and submit are launched at the same time. And because of that one of the calls cannot resolve a reference to the action class. But then why is it only in IE?

I also tried to use the Hibernate validations but still the same issue!

I googled this issue but can't find anything that helps me. Any guesses here?

My action class:

@Name("sateiFileHome")
@Scope(ScopeType.CONVERSATION)
public class SateiFileHome extends CustomHome<Satei> {
    ...
    private Integer productionMonth = 0;
    ...
    public Integer getProductionMonth() {
        return productionMonth;
    }

public void setProductionMonth(Integer productionMonth) {
    this.productionMonth = productionMonth;
}
    ...
/* VALIDATORS */
public void validateProductionMonth(final FacesContext context,
        final UIComponent comp, final Object inputValue)
        throws ValidatorException {
    DateValidator.validateYearMonth(inputValue, false);
    this.productionMonth = Integer.parseInt(String.valueOf(inputValue));
}
    ...
}

My XHTML file:

<s:decorate id="productionMonthField" template="layout/edit.xhtml">
    <ui:define name="label">Production Month</ui:define>
    <h:inputText id="productionMonth" 
            value="#{sateiFileHome.productionMonth}" 
            validator=#{sateiFileHome.validateProductionMonth}
            required="true"
            size="7"
            maxlength="6">
                    <a:support event="onblur" reRender="productionMonthField"/>
    </h:inputText>
</s:decorate>

The exception (only reproducable in IE8):

Caused by javax.el.PropertyNotFoundException with message: "/SateiFile.xhtml @123,48 value="#{sateiFileHome.versionCode}": Target Unreachable, identifier 'sateiFileHome' resolved to null"

And the full stackstrace:

Exception during request processing:
Caused by javax.servlet.ServletException with message: "/SateiFile.xhtml @123,48 value="#{sateiFileHome.versionCode}": Target Unreachable, identifier 'sateiFileHome' resolved to null"
javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)
Caused by javax.el.PropertyNotFoundException with message: "/SateiFile.xhtml @123,48 value="#{sateiFileHome.versionCode}": Target Unreachable, identifier 'sateiFileHome' resolved to null"
com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:92)
com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:188)
com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:301)
javax.faces.component.UIInput.getConvertedValue(UIInput.java:942)
javax.faces.component.UIInput.validate(UIInput.java:868)
javax.faces.component.UIInput.executeValidate(UIInput.java:1072)
javax.faces.component.UIInput.processValidators(UIInput.java:672)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
javax.faces.component.UIForm.processValidators(UIForm.java:235)
org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:447)
org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:240)
org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:463)
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)
dirkvranckaert
  • 1,364
  • 1
  • 17
  • 30
  • You didn't tell what browsers it works properly in. Which browsers did you all try? Did you also try IE9? Are you using latest versions of JSF and Seam? Did you try upgrading to the latest? Some early versions might have browser-specific bugs. – BalusC Oct 12 '11 at 13:09

2 Answers2

2

Putting the bean in the page scope instead of conversation scope solved the problem. We were using conversation scope, but we don't leave the page so we realized that conversation scope is not really needed. Page scope is enough and it solves the problem. Don't ask me why and how, but it works.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
dirkvranckaert
  • 1,364
  • 1
  • 17
  • 30
  • The reason is because you are using temporary conversations. You are updating the field `onchange`, which will send an AJAX request and go through the full JSF lifecycle after every keypress. If your computer is too slow, it tries to submit the form using an old conversationId. The conversation was already killed and all conversation-scoped components are re-initialised. – parasietje Jan 03 '12 at 15:30
0

There are a couple of things I'd try.

1) Should

 validator=#{sateiFileHome.validateProductionMonth}

have quotes around the attribute value?

 validator="#{sateiFileHome.validateProductionMonth}"

2) Work out where the conversation is started and is there indeed a conversation in progress. The fact it is only in IE probably means this isn't the problem.

3) Have you tried adding

immediate="true"

to the ajax tag?

4) You could also try moving the validation to a another class. That would make it a little more usable and the validation would then not be on a conversation scoped bean.

5) You could also implement your own javax.faces.validator.Validator and add that as a tag to your input. This would mean the validator="#{sateiFileHome.validateProductionMonth}" could be replaced.

Hope something here helps.

James DW
  • 1,815
  • 16
  • 21