Javax.faces.context.FacesContext.getELContext

9 respostas
K

Galera,
Sou novato no desenvolvimento de jsf.
Estou tentando fazer uma pagina simples de jsf + facelets e esta danço o seguinte erro:

Alguém sabe me dizer o que é isso??

Web.xml:

javax.faces.DEFAULT_SUFFIX .xhtml facelets.DEVELOPMENT true com.sun.faces.validateXml true com.sun.faces.verifyObjects true Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet *.jsf

faces-config.xml:

<?xml version="1.0"?> pt_BR com.sun.facelets.FaceletViewHandler
<managed-bean>
	<managed-bean-name>numberBean</managed-bean-name>
	<managed-bean-class>tutorial.NumberBean</managed-bean-class>
	<managed-bean-scope>session</managed-bean-scope>
	<managed-property>
  		<property-name>min</property-name>
  		<value>1</value>
	</managed-property>
	<managed-property>
 		<property-name>max</property-name>
	    <value>10</value>
	</managed-property>	
</managed-bean>

<!-- going from guess.xhtml to response.xhtml -->
/guess.xhtml success /response.xhtml /response.xhtml success /guess.xhtml

guess.xhtml:

This text above will not be displayed.

<ui:composition template="/template.xhtml">

This text will not be displayed.

<ui:define name=“title”>
I’m thinking of a number from #{numberBean.min} to #{numberBean.max}. Can you guess it?
</ui:define>

This text will also not be displayed.

<ui:define name=“body”>

<h:form id=“helloForm”>

<h:inputText type=“text” id=“userNo” value="#{numberBean.guess}" validator="#{numberBean.validate}"/>




<h:commandButton type=“submit” id=“submit” action=“success” value=“Submit” />




<h:message showSummary=“true” showDetail=“false” style=“color: red; font-weight: bold;” id=“errors1” for=“userNo”/>

</h:form>

</ui:define>

This text will not be displayed.

</ui:composition>

This text below will also not be displayed.

response.xhtml:

<ui:composition template="/template.xhtml">

<ui:define name=“title”>

#{numberBean.message}

</ui:define>

<ui:define name=“body”>



</ui:define>

</ui:composition>

template.xhtml:

Facelets: Number Guess Tutorial

Default Title

Default Body

NumberBean:

package tutorial;

import java.io.Serializable;

import java.util.Random;

import javax.faces.application.FacesMessage;

import javax.faces.component.UIComponent;

import javax.faces.context.FacesContext;

import javax.faces.validator.ValidatorException;

public class NumberBean implements Serializable {

protected final static Random rand = new Random();

protected int min;

protected int max;

protected int guess;

protected int actual;
// Default Constructor

public NumberBean() {

this.min = 1;

this.max = 10;

}
// called by JSF to validate user input

public void validate(FacesContext context, UIComponent component, Object value)

throws ValidatorException {
// coerce the value to an int
try {
  int param = Integer.parseInt(value.toString());

  // validate param
  if (param > this.max || param < this.min) {
      FacesMessage msg = new FacesMessage("Guess must be between "+this.min+" and "+this.max);
      throw new ValidatorException(msg);
  }
} catch (NumberFormatException e) {
  FacesMessage msg = new FacesMessage("Must be a number");
  throw new ValidatorException(msg);
}

}

// lazy generate our actual value

public synchronized int getActual() {

if (this.actual == 0) {

this.actual = rand.nextInt(this.max-this.min);

this.actual += this.min;

}

return this.actual;

}
// our message for the response

public String getMessage() {

if (this.guess == this.getActual()) {

return Sweet, you got it right!”;

} else if (this.guess < this.getActual()) {

return Sorry, try something higher;

} else {

return Too bad, go lower;

}

}
// other bean properties

public int getMin() { return this.min; }

public int getMax() { return this.max; }

public int getGuess() { return this.guess; }
public void setMin(int min) { this.min = min; }

public void setMax(int max) { this.max = max; }

public void setGuess(int guess) { this.guess = guess; }

}

libs usadas:

cglib-2.1.1.jar
common-annotations.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.1.jar
commons-digester-1.6.jar
commons-el-1.0.jar
commons-fileupload.jar
commons-lang-2.1.jar
commons-logging-1.0.4.jar
el-api.jar
el-ri.jar
jboss-serialization.jar
jsf-api.jar
jsf-facelets.jar
jsf-impl.jar
jsp-api.jar
jstl-1.1.0.jar
myfaces-all.jar
myfaces-api-1.1.3.jar
myfaces-impl-1.1.3.jar
portlet.jar
servlet-api.jar
standard.jar
tomahawk-1.1.2.jar

Valeu galera

9 Respostas

G

cara, tem como voce colocar a mensagem completa (stack trace) do erro que tá dando?
Eu uso facelets e acho que até já cheguei a rodar esse tutorial que voce ta usando… mas sem a mensagem de erro fica complicado ajudar.

