Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:41:58+00:00 2026-06-07T12:41:58+00:00

I am having problems with a pure JSF 2 page. When loading the page

  • 0

I am having problems with a pure JSF 2 page. When loading the page two inputText and one select is shown. There’s a validation field to the right of each. The two inputs are required fields, while the select always has a selection, so it doesn’t validate at all (at least it shouldn’t).

Here’s a screenshot:

enter image description here

This is what is displayed when the Create button was clicked. When re-hitting the Create button the following popup appears:

enter image description here

OK, nothing without code, here’s the 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:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
  <h:head>
  </h:head>
  <h:body>
    <h:form>
      <h:panelGrid columns="3" id="base-data-grid">
        <h:outputLabel value="Name:*" for="name-input" />
        <h:inputText value="#{testBean.name}"
                     requiredMessage="Name required!"
                     id="name-input">
          <f:validateRequired />
        </h:inputText>
        <h:message for="name-input" style="color: red;" />
        <h:outputLabel value="Code:*" for="code-input" />
        <h:inputText value="#{testBean.code}"
                     requiredMessage="Code required!"
                     id="code-input">
          <f:validateRequired />
        </h:inputText>
        <h:message for="code-input" style="color: red;" />
        <h:outputLabel value="Location:" for="location-select" />
        <h:selectOneMenu value="#{testBean.location}"
                         converter="#{testConverter}"
                         id="location-select">
          <f:selectItems value="#{testBean.locations}"
                         var="l"
                         itemValue="#{l}"
                         itemLabel="#{l.name}" />
        </h:selectOneMenu>
        <h:message for="location-select" style="color: red;" />
      </h:panelGrid>
      <h:panelGrid columns="1">
        <h:commandButton value="Create"
                           action="#{testBean.create}">
          <f:ajax execute="base-data-grid" render="base-data-grid lalala" />
        </h:commandButton>
      </h:panelGrid>
      <h:messages id="lalala" />
    </h:form>
  </h:body>

</html>

The location class for the select (just a name):

public class Location
{
    private String name;
    public Location(String name)
    {
        this.name = name;
    }
    public String getName()
    {
        return name;
    }
}

The converter (as CDI version):

import javax.enterprise.context.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named
@RequestScoped
public class TestConverter implements Converter
{
    private static final Logger log = LoggerFactory.getLogger(TestConverter.class);

    @Inject
    private TestBean testBean;

    @Override
    public Object getAsObject(FacesContext arg0, UIComponent arg1, String name)
    {
        log.info(getClass().getSimpleName() + ".getAsObject: " + name);

        return testBean.getLocationFor(name);
    }

    @Override
    public String getAsString(FacesContext arg0, UIComponent arg1, Object obj)
    {
        log.info(getClass().getSimpleName() + ".getAsString: " + obj);

        return ((Location)obj).getName();
    }
}

And the test bean:

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named
@SessionScoped
public class TestBean implements Serializable
{
    private static final Logger log = LoggerFactory.getLogger(TestBean.class);

    private String name;
    private String code;

    private Location location;
    private List<Location> locations;

    @PostConstruct
    public void init()
    {
        locations = new ArrayList<Location>();

        locations.add(new Location("Berlin"));
        locations.add(new Location("London"));
        locations.add(new Location("New York"));
        locations.add(new Location("Moscow"));
        locations.add(new Location("Bejing"));

        location = locations.get(2);
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getCode()
    {
        return code;
    }

    public void setCode(String code)
    {
        this.code = code;
    }

    public Location getLocation()
    {
        return location;
    }

    public void setLocation(Location location)
    {
        this.location = location;
    }

    public List<Location> getLocations()
    {
        return locations;
    }

    public void setLocations(List<Location> locations)
    {
        this.locations = locations;
    }

    public void create()
    {
        log.info("Creating new whatever...");
    }

    // for converter to mimic DB query
    public Location getLocationFor(String name)
    {
        for ( Location location : locations )
        {
            if ( location.getName().equals(name) )
            {
                return location;
            }
        }

        return null;       
    }

}

As you can see, there’s not much the page is supposed to do. Validate the two input fields, display the select and call testBean.create if all is validated fine.

However, as soon as the validation has run once, each subsequent Create button click will cause that serverError.

NOTE, that if you remove the f:selectItems or the h:selectOneMenu entirely, the page will work as expected. This is what makes the whole thing so strange actually…

I have no idea what is going on here. Does anybody know what’s wrong?

I have attached a JBoss AS 7 test app here: https://community.jboss.org/thread/202501 (dupe post, sorry need a lot of help).

Please have a look at this extremely weird IllegalStateException. There’s not even something in the JBAS server.log…

PS: the Mojarra version is 2.1.7 of course (the one that comes with JBoss AS 7.1.1.Final)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:42:00+00:00Added an answer on June 7, 2026 at 12:42 pm

    Your problem is that the Location needs to be serializable
    (implement the java.io.Serializable interface)

    the f:validateRequired tag causes the required-validation to be performed by ajax.

    During the RestoreView-phase of this ajax-request, the runtime encounters an InstantiationException due to the Location not being Serializable.

    I do honestly not know why the error including stacktrace is not logged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having problems with the combining of two statements in a controller. Both statements work
Im having problems with displaying ONLY some elements ONLY on print page. For example
I'm having some problems using Sinatra with Capybara. I want to test a pure
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume
Im having problems with a method in a class file: public static function getPageLeft($pid)
Im having problems getting at the HTML5 video tag with jQuery. Here is my
Im having problems with classpaths. I have used them before with import but I'm
im having problems starting a codeigniter project, the problem is that when i do
im having problems on how to save the content of an array in an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.