Bom dia,
Estou montando um template default para meu projetos usando maven. A intenção é deixar tudo o que eu uso normalmente pronto, mas bem no inicio de tudo apareceu uma exceção que não estou conseguindo descobrir o pq dela.
Listening for transport dt_socket at address: 4000
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building vraptor-blank Maven Webapp
[INFO] task-segment: [jetty:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jetty:run
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Marcio\workspace\vraptor-blank\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [jetty:run {execution: default-cli}]
[INFO] Configuring Jetty for project: vraptor-blank Maven Webapp
[INFO] Webapp source directory = C:\Marcio\workspace\vraptor-blank\src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\Marcio\workspace\vraptor-blank\target\classes
2009-11-16 11:34:37.072::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /
[INFO] Tmp directory = determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
2009-11-16 11:34:37.134::INFO: jetty-6.1.21
[INFO] web.xml file = C:\Marcio\workspace\vraptor-blank\src\main\webapp\WEB-INF\web.xml
[INFO] Webapp directory = C:\Marcio\workspace\vraptor-blank\src\main\webapp
[INFO] Starting jetty 6.1.21 ...
2009-11-16 11:34:37.275::INFO: No Transaction manager found - if your webapp requires one, please configure one.
log4j:WARN No appenders could be found for logger (br.com.caelum.vraptor.ioc.spring.VRaptorApplicationContext).
log4j:WARN Please initialize the log4j system properly.
2009-11-16 11:34:38.025::INFO: Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 10 seconds.
2009-11-16 11:34:44.009::WARN: /
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at br.com.caelum.vraptor.vraptor2.Info.capitalize(Info.java:62)
at br.com.caelum.vraptor.http.asm.AsmBasedTypeCreator.typeFor(AsmBasedTypeCreator.java:84)
at br.com.caelum.vraptor.reflection.CacheBasedTypeCreator.typeFor(CacheBasedTypeCreator.java:54)
at br.com.caelum.vraptor.http.ognl.OgnlParametersProvider.createViaOgnl(OgnlParametersProvider.java:122)
at br.com.caelum.vraptor.http.ognl.OgnlParametersProvider.createRoot(OgnlParametersProvider.java:116)
at br.com.caelum.vraptor.http.ognl.OgnlParametersProvider.getParametersFor(OgnlParametersProvider.java:92)
at br.com.caelum.vraptor.interceptor.ParametersInstantiatorInterceptor.intercept(ParametersInstantiatorInterceptor.java:71)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:42)
at br.com.caelum.vraptor.core.InstantiatedInterceptorHandler.execute(InstantiatedInterceptorHandler.java:40)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
at br.com.caelum.vraptor.interceptor.multipart.MultipartInterceptor.intercept(MultipartInterceptor.java:74)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
at br.com.caelum.vraptor.interceptor.InterceptorListPriorToExecutionExtractor.intercept(InterceptorListPriorToExecutionExtractor.java:46)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:51)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:67)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:45)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:59)
at br.com.caelum.vraptor.core.DefaultRequestExecution.execute(DefaultRequestExecution.java:60)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:91)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:55)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:88)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Segue meus fontes:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Blank Web Application</display-name>
<context-param>
<param-name>br.com.caelum.vraptor.packages</param-name>
<param-value>cc.marcio.name</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>messages</param-value>
</context-param>
<filter>
<filter-name>vraptor</filter-name>
<filter-class>br.com.caelum.vraptor.VRaptor</filter-class>
</filter>
<filter-mapping>
<filter-name>vraptor</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Minhas 2 classes:
UserController
package cc.marcio.name.controller;
import cc.marcio.name.utils.CommonsValidator;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.view.Results;
@Resource
public class UserController {
private Result result;
public UserController(Result result) {
this.result = result;
}
@Post
public void login(String username, String password) {
if( CommonsValidator.validateString( username ) && CommonsValidator.validateString(password)) {
if( "marcio".equals(username) && "senha".equals("senha") ) {
this.result.include("teste", "Usuario logado com sucesso");
this.result.use(Results.logic()).redirectTo(HomeController.class).index();
} else {
this.result.include("teste", "Os dados digitados são inválidos");
this.result.use(Results.logic()).redirectTo(UserController.class).index();
}
}
}
/**
*
* WEB-INF/jsp/user/index.jsp
* @since 16/11/2009 - 10:55:57
*/
@Path("/")
public void index() {
System.out.println("Index");
}
}
HomeController
package cc.marcio.name.controller;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
@Resource
public class HomeController {
private Result result;
public HomeController(Result result) {
this.result = result;
}
/**
* JSP: WEB-INF/jsp/home/index.jsp
* @since 16/11/2009 - 11:06:03
*/
public void index() {
this.result.include("teste", "Sucesso");
}
}
Além das classes, criei na estrutura WEB-INF/jsp/user o jsp index.jsp com o formulário para o login e em WEB-INF/jsp/home o jsp index.jsp somente printando a mensagem que foi setada no controler.
Tem também na raiz do webcontent o arquivo index.jsp que só faz o redirect para o path “/”
index.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:redirect url="/user/index" />
Alguém me sugere alguma alteração para resolver o problema?!?
[]'s