flw.

K

gilliard_santos:
cara, tem como voce colocar a mensagem completa (stack trace) do erro que tá dando?
Eu uso facelets e acho que até já cheguei a rodar esse tutorial que voce ta usando… mas sem a mensagem de erro fica complicado ajudar.

flw.

He verdade!!!
esqueci desse detalhe!!
segue o stack trace:

Merve Tomcat Plugin 0.9.1 launching project ‘jsf’ at url <a href="http://localhost:8080/jsf">http://localhost:8080/jsf</a>

context folder: C:\Inetpub\wwwroot\eclipse\jsf\web

tomcat version: Apache Tomcat/5.5.17

reloadable: false

Servlet.service() for servlet Faces Servlet threw exception

java.lang.UnsupportedOperationException

at javax.faces.context.FacesContext.getELContext(FacesContext.java:136)

at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:888)

at org.apache.myfaces.application.jsp.JspViewHandlerImpl.createView(JspViewHandlerImpl.java:130)

at com.sun.facelets.FaceletViewHandler.createView(FaceletViewHandler.java:650)

at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:127)

at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:595)
M

Kra, tranquilo?

Teve solução para esse erro? estou com o mesmo boro!

vlw!

kurokibr:
gilliard_santos:
cara, tem como voce colocar a mensagem completa (stack trace) do erro que tá dando?
Eu uso facelets e acho que até já cheguei a rodar esse tutorial que voce ta usando… mas sem a mensagem de erro fica complicado ajudar.

flw.

He verdade!!!
esqueci desse detalhe!!
segue o stack trace:

Merve Tomcat Plugin 0.9.1 launching project ‘jsf’ at url <a href="http://localhost:8080/jsf">http://localhost:8080/jsf</a>

context folder: C:\Inetpub\wwwroot\eclipse\jsf\web

tomcat version: Apache Tomcat/5.5.17

reloadable: false

Servlet.service() for servlet Faces Servlet threw exception

java.lang.UnsupportedOperationException

at javax.faces.context.FacesContext.getELContext(FacesContext.java:136)

at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:888)

at org.apache.myfaces.application.jsp.JspViewHandlerImpl.createView(JspViewHandlerImpl.java:130)

at com.sun.facelets.FaceletViewHandler.createView(FaceletViewHandler.java:650)

at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:127)

at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:595)</blockquote>
J

Acontecia um erro assim comigo e era conflito de jars, no projeto tinha o javax.el.jar e como eu usava o tomcat nele tinha el-api.jar.
Para resolver simplesmente tirei o javax.el.jar do projeto.
Espero que ajude.

M

jamirdeajr:
Acontecia um erro assim comigo e era conflito de jars, no projeto tinha o javax.el.jar e como eu usava o tomcat nele tinha el-api.jar.
Para resolver simplesmente tirei o javax.el.jar do projeto.
Espero que ajude.

opa… jah deu um luz… rsrsr
entao eu tenho o el-api.jar e o el-imp.jar no meu projeto… deve tirar entao o el-api certo?!

J

Opa, não tinha visto tua lista de jars… então você deve tentar tirar o el-api.jar do projeto, já que no tomcat ele também existe e é uma versão provavelmente diferente.
Olhei aqui um projeto anterior meu que usava MyFaces 1.1.4 e Tomahawk e na lista de libs foi tirado o el-api.jar também.
No mais está bem parecida.

M

jamirdeajr:
Opa, não tinha visto tua lista de jars… então você deve tentar tirar o el-api.jar do projeto, já que no tomcat ele também existe e é uma versão provavelmente diferente.
Olhei aqui um projeto anterior meu que usava MyFaces 1.1.4 e Tomahawk e na lista de libs foi tirado o el-api.jar também.
No mais está bem parecida.

Então… descobri ainda que está dando esse erro também quando coloco o tomahawk-sandbox-1.1.7.jar… no meu projeto…
Estou usando facelets 1.1.15 e jsf 2.1 e jsp 2.1

J

Opa não tinha notado… mas o MyFaces é uma implementação do JSF 1.1-1.2, então não pode misturar com as bibliotecas do jsf 2…
O MyFaces já tem o jsf junto, diferente do RichFaces, Primefaces.

S

Olá! Eu estou com o mesmo problema, recebendo a mesma msg, so que eu só tenho os segunites jars:
jstl-1.1.2
standard-1.1.2
jsf-facelets- 1.1.14
commons-beanutils-1.8.3
commons-collections-3.2.1
commons-digester-1.8
commons-logging-1.1.1
jsf-api-1.2_02
jsf-impl-1.1_02

Obrigada desde ja, quem puder…
abs
Sylvia Helena Dantonio

Criado 13 de dezembro de 2006
Ultima resposta 17 de mai. de 2011
Respostas 9
Participantes 5