3

After update from JSF 2.1 to 2.2, I start getting the following error message:

The metadata component needs to be nested within a f:metadata tag. Suggestion: enclose the necessary components within <f:metadata>

It's a bit weird as the code looks like this:

....
 <ui:composition template="./resources/templates/template_base.xhtml">

        <ui:define name="contentBody">

            <h:outputStylesheet library="css/table" name="tableContent.css" />
            <h:outputScript library="javascript" name="pagination.js" target="head" />

            <p:growl id="messages" autoUpdate="true" />

            <f:metadata>
                <f:viewParam name="topicId" value="#{topicBean.topic.id}" />
                <f:event type="preRenderView" listener="#{topicBean.init(true)}" />
            </f:metadata>

        </ui:define>

</ui:composition>
....

If the metadata component the error message refers to is either f:viewParam or f:event, then I do have it/them enclosed by f:metadata.

Any ideas about what I'm doing wrong? The error does not show if I set javax.faces.PROJECT_STAGE to Production, but I would like to keep it in Development until I'm finished.

Edit1 - Versions:

  • Netbeans: 7.3.1 (Build 201306052037)
  • Java: 1.7.0_25; Java HotSpot(TM) Client VM 23.25-b01
  • Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b16
  • Java EE: Java EE 7 Web
  • JSF implementation: Mojarra 2.2.0
  • Glassfish: 4.0 build 89
nivis
  • 913
  • 3
  • 17
  • 34
  • Which JSF 2.2 impl/version? – BalusC Jun 26 '13 at 12:49
  • I've added more info about versions in the end of the post – nivis Jun 26 '13 at 13:23
  • I don't have Mojarra 2.2.0 at hands right now, but I can't reproduce in Mojarra 2.2.1. What if you put `` in its own `` which ends up in an `` as immediate child of ``, exactly as recommended in tag documentation? http://docs.oracle.com/javaee/7/javaserverfaces/2.2/vdldocs/facelets/f/metadata.html Mojarra is more lenient in this, but MyFaces is known to fail like that when not done as per the recommendation. – BalusC Jun 26 '13 at 13:24
  • I will try that. I'm also using PrimeFaces if that can affect anything. I didn't mention that as thought that it wouldn't make any difference. – nivis Jun 26 '13 at 13:34
  • It shouldn't :) At least not in this specific case. – BalusC Jun 26 '13 at 13:36
  • Good. One less thing to worry about :) – nivis Jun 26 '13 at 13:52
  • Finally got around testing a separate `ui:define` for the metadata. It made no difference though :/ – nivis Jul 03 '13 at 09:39
  • Well, maybe your runtime classpath is polluted with multiple JSF versions which conflicted with each other. Doublecheck and cleanup. – BalusC Jul 03 '13 at 10:21
  • I tried to get this information through using `ClassLoader.getSystemClassLoader` and then `getURLs()`. When printing it only shows `glassfish.jar` and `flashlight-agent.jar`, so I'm not sure how to check this. Can you point me in the right direction to find the complete classpath? – nivis Jul 04 '13 at 07:22
  • I think it's a bug. I remember seeing a bug report about this when I was helping someone. I'll see if I can find the link to be sure. – Andy Jul 04 '13 at 07:33
  • Yep, I reread your question. I remember reading something about this but only when you set your project as DEVELOPMENT. – Andy Jul 04 '13 at 07:34
  • Yeah, I noticed that when I set `PROJECT_STAGE` to production, the error message disappeared. Problem is that I really wan't to have it set to DEV during development. Version 2.2.1 is some kind of development version still, right? I tried to find where to download it, but I was unsuccessful. – nivis Jul 04 '13 at 13:21
  • Found that it will be released on Tuesday (9th) – nivis Jul 04 '13 at 13:47
  • Hopefully there's no delay. But it works though *I think*. Try to ignore it for not I guess. – Andy Jul 04 '13 at 15:04
  • This solution I poster earlier may be a solution. [Update Glassfish 4.0 build 89 Mojarra implementation from 2.2.0 => 2.2.25][1] [1]: http://stackoverflow.com/questions/10583337/viewparam-value-not-set-in-viewscoped-bean/21089406#21089406 – mookins Jan 13 '14 at 11:29
  • This solution I poster earlier may be a solution. [Update Glassfish 4.0 build 89 Mojarra implementation from 2.2.0 => 2.2.25][1] [1]: http://stackoverflow.com/questions/10583337/viewparam-value-not-set-in-viewscoped-bean/21089406#21089406 – mookins Jan 13 '14 at 11:32

2 Answers2

2

Bug reported for JSF 2.2. I was dealing with the same issue awhile back.

https://java.net/jira/browse/JAVASERVERFACES-2803

You might also want to stay away from f:viewActions also.

https://java.net/jira/browse/JAVASERVERFACES-2868

Andy
  • 5,900
  • 2
  • 20
  • 29
0

I used exactly the same configuration (Glassfish, Mojarra 2.2.0) and found out that I could circumvent the error message if I use only one child in the metadata-tag and put the listener outside of it.

<f:event type="preRenderView" listener="#{bean.listener()}"/>
<f:metadata>
    <f:viewParam name="par1" value="#{bean.val1}" />
</f:metadata>

The problem occurs again if you use two viewParams, see https://java.net/jira/browse/JAVASERVERFACES-3080

An upgrade to the latest Mojarra Version (2.2.6 as of now) solved the problem for me.

esel
  • 901
  • 9
  • 20