I have two producer based methods that produce maps used in a column of a h:dataTable. This is the simple page:

```
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view contentType="text/html">
    <h:body>
        <h:form id="mainForm">
            <h:dataTable value="#{adminManager.expertisesubs}" 
                                var="_expertisesub">
                <h:column>
                    <h:outputText value="#{testMapTwo[_expertisesub.tempValue]}" />
                    <br />
                    <h:selectOneMenu value="#{_expertisesub.tempValue}">
                        <f:selectItems value="#{testMapOne}" />
                    </h:selectOneMenu>      
                </h:column>
            </h:dataTable>
        </h:form>
    </h:body>
</f:view>
</html>

```

The producer looks like this:

```
public class ExpertisemainProducerHelper implements Serializable {

private static final long serialVersionUID = -8387208055146539725L;

@Produces
@ViewScoped
@Named("testMapOne")
public Map<String, Integer> produceTestMapOne() {
    Map<String, Integer> theMap = new TreeMap<String, Integer>();

    theMap.put("FOUR", 4);
    theMap.put("FIVE", 5);
    theMap.put("SIX", 6);

    return theMap;
}

@Produces
@ViewScoped
@Named("testMapTwo")
public Map<Integer, String> produceTestMapTwo() {
    Map<Integer, String> theMap = new TreeMap<Integer, String>();

    theMap.put(4, "FOUR-2");
    theMap.put(5, "FIVE-2");
    theMap.put(6, "SIX-2");

    return theMap;
}
}

```

The dataTable iterates over the list expertisesubs which is a list of object expertisesub. That object has the simple field private field Integer tempValue with the standard setter/getter methods.

That page produces the following exception:

```
SEVERE: Error Rendering View[/faces/layouts/admin.xhtml]
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at java.lang.Integer.compareTo(Unknown Source)
at java.util.TreeMap.getEntry(Unknown Source)
at java.util.TreeMap.get(Unknown Source)
at javax.el.MapELResolver.getValue(MapELResolver.java:52)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:386)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:163)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:461)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

```

The exception only occurs if the page references both produced maps using @ViewScoped in the method declaration. If I change the scope to @SessionScoped or remove reference to one or the other map on the page, the page works (no exceptions).

The page is not the real solution but a torn down minimal page that can produce the same error.

My environment is:

JSF 2.2 (Mojarra)
CDI (Weld 2.2.3)
Tomcat 7
Java 7 (latest build...tried earlier too)

I've configured my environment to support JSF 2.2x @ViewScoped as follows:

Empty beans.xml

web.xml entries:

```
<listener>
    <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
    <resource-env-ref-name>BeanManager</resource-env-ref-name>
    <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>

```

context.xml in META-INF:

```
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Manager pathname="" />

<Resource name="BeanManager" 
    auth="Container"
    type="javax.enterprise.inject.spi.BeanManager"
    factory="org.jboss.weld.resources.ManagerObjectFactory" />
</Context>

```

**Note**: This all worked perfectly in Jsf 2. Weld 1.x. Custom @ViewScoped.

**Update**: I thought this might have been an issue with wiring up CDI to Tomcat 7 so I tried this in GlassFish 4 (I removed the context.xml, web.xml listener/resource, weld-servlet, and jsf lib so it all is dependent on the default GlassFish implementation). Same problem with same stack occurs in GlassFish.

**Update July 2015**: 
Due to the recent activity on the post, I'm adding information about how I "worked around" the problem.

Basically, I removed direct reference to the producers from the page. Instead, I injected (CDI) the maps directly into the bean behind the page. I added some @PostConstruct code to iterate over the map and build SelectItem objects and place those into appropriate lists. I then referenced those fields (lists of SelectItem) on the page. Not nice, defeats the purpose of the producer, but in the end I had to get this moving forward and did not have time to download sources (CDI issue? JSF issue? Weld specific issue?), add debug, compile, and test. Thanks for the recent attention.