Pessoal,
Fui convencido (tarde demais) a estudar o Struts.
Baixei um strutsSample.war completo e executei sobre struts 1.0 com sucesso.
Tentei criar o meu primeiro projeto sobre struts 1.1 e ocorreram alguns problemas.
Estou obtendo a seguinte exceção tentando executar o “Login” Struts.
javax.servlet.ServletException: Missing message for key "login.title"
Aparentemente o struts não tá conseguindo achar meu ApplicationResources.properties (este é o arquivo de properties que contem login.title). Inicialmente eu coloquei o <init-param>application no meu web.xml, não funcionou, tentei então colocar no meu struts-config.xml:
<message-resources
factory="org.apache.struts.util.PropertyMessageResourcesFactory"
key="org.apache.struts.action.MESSAGE"
null="true"
parameter="com.oreilly.ApplicationResources" />
Meu arquivo ApplicationResources.properties está no arquivo war dentro da estrutura:
<my-web-context>/WEB-INF/classes/com/oreilly
Ele tem uma chave “login.title” configurada corretamente.
Por favor, não me recomendem ver o struts-example.war, pois eu já o fiz :evil: . Funcionou legal.
Thanks
manda ai o ApplicationResources.properties pra nois da uma olhada
Pega aí:
login.title=Login Struts Sample
error.userName.required=u00C9 necessu00E1rio um nome de usuu00E1rio
error.login.authenticate=username/password invu00E1lido
errors.footer=</ul><hr>
errors.header=<h3><font color="red">Page
Validation</font></h3>Corrija o(s) seguinte(s) erro(s)
antes de continuar:<ul>
applicationResources=Cannot load application resources bundle
tente somente
<message-resources
parameter="com.oreilly.ApplicationResources" />
parece certinho,
tu tem o output do tomcat quando inicializa o site??
nrmalmente ele mostra algumas mensagens de inicialização do struts, falando dos resources carregados e …
Aí vai galera:
Fiz o que o nakayatomo propôs.
Segue os logs.
Inicialização do Tomcat:
01/07/2003 18:04:39 org.apache.commons.modeler.Registry loadRegistry
INFO: Loading registry information
01/07/2003 18:04:39 org.apache.commons.modeler.Registry getRegistry
INFO: Creating new Registry instance
01/07/2003 18:04:40 org.apache.commons.modeler.Registry getServer
INFO: Creating MBeanServer
01/07/2003 18:04:44 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on port 8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.18-LE-jdk14
01/07/2003 18:05:11 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
01/07/2003 18:05:11 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true
01/07/2003 18:05:12 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='com.oreilly.ApplicationResources', returnNull=true
01/07/2003 18:05:12 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
01/07/2003 18:05:13 org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
01/07/2003 18:05:13 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=30/300 config=F:USRjboss-3.0.6_tomcat-4.1.18 omca
t-4.1.xconfjk2.properties
Arquivo de log do Tomcat após 1 requisição a http://localhost:8080/strutsSample:
2003-07-01 18:05:02 WebappLoader[/webdav]: Deploying class repositories to work directory F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xworkStandalonelocalhostwebdav
2003-07-01 18:05:03 StandardManager[/webdav]: Seeding random number generator class java.security.SecureRandom
2003-07-01 18:05:03 StandardManager[/webdav]: Seeding of random number generator has been completed
2003-07-01 18:05:03 StandardWrapper[/webdav:default]: Loading container servlet default
2003-07-01 18:05:03 StandardWrapper[/webdav:invoker]: Loading container servlet invoker
2003-07-01 18:05:05 WebappLoader[/tomcat-docs]: Deploying class repositories to work directory F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xworkStandalonelocalhost omcat-docs
2003-07-01 18:05:05 StandardManager[/tomcat-docs]: Seeding random number generator class java.security.SecureRandom
2003-07-01 18:05:05 StandardManager[/tomcat-docs]: Seeding of random number generator has been completed
2003-07-01 18:05:05 StandardWrapper[/tomcat-docs:default]: Loading container servlet default
2003-07-01 18:05:05 StandardWrapper[/tomcat-docs:invoker]: Loading container servlet invoker
2003-07-01 18:05:05 WebappLoader[/manager]: Deploying class repositories to work directory F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xworkStandalonelocalhostmanager
2003-07-01 18:05:05 ContextConfig[/manager]: Configured an authenticator for method BASIC
2003-07-01 18:05:05 StandardManager[/manager]: Seeding random number generator class java.security.SecureRandom
2003-07-01 18:05:05 StandardManager[/manager]: Seeding of random number generator has been completed
2003-07-01 18:05:05 StandardWrapper[/manager:default]: Loading container servlet default
2003-07-01 18:05:05 StandardWrapper[/manager:invoker]: Loading container servlet invoker
2003-07-01 18:05:05 WebappLoader[]: Deploying class repositories to work directory F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xworkStandalonelocalhost\_
2003-07-01 18:05:06 StandardManager[]: Seeding random number generator class java.security.SecureRandom
2003-07-01 18:05:06 StandardManager[]: Seeding of random number generator has been completed
2003-07-01 18:05:06 StandardWrapper[:default]: Loading container servlet default
2003-07-01 18:05:06 StandardWrapper[:invoker]: Loading container servlet invoker
2003-07-01 18:05:06 HostConfig[localhost]: Expanding web application archive strutsSample.war
2003-07-01 18:05:06 StandardHost[localhost]: Installing web application at context path /strutsSample from URL file:F:/USR/jboss-3.0.6_tomcat-4.1.18/tomcat-4.1.x/webapps/strutsSample
2003-07-01 18:05:06 WebappLoader[/strutsSample]: Deploying class repositories to work directory F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xworkStandalonelocalhoststrutsSample
2003-07-01 18:05:06 WebappLoader[/strutsSample]: Deploy class files /WEB-INF/classes to F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xwebappsstrutsSampleWEB-INFclasses
2003-07-01 18:05:06 WebappLoader[/strutsSample]: Deploy JAR /WEB-INF/lib/struts.jar to F:USRjboss-3.0.6_tomcat-4.1.18 omcat-4.1.xwebappsstrutsSampleWEB-INFlibstruts.jar
2003-07-01 18:05:09 StandardManager[/strutsSample]: Seeding random number generator class java.security.SecureRandom
2003-07-01 18:05:09 StandardManager[/strutsSample]: Seeding of random number generator has been completed
2003-07-01 18:05:10 StandardWrapper[/strutsSample:default]: Loading container servlet default
2003-07-01 18:05:12 StandardWrapper[/strutsSample:invoker]: Loading container servlet invoker
2003-07-01 18:06:42 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Missing message for key "login.title"
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
----- Root Cause -----
javax.servlet.ServletException: Missing message for key "login.title"
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:530)
at org.apache.jsp.Login_jsp._jspService(Login_jsp.java:95)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
Na tela do Tomcat após a requisição:
...
01/07/2003 18:15:43 org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.taglib.bean.LocalStrings', returnN
ull=true
Forma que estou usando o bean no JSP:
...
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
...
<title><bean:message key="login.title" /></title>
...
Eu tenho que especificar um Locale em algum lugar ? Onde ?
Thanks
provavelmente você esta utilizando windows e esta com algum problema de case no nome do arquivo, tent renomear ele para alguma outra coisa e renomear de volta
Valeu galera, tá funcionando
Eu não entendi bem o que aconteceu, então refiz o módulo de “Login” do exemplo Struts a partir do zero e agora tudo funciona.
Devo ter tropeçado na versão anterior. :roll:
Obrigado pela ajuda.