jsf - Error deploying on Glassfish v.3 after using @SessionScoped -


i new jsf, java ee , having abit of problem small test case trying out faces.xml, jsf , managedbeans..

i have managedbean called beanmanager.java , in it, have 2 fields(name , testname) , method called testcase1() returns string. now, in frontpage.xhtml, have input text box gets name user , once user clicks submit button, testcase1() method called , set testname field of beanmanager.java class user's input reasons-obviously why sending message- when user enter's name , hits search button page navigates displaypage.xhtml , page displays nothing. supposed show name entered user blank. advised use @sessionscoped instead of @requestscoped problem when deploy java ee application on glassfish, following error:

exception occurred :error occurred during deployment: exception while loading app :  java.lang.illegalstateexception: containerbase.addchild: start:  org.apache.catalina.lifecycleexception: java.lang.illegalargumentexception:  javax.servlet.servletexception: com.sun.enterprise.container.common.spi.util.injectionexception:  error creating managed object class: class org.jboss.weld.servlet.weldlistener 

below files..

beanmanager.java

    import javax.enterprise.context.sessionscoped;     import javax.faces.bean.managedbean;       @managedbean(name = "user")     @sessionscoped  public class beanmanager {     private string name = "";     private string testname = "";       public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }       public string testcase1(){         settestname(this.name);         return "test1";     }       public string gettestname() {         return testname;     }      public void settestname(string testname) {         this.testname = testname;     }  } 

frontpage.xhtml

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"      "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:f="http://java.sun.com/jsf/core">  <ui:composition template="web-inf/templates/origin.xhtml">     <ui:define name="content">         <f:view>             <h:form>                 <h:panelgrid>                     <h:inputtext value="#{user.name}" required = "true"/>                 </h:panelgrid>                 <h:commandbutton                      action="#{user.testcase1()}"                     value="search"></h:commandbutton>             </h:form>             </f:view>       </ui:define> </ui:composition> </html> 

displaypage.xhtml

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"      "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:f="http://java.sun.com/jsf/core">  <ui:composition template="/web-inf/templates/origin.xhtml">     <ui:define name="content">        <h:panelgrid>         <h:outputtext value="#{user.testname}"/>         <h:commandbutton id="back" value="goback" action="frontpage"/>        </h:panelgrid>     </ui:define> </ui:composition> </html> 

faces-config.xml

<?xml version="1.0" encoding="utf-8"?>   <faces-config     xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"     version="2.0">      <navigation-rule>         <from-view-id>/frontpage.xhtml</from-view-id>         <navigation-case>             <from-action>#{user.testcase1()}</from-action>             <from-outcome>test1</from-outcome>             <to-view-id>/displaypage.xhtml</to-view-id>             <redirect/>         </navigation-case>          </navigation-rule>     <navigation-rule>     <from-view-id>/displaypage.xhtml</from-view-id>             <navigation-case>                 <from-outcome>goback</from-outcome>                 <to-view-id>/frontpage.xhtml</to-view-id>         </navigation-case>     </navigation-rule> </faces-config> 

you can't use cdi annotation javax.enterprise.context.sessionscoped jsf javax.faces.bean.managedbean. either go pure jsf with

  • javax.faces.bean.managedbean(naming) , javax.faces.bean.sessionscoped (scoping)

    or pure cdi

  • javax.inject.named (naming) , javax.enterprise.context.sessionscoped(scoping)

related:


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -