1 Reply Latest reply on Aug 26, 2010 3:02 PM by Fabricio Lemos

    ViewScoped with seam-faces 3.0.0.Alpha3

    Fabricio Lemos Newbie

      Hello,


      I can´t get @ViewScoped to work with seam-faces 3.0.0.Alpha3. It´s like the bean instance is not stored.


      Here is my bean



      import javax.faces.bean.ViewScoped;
      import javax.inject.Named;
      
      @Named @ViewScoped
      public class MyBean implements Serializable {
              
              private int count;
              public void increment() {count = count + 1;}
              public int getCount() {return count;}
      }



      And this is the page:



      <?xml version="1.0"?>
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              template="/WEB-INF/templates/default.xhtml">
              <ui:define name="body">
                      <div class="code"><h:form>
                              <h:commandButton action="#{myBean.increment()}" value="Increment" />
                              <h:outputText value="#{myBean.count}" />
                      </h:form></div>
              </ui:define>
      </ui:composition>
      



      When I load the page, count shows 0 and them I click on the button several times but it only increments to 1.


      If I change @ViewScoped to @SessionScoped it works fine.


      I´m running on Glassfish 3.0.1 and added


      <listener>
      <listener-class>org.jboss.seam.faces.beanManager.BeanManagerServletContextListener</listener-class>
      </listener>



      to my web.xml




      Also, the first time I access the page I get this exception:




      SEVERE: Error Loading Library: jar:file:/D:/java/glassfish/glassfishv301-2/glassfish/domains/domain1/eclipseApps/pdf-app/WEB-INF/lib/seam-faces-3.0.0.Alpha3.jar!/META-INF/seam-faces.taglib.xml
      java.io.IOException: Error parsing [jar:file:/D:/java/glassfish/glassfishv301-2/glassfish/domains/domain1/eclipseApps/pdf-app/WEB-INF/lib/seam-faces-3.0.0.Alpha3.jar!/META-INF/seam-faces.taglib.xml]: 
              at com.sun.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:410)
              at com.sun.facelets.compiler.TagLibraryConfig.loadImplicit(TagLibraryConfig.java:431)
              at com.sun.facelets.compiler.Compiler.initialize(Compiler.java:87)
              at com.sun.facelets.compiler.Compiler.compile(Compiler.java:104)
              at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:218)
              at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:149)
              at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:100)
              at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:519)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:569)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
              at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
              at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
              at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
              at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
              at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
              at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
              at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
              at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
              at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
              at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
              at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
              at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
              at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
              at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
              at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
              at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
              at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: org.xml.sax.SAXException: Error Handling [jar:file:/D:/java/glassfish/glassfishv301-2/glassfish/domains/domain1/eclipseApps/pdf-app/WEB-INF/lib/seam-faces-3.0.0.Alpha3.jar!/META-INF/seam-faces.taglib.xml@25,18]
              at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.error(TagLibraryConfig.java:376)
              at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
              at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
              at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
              at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1621)
              at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1900)
              at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:764)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1318)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
              at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
              at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
              at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
              at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
              at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
              at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
              at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
              at com.sun.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:407)
              ... 46 more



      What could possibly be wrong?


      thanks in advance,
      Fabricio Lemos