40

Here is my form:

<form action="j_security_check">
    <h:panelGrid columns="2" bgcolor="#eff5fa" cellspacing="5" frame="box" styleClass="center">
        <h:outputLabel value="User ID:"/>
        <h:inputText id="j_username" tabindex="1" />
        <h:outputLabel value="Password:"/>
        <h:inputSecret id="j_password"/>
        <h:outputLabel value=""/>
        <h:commandButton id="login" value="Login"/>
    </h:panelGrid>
</form>

It work fine with Glassfish 3.0.1, but since Glassfish 3.1 b2 it shows this warning as a FacesMessage in the JSF page:

The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>

If I change the <form action="j_security_check"> to <h:form>, it does not fix it, I have to place the <h:form> inside the <h:panelGrid>.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Thang Pham
  • 38,125
  • 75
  • 201
  • 285
  • I'm still having this issue (with Glassfish 3.1-b37). Did you find a solution so far? – Theo Jan 13 '11 at 10:02
  • 1
    @Theo : I switch back to GF 3.0.1 as GF 3.1 gave me so much problem when I configure mail server. But as `@Carlo Pacheco` suggests `It only shows if you are in JSF Development based on your web config. javax.faces.PROJECT_STAGE Development. When you change it to Production it wont show anymore`. I have not tried it, maybe you can verify what he said. – Thang Pham Jan 13 '11 at 10:07
  • Behavior still present in 3.1.1. – Thorbjørn Ravn Andersen Nov 08 '11 at 11:39
  • This behaviour still exists in Wildfly 9.0.1.Final (which uses JSF 2.2, Mojarra implementation). – Buhake Sindi Oct 20 '15 at 15:24
  • @BuhakeSindi: **what** behaviour? Did you read all the answers? It is in many cases the right behaviour (if you made an error), so please be more specific in what exactly the problem still is, and if so, create your own new question referring this one. – Kukeltje Oct 20 '15 at 15:31
  • @Kukeltje yes I did and I have understood the question. I am saying that, with the latest JSF implementation I am getting this warning, only in 1 particular case. I have to use the Development Project Stage during development so my code is written properly. I am just highlighting that this warning still exists, 4 years after this post was logged. – Buhake Sindi Oct 20 '15 at 16:15
  • I get the warning to in cases where I made a mistake. If you still get it in a case you think you did not make a mistake, then please post in **which case**. Then it is helpful and maybe someone can create an issue with Mojarra (which version?) – Kukeltje Oct 20 '15 at 16:41

6 Answers6

50

This is just a Warning not an Error. Warnings are usually there to inform the developer about unforeseen situations/conditions which might not immediately cause technical errors/problems. Anything may just work flawlessly, but the behaviour/results may probably not be as the developer intented. A newbie developer may for example accidently have used <form> instead of <h:form>. Warnings like this are then helpful.

In your particular case, you are simply forced to use <form> because of the need to submit to a non-JSF service. You as a more experienced developer know that it's legitimately valid. You can just ignore this warning. This warning will only appear when javax.faces.PROJECT_STAGE is set to Development anyway and not appear when it is set to Production.

However, that it still displays the warning when there's another component like panelgrid in between the form and its input children, is a bug to me. I'd report it to the Mojarra guys. It look like as if it is checking the immediate parent only and not all of the parents. Update: it has been fixed as per Mojarra 2.1.3/2.2, see also issue 2147.

This is by the way not Glassfish specific. The newer GF version of course ships with a newer Mojarra version which has those warnings implemented. See also issue 1663.

Related questions:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 2
    There must be a way for now to shut down the warning. it must be something like setting the server log level to SEVERE instead. – Thang Pham Nov 03 '10 at 16:26
  • if the warning is only inside the log, then I dont really mind, but it actually display onto the page, whether the page have p:growl, p:message or nothing at all. – Thang Pham Nov 03 '10 at 16:49
  • 1
    Oh, it's displayed as facesmessage? This surprises me. Which JSF impl version is it? – BalusC Nov 03 '10 at 16:54
  • Yeah it display as FacesMessages. Mine is Mojarra 2.1.0-SNAPSHOT, it come with GF 3.1 b.25 – Thang Pham Nov 03 '10 at 16:59
  • That's a nightly/beta build... Right, Glassfish 3.1 itself is also beta. – BalusC Nov 03 '10 at 17:58
  • There are nightly and promoted version. I use the promoted version. Here is the link http://dlc.sun.com.edgesuite.net/glassfish/3.1/promoted/ – Thang Pham Nov 03 '10 at 18:33
  • Can we safely say that this is a bug and report that too Mojarra guys, BalusC? – Thang Pham Nov 03 '10 at 20:50
  • I'm not sure. I quickly downloaded latest nightly of 2.1 from javaserverfaces.dev.java.net, added it to a Tomcat 6 playground environment with a copypaste of your form along with a `h:messages`. I didn't see a message, also not in the logs. Don't you have some special JSF debug settings in faces-config or web.xml I am not aware of? – BalusC Nov 03 '10 at 21:01
  • I actually thought about that as well. I have another EE project that use the same security form as above, but it never gave me the FacesMessage. So i suspect something is wrong with me original project, but then I double check by deploy that original project onto GF 3.0.1, the FacesMessage go away. It kind of contradict my analysis. In my web.xml, nothing is out of the ordinary, `context-param`, `filter` for PF file upload and my custom filter, `servlet` for FacesServlet, and `security-constraint`. In faces-config, is just my navigation rule and managed bean – Thang Pham Nov 03 '10 at 21:54
  • Maybe I have to take my words back and this is somehow GF 3.1 related. But still, this is plain weird. Google also [hints](http://webcache.googleusercontent.com/search?q=cache:lamlXoidS1gJ:forums.java.net/jive/thread.jspa%3FmessageID%3D485857+%22The+form+component+needs+to+have+a+UIForm+in+its+ancestry%22&cd=2&hl=en&ct=clnk) that you're not the only one who encountered this on GF 3.1. One has mentioned that s/he already reported an issue, but I can't find it right now. – BalusC Nov 03 '10 at 22:12
  • Ahhh, now that we confirm that it a bug, I wont have to look anymore. Thank you BalusC – Thang Pham Nov 03 '10 at 23:32
  • 4
    Yeah, I get this in GF 3.1 as well! The "workaround" is changing `javax.faces.PROJECT_STAGE` from **Development** to **Production**. Hopefully, when JSF 2.1.1-b04 successor is stabled then this message will go away in Development mode. Like @BalusC said, it does confuse new developer - and they could spend hours frustrated by this issue. But experienced developers just ignore this as it's only a warning and doesn't show up when you change to Production mode. – ChuongPham Apr 20 '11 at 05:47
  • FYI: I'm using JBoss AS 7.0.2.Final, which comes with "Mojarra 2.1.3 (SNAPSHOT 20110825)" and I do see this message on one of my pages. – Joshua Davis Dec 15 '11 at 15:53
  • I was able to figure out why this is still happening for me on Mojarra 2.1.3: I use a to create tabs dynamically in a . Apparently that hides the form from the . – Joshua Davis Dec 15 '11 at 16:14
  • This thing is so annoying. – Ced Aug 12 '15 at 13:44
  • This issue is still present in Mojarra 2.2.15 (at least, a client id could be displayed to know which component is the cause...) – Rapster Mar 22 '18 at 09:43
16

This was suggested to me by Oleg from the PrimeFaces forum and works:

<h:form id="login" prependId="false"
                onsubmit="document.getElementById('login').action='j_security_check';">

Regards, Brendan.

Oversteer
  • 1,778
  • 1
  • 22
  • 38
4

It only shows if you are in JSF Development based on your web config.

<context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

When you change it to Production it wont show anymore

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
  • Guys, did the javax.faces.PROJECT_STAGE set to Production help you? Unfortunatelly for me this value is never set for some reasons, I checked it by `FacesContext.getCurrentInstance().getApplication().getProjectStage()` and it always returns Development! – bitec Mar 13 '11 at 19:39
  • Change the `javax.faces.PROJECT_STAGE` to **Production** work. – ChuongPham Apr 20 '11 at 05:52
3

If anyone will find this usefull one day, i had same error and the problem was that i have primefaces component

<p:something ....

and that component was not inside <h:form> element

anotherUser
  • 551
  • 6
  • 29
1

I'm using Mojarra 2.1.27 and find out that this is my mistakes. However its just very hard to find what the mistakes was. Hopefully someone from Mojarra could add component id to the warning messages. Here is what I did to found out the component: (which also posted to https://code.google.com/p/primefaces/issues/detail?id=1586#c48)

I trace it by downloading the Mojarra source code and adding break point to com.sun.faces.context.FacesContextImpl class in method: public void addMessage(String clientId, FacesMessage message). when the break point catch, open the Debugging window or call stack window to find out that it was called by class com.sun.faces.application.view.FormOmittedChecker in method private static void addFormOmittedMessage(FacesContext context) which is previously called by method

public static void check(FacesContext context).

inside the check method there is parameter variable component. You can get the component id from Watch or variable window and then trace it back to your html page and code.

Its a hard way, but hope you can find the root of the problems. It will be much more simpler if the warning message also display the problematic component id

Harun
  • 667
  • 7
  • 13
0

In my case, this warning message was displayed in p:messages which I've put in dialog to show validation errors, so I've just included severity="error"in p:messages and warning message was gone.

matoni
  • 2,479
  • 21
  • 39
  • That is sort of just hiding like setting the log level to error to hide the warning messages. It is not a real 'solution'. – Kukeltje Jun 04 '19 at 15:13