Olá galera,
Bem, estou com um problema que eu acho que é algum detalhe bem besta que estou esquecendo. Estou criando uma telinha de login que consulta num BD MySQL, até aí tudo certo, compila legal sem nenhum erro. (Nem quero mostrar o codigo pq fiz em 9 minutos exatos e tá uma coisa monstruosamente PORCA). Eu acho que é algum probleminha besta de configuração.
Alterei o server.xml do tomcat para rodar pela porta 80, ok. Entao eu digito http://localhost/login e voi là! A telinha JSP aparece.
Agora nos temos o seguinte arquivo web.xml:
<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Login</display-name>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>com.login.controller.ChecarLogin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/checarLogin</url-pattern>
</servlet-mapping>
</web-app>
Ok, entao quando eu digitasse http://localhost/login/checarLogin eu deveria ter o servlet. Mas ao invés disso tenho:
[code]HTTP Status 404 - /checarLogin
type Status report
message /checarLogin
description The requested resource (/checarLogin) is not available.
Apache Tomcat/6.0.16
[/code]
Pelo form action do index.jsp eu tenho:
<form action="checarLogin" method="POST">
A minha estrutura de diretórios:
login
*src
--com
--login
--controller
--ChecarLogin.java
--model
*web
index.jsp
web.xml
--images
--WEB-INF
--classes
--com
--login
--controller
--ChecarLogin.class
--lib
--mysqlconnector.jar
Eu gostaria de saber porque diabos está dando a porcaria do 404.
PS: Setei a permissão do .class pra 777 e tudo mais.
Tente http://localhost/checarLogin, SEM o ‘login’ na URL.
O Servlet não respeita a estrutura de diretórios. Ele é acessado da raiz do contexto.
Você poderia também mudar o
<url-pattern>/minha-app/checarLogin</url-pattern>
[quote=ze_kiefa]Tente http://localhost/checarLogin, SEM o ‘login’ na URL.
O Servlet não respeita a estrutura de diretórios. Ele é acessado da raiz do contexto.[/quote]
Mudei o web.xml, tentei acessar desse outro jeito e…
Nada, não deu em nada… Continua 404 ;(
Boa idéia. não havia pensado nisso… rs.
Deixa eu dar um olhada aqui…
08/08/2008 17:15:23 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found o$
08/08/2008 17:15:23 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-80
08/08/2008 17:15:23 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1483 ms
08/08/2008 17:15:23 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
08/08/2008 17:15:23 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
08/08/2008 17:15:24 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.ContextListener" is already configured for this context. The duplicate definition has been ign$
08/08/2008 17:15:24 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.SessionListener" is already configured for this context. The duplicate definition has been ign$
08/08/2008 17:15:25 org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/ch1/WEB-INF/web.xml
java.io.UnsupportedEncodingException: ISO-8851-1
at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:70)
at java.io.InputStreamReader.<init>(InputStreamReader.java:100)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.createReader(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.setEncoding(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$XMLDeclDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:369)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1062)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
08/08/2008 17:15:25 org.apache.catalina.startup.ContextConfig start
SEVERE: Marking this application unavailable due to previous error(s)
08/08/2008 17:15:25 org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
08/08/2008 17:15:25 org.apache.catalina.core.StandardContext start
SEVERE: Context [/ch1] startup failed due to previous errors
08/08/2008 17:15:25 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-80
08/08/2008 17:15:25 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
INFO: Jk running ID=0 time=0/90 config=null
08/08/2008 17:15:25 org.apache.catalina.startup.Catalina start
INFO: Server startup in 2354 ms
Viu algo demais? Eu não vi… Essa aplicaçãozinha ai ch01 é outra, a primeira q tava testando…
apaga ela do projeto entao…
Ah, outro arquivo aqui de log:
catalina.08.08.2008.log
08/08/2008 17:15:23 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found o$
08/08/2008 17:15:23 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-80
08/08/2008 17:15:23 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1483 ms
08/08/2008 17:15:23 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
08/08/2008 17:15:23 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
08/08/2008 17:15:24 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.ContextListener" is already configured for this context. The duplicate definition has been ign$
08/08/2008 17:15:24 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.SessionListener" is already configured for this context. The duplicate definition has been ign$
08/08/2008 17:15:25 org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/ch1/WEB-INF/web.xml
java.io.UnsupportedEncodingException: ISO-8851-1
at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:70)
at java.io.InputStreamReader.<init>(InputStreamReader.java:100)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.createReader(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.setEncoding(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$XMLDeclDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:369)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1062)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:70)
at java.io.InputStreamReader.<init>(InputStreamReader.java:100)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.createReader(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.setEncoding(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$XMLDeclDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:369)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1062)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
08/08/2008 17:15:25 org.apache.catalina.startup.ContextConfig start
SEVERE: Marking this application unavailable due to previous error(s)
08/08/2008 17:15:25 org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
08/08/2008 17:15:25 org.apache.catalina.core.StandardContext start
SEVERE: Context [/ch1] startup failed due to previous errors
08/08/2008 17:15:25 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-80
08/08/2008 17:15:25 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
08/08/2008 17:15:25 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/90 config=null
08/08/2008 17:15:25 org.apache.catalina.startup.Catalina start
INFO: Server startup in 2354 ms
Continuo sem ver nada… =(
[quote=raf4ever]olha as coisas melhorando 
SEVERE: Parse error in application web.xml file at jndi:/localhost/ch1/WEB-INF/web.xml
java.io.UnsupportedEncodingException: ISO-8851-1
[/quote]
Mas então cara, essa aplicação CH1 não é a que estou agora, a que estou é a Login…
Essa é uma que eu tava testando ainda…
deleta essa aplicação então…
como perguntar não ofende… 
tu estás usando doPost() ou service() no teu servlet?
[quote=raf4ever]como perguntar não ofende… 
tu estás usando doPost() ou service() no teu servlet?[/quote]
Rsrs. Relaxa, eu sou bem iniciante ainda em WEB.
No servlet, sobrescrevi a ação do DoGet() e no corpo do metodo coloquei para DoPost().
Não sobrescrevi o método Service().
Mas cara, esse erro é 404, diz que nao localiza. Se fosse algum erro no bytecode ele acusaria depois que tentasse acessar, eu estaria feliz se ele estivesse acusando um erro no codigo, rsrsrs.
Oi,
Tá dando exception de encoding na aplicacao ch1, se voce nao conseguir remover ela pelo manager/html pode fazer o que sugeriram, pare o tomcat, dá um delete na pasta, limpa os logs, reinicia o tomcat… deve funcionar…
Outra coisa, se você nao quiser se preocupar se a requisicao vem por GET, POST, etc, basta colocar o seu codigo direto no service que o container se vira…
Abs
Olá galera,
Bme, uma coisa. Eu estou rodando o Tomcat pelo plugin da Sysdeo instalado do Eclipse Ganymede.
Mas acontece que eu posso reestartar, etc, e os arquivos de log dentro de /home/darkstar/apache-tomcat/logs nao sao alterados, no caso, ele nao usa o diretório de log default do tomcat. Alguem sabe qual ele usa?
[]'s!
E outra coisa, quando eu coloco o arquivo web.xml dentro do diretorio web/ a index.jsp aparece. Mas se eu coloco o arquivo web.xml dentro do /web/WEB-INF ele não mostra o index.jsp nem o servlet.
grato.
Ok, ja vi que um dos problemas que estava dando era com a tag display-name e o local doa rquivo, que ja foi modificado para WEB-INF.
Mas continua dando 404… E agora hein? 
Fiz rodar, era só isso o problema besta. O caminho do web.xml e a localização do servlet. Nada mais.
Desculpem pelas 2 paginas de nada. =) rs.