Version 78

    Page parameters are not working


    A bug in MyFaces in conjunction with server side state saving causes page parameters to loose their values or to not update to new values.

    Switch to client side state saving instead.

    Also be sure to complain in the MyFaces maling list, the bug does not currently seem to have any priority at all.




    I get an error like java.lang.IllegalStateException: Client-id : _id0 is duplicated in the faces tree when using Seam with MyFaces and Facelets


    This is due to a bug in MyFaces. Try upgrading to the latest nightly build. A workaround is to return a non-null outcome from your action method and have a corresponding navigation rule in your faces-config.xml, which forces the view to be re-built.


    Also, you will encounter this error if you forget to include commandButton / commandLink tags inside <h:form> tags. Check your page as well as the template for this potential error.




    I get an exception like java.lang.NullPointerException at javax.faces.webapp.FacesServlet.init( when using Seam with the JSF RI


    Add the following line to web.xml:






    I get an exception like java.lang.NullPointerException javax.faces.webapp.UIComponentTag.setupResponseWriter(


    You have tried to hit a JSF template directly, instead of going via the faces servlet. Adjust your URL to be, for example, {/myView.seam} or {/myView.faces} instead of {/myView.jsp}.




    I use @Begin(join=true, pageflow=...) but my pageflow is not starting!


    Pageflows only start at the beginning of a long-running conversation. If there is a long-running conversation already in progress when you hit a method with @Begin(join=true), no new pageflow will start.




    I get an exception like java.lang.IllegalStateException: No conversation context active


    There are several things that could cause this, but overwhelmingly the most common cause is that you tried to access a conversation-scope component during the JSF RESTORE_VIEW phase. The use of the 'binding' attribute of a component leads to such an exeception. And, of course, the tomahawk state saving components like t:savestate. Seam does not restore the conversation context until the very end of this phase.




    I get a NullPointerException thrown by PageContext.getCurrentReadableMap()


    You probably have two SeamPhaseListeners registered with JSF. Look for a duplicate log message like this:


    INFO [FacesConfigurator] Reading config /WEB-INF/faces-config.xml
    INFO [FacesConfigurator] Reading config /WEB-INF/faces-config.xml


    Try removing the javax.faces.CONFIG_FILES context parameter from web.xml, it is not usually needed by JSF.




    When editing an entity bean in a form I always get a Model Update Failure. Or: After saving I get an IllegalArgumentException and the entity manager complains about an attempt to create merge event with null entity


    Maybe you forgot an annotation. Or you didn't regard consistency of the used names. Have a look at the following example:

      • Entity: @Entity @Name("theentityname") public class TheEntityClass {...}

      • Backing bean: @In(required=false) @Out private TheEntityClass theentityname;

      • JSF: {theentityname.someproperty}




    My component isn't being found (methods on the page don't get called, the constructor isn't called, the page appears to just refresh in the browser)


    Seam probably hasn't found the component. Check in your log file, you should see something like


    [Scanner] scanning: /C:/java/jboss-4.0.4/server/default/tmp/deploy/tmp27153jboss-seam-todo.ear-contents/jboss-seam-todo.jar
    [Component] Component: login, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.example.todo.Login
    [Component] Component: todoList, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.example.todo.TodoList


    if you don't make sure you have in the root of the archive in which your seam components reside.




    When I click a commandButton/commandLink to submit my page, the page just refreshes and the action method isn't called


    Your component may not have been found (see another FAQ) or the errors may be hidden. The JSF lifecycle consists of a number of phases; in some of these phases errors can occur which don't cause an exception to be thrown and logged (at least at the default logging level for JBoss AS) - for example conversion errors, validation errors, model update errors. These can be viewed on the page using the <h:messages /> tag. You can also put in exception breakpoints for ConverterException and ValidatorException to get more details on why the phase errored.




    I get java.lang.NullPointerException: serialFactory when running a portlet in JBoss 4.0.5


    JBoss 4.0.5 uses MyFaces 1.1.4. There is a bug in this version that can cause a NullPointerException with portlets. See this MyFaces wiki page for a workaround.




    When using <s:validate> or <s:validateAll> fields annotated with @NotNull and @Length(min=1) aren't being validated (an InvalidStateException occurs and <h:message> shows no error)


    JSF only runs validation (using Hibernate Validator if you use the s:validate/s:validateAll tags) if the input field isn't empty. To check that a field is not null / not an empty string you need to use the required="true" attribute on the JSF component tag.



    How do I set the character encoding for my facelets page?


    Either specify the encoding in the template <?xml?> declaration, or use <f:view encoding="..../>.



    I would like to customize the default hibernate validator messages like "length must be between 5 and 10". Is there a way to override these messages?


    Most, if not all, hibernate validator annotations like @Length, @Size, etc. provides a message attribute where you can customize the message for a particular property. For example,

    @Length(min = 5, message="Length must be minimum of length 2")


    @Length(min = 5, message="#{messages['']})



    If you need to override the default hibernate validator messages, add the following key-value entries in your own file. These will override the default hibernate validator messages found in the hibernate-annotations.jar


    validator.assertFalse=assertion failed
    validator.assertTrue=assertion failed
    validator.future=must be a future date
    validator.length=length must be between {min} and {max}
    validator.max=must be less than or equal to {value}
    validator.min=must be greater than or equal to {value}
    validator.notNull=may not be null
    validator.past=must be a past date
    validator.pattern=must match "{regex}"
    validator.range=must be between {min} and {max}
    validator.size=size must be between {min} and {max} a well-formed email address
    validator.notEmpty=may not be null or empty




    Seam outputs messages to the page when something happens (e.g. Welcome, Peter).  How do I internationalize/disable these?


    Use the file.  The reference manual should specify the correct key (if not, take a look at the source code, and raise an issue in JIRA so we can update the manual).  To internationalize, add the key=value to the correct messages file.  To disable, put an empty property in the messages file (e.g. org.jboss.seam.loginSuccessful=).



    Why do I get a NullPointerException when I access injected Seam components, for example, @Logger org.jboss.seam.log.Log log in my component's constructor?


    Seam needs a default constructor to be declared in the component for proper instantiation and injection of Seam components. Use @Create on a method to be invoked after proper construction has occurred and all Seam components are properly initialized for the component.



    I'm using s:link/s:button (like <s:button view="/nextPage.xhtml" action="{}"> ) to submit the form, but the data isn't not saved. How do I fix this?


    s:button and s:link do not submit the form like h:commandButton and h:commandLink. To submit the form, and update your data model, you must use <h:commandButton> or <h:commandLink>. <s:button> and s:link are useful for navigation - they allow you to call an action and propagate the conversation transparently.


    I've commented out a JSF component but Facelets is still trying to access the property


    By default facelets processes commented out sections (resolves any EL as value bindings, and writes the commented section to the output).  To skip comments, add



    to your web.xml - this is not the default as the facelets manual suggests.


    You will also find, if commenting out an action method binding, with SKIP_COMMENTS set to false that you will get a PropertyNotFoundException - facelets is processing the comment as text, not a JSF component.


    I am getting a NullPointerException when trying to access my EntityManager


    If you are using EJB3 session beans, you can inject the EntityManager using @PersistenceContext; if you want to take advantage of Seam Managed Persistence Context (SMPC) you need to use @In EntityManager entityManager.  An SMPC has many advantages, which are discussed in the documentation - or if you using Seam JavaBeans, the Seam Application Framework or s:convertEntity then you'll need to use it.


    If you decide to use an SMPC you'll need to configure it in components.xml using <core:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/MyEntityManagerFactory"/>.



    I get Could not destroy component warnings logged by Seam when the HTTP session times out


    You need to make sure that your SFSB timeout is longer than your HTTP session timeout. See JbossTimeoutSettingForSeam.



    I get Value is not a valid option when using s:selectItems and s:convertEntity, or a custom converter


    The scenario: JSF runs the converter and loads the entity from the persistence context; JSF runs any validators, and adds it's own - that the selected object must be in the original list; the validation fails as a new object has been loaded from the persistence context.


    The solution - you've got two options:


    • Strongly Recommended Ensure that you are in a long-running conversation that spans the both the select list creation and the submission of the form.

    • Use id equality rather than object equality (make equals return true if both objects have the same id) (read this if you take this approach)



    I've configured Seam's exception handling, but it doesn't always work


    If the exception is thrown early enough in the page rendering process, Seam is able to handle the exception, however, it doesn't work when the page is rendered partially. This occurs because once the response has started to be written, you can't then do a redirect.


    There isn't much to be done (a pluggable Exception handler is slated for JSF 2.0 which should dramatically improve this);  your best bet is to configure JSF exception handling in web.xml to redirect to an error page.





    I get java.lang.ClassCastException: org.jboss.seam.jsf.SeamApplication11 incompatible with com.sun.faces.application.ApplicationImpl when using Seam with IBM WAS 6.1 and IBM jsf 1.1 Implementation


    This is a bug on IBM JSF Impl. They make a type cast of SeamApplication11 ( or any class that extend from javax.faces.application.Application) directly to ApplicationImpl , they must cast to Application.


    To solve this you have to use Sun JSF RI or My faces , put the jsf jars on WEB-INF/lib , remove jsf-ibm.jar, and modify the faces-config to use the other implementation. The problem with this is that you can�t use some extended IBM JSF components.


    Or wait  IBM  solve this bug



    I get a NullPointerException while testing with testNG inside Eclipse and the embedded EJB container


    One line above the NullPointerException you find the warning "[RuleBasedIdentity|RuleBasedIdentity] no security rule base available - please install a RuleBase with the name 'securityRules' if permission checks are required."


    To successfully test all testNG testcases inside the embedded EJB container, it's needed to add the test-build directory to the build-path of the eclipse project. Otherwise the embedded EJB-Container will not parse the EJB-classes for components.


    The discribed error is only one example off possible errors you might detect. Attention! You must remove the directory again if you start testNG by call of the ant target "test" of supplied seam ant build script.




    I put a component in a collection, but it can't be found


    It turns out that the default equals() method doesn't work for Seam JavaBean components; that is, authenticator.equals(authenticator) returns false (using reference equality).  The reason is Seam wraps Authenticator in a proxy, which after injection etc., calls equals(authenticator) on the real authenticator instance.  However, it sends the same parameter, which is the proxy, not the real instance.   The references are different, so equals() returns false.


    Thus, by default, you can't store Seam JavaBean components in collections, because collections depend on the correct implementation of equals().  To get around this, override equals() using field comparison.





    Seam Components are being created even without @AutoCreate or @In(create=true)


    When you reference a seam component in jsf (<h:inputText value="{someComponent.someProperty}"/>), Seam will automatically create this component for you with a no arg constructor.  This can be confusing especially when you don't enter a value for someProperty when you submit the page.  You can assume that all components referenced in a JSF page will be created by Seam.  If you wish to check if a component is "functionally null" meaning it has been created by Seam but not populated by user input, you must check some property of the component, usually a primary key or some property you expect to be there.


    if (someComponent.getId() == null)


    or the equivalent in EL


    See this forum thread for more info




    My application is running really slowly after changing Seam versions


    If you have changed the minor version of Seam (e.g. 1.1 -> 1.2, 1.2 -> 2.0) you need to update all the dtd and xsd references in pages.xml and  components.xml (e.g. "" -> "").  Only the current version is cached locally in jboss-seam.jar so for out-of-date references a roundtrip to happens for every read of the dtd.



    I get Target Unreachable exception when try to bind a component using binding attribute and the backing bean resolved to null


    You can't bind to a CONVERSATION scoped backing component because the conversation context is not available in the RESTORE VIEW phase



    Is it safe to inject event/conversation/session scoped components into application-scoped components?


    No, unless the application-scoped bean is @Synchronized. If it isn't, concurrent requests will overwrite the injected value, and this could lead to undesired behaviour.



    Is it safe to inject event/conversation/session scoped components into stateless-scoped components?


    Yes, as the EJB3 contract requires that you can't invoke a method twice on a stateless bean at the same time. In case of a high load, new beans will be created by the container.




    *I get warning like 2007-10-08 11:46:34,784 WARN  Javax.enterprise.resource.webcontainer.jsf.application JSF1004: Cann ot instantiate component of type org.jboss.seam.ui.Link followed by an UnsupportedOperationException *


    Don't use the context parameter com.sun.faces.verifyObjects with Seam as it causes all JSF controls to be loaded at start, including those which are optional (e.g. require jBPM, JBoss Cache).



    *I'm ending a conversation using <end-conversation before-redirect="true" /> or @End(beforeRedirect=true) and any FacesMessages aren't being displayed on the page I redirect to *


    FacesMessages are stored in the conversation (so they normally survive the redirect, which they don't in plain JSF).  By ending the conversation before the redirect you loose the FacesMessages.





    My getter methods are called many times when rendering a view (JSF page) which causes my app to be really slow. This is a bug in JSF, surely?


    Absolutely not.  JSF assumes you use a lazy initialization pattern to load your data into the backing bean, and use the getter methods as simple accessors.  You can either implement the lazy initialization yourself in the getter, or use Seam's @Factory annotation.  Another alternative is to use @Create to do the expensive logic when the component is created.



    Seam/Jsf is converting character and tag to their html code, why ?


    This is a normal jsf future, set <h:outputText escape="true"/> (default is escape="false") to avoid it.



    My authenticator is called more than once when a log in fails. Why?


    This is perfectly normal; Seam makes no guarantee on how many times the authenticator is called.  If you want to do something (e.g. log failed logins) you should observe the security events (see the ref docs for details).



    *I just deleted a seam-generated entity, and associated entities were deleted as well, even though the foreign key constraint in the database is ON DELETE RESTRICT. *




    This occurs because


    properties in seam-generated entities always have their cascade attribute set to


    (see  If the foreign key constraint in the database is set to restrict, you will need to modify the cascade attribute of the generated code, changing it to something like that shown in the following example:




         @OneToMany(cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.LAZY, mappedBy = "customer")
         public Set<SalesOrder> getSalesOrders() {
              return this.salesOrders;





    When accessing SEAM components, I get authentication failed exception because my SEAM components are protected by a security domain


    You need to separate your SEAM component into a different JAR file that is not protected by a security domain. You can then use the the SEAM Authenticator component to implement web security, and your SEAM components can invoke your protected EJB's by properly configure the InitialContext environment properties.


    Getting target unreachable problem when accesing entity property


    Sometimes Hibernate (@NotNull) validator causing this problem. Mark these properties with @Length anotation and give max and min values. In your jsf pages use "requiered=true" option.