Configurando VRaptor 3.2.0

Pessoal estou tendo problemas para testar o exemplo com tiles do cookbook do VRaptor, será que alguém poderia dar uma força.

Meu pom.xml

		<dependency>
			<groupId>br.com.caelum</groupId>
			<artifactId>vraptor</artifactId>
			<version>3.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-core</artifactId>
			<version>2.2.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-api</artifactId>
			<version>2.2.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-servlet</artifactId>
			<version>2.2.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-jsp</artifactId>
			<version>2.2.2</version>
		</dependency>
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.5</version>
		</dependency>

Meu web.xml


	<context-param>
		<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
		<param-value>/WEB-INF/classes/tiles.xml</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>
	<servlet>
		<servlet-name>TilesServlet</servlet-name>
		<servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>TilesDispatchServlet</servlet-name>
		<servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>TilesDispatchServlet</servlet-name>
		<url-pattern>*.tiles</url-pattern>
	</servlet-mapping>

Quando vou testar aplicação, o log mostra um erro com uma das dependências.

2010-11-14 03:14:45.077:WARN::failed vraptor: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
2010-11-14 03:14:45.080:WARN::failed org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@64b2e752{/myassociatedlist,/Users/leandrostoroli/Documents/workspace/myassociatedlist/target/myassociatedlist.war}: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
2010-11-14 03:14:45.080:WARN::failed ContextHandlerCollection@5dd6c336: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
2010-11-14 03:14:45.110:WARN::failed HandlerCollection@3eaa3e5b: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
2010-11-14 03:14:45.110:WARN::Error starting handlers
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159)
at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:411)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.start(SpringBasedContainer.java:68)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.start(SpringProvider.java:82)
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:110)
at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:103)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
at org.mortbay.jetty.plugin.Jetty6RunWar.execute(Jetty6RunWar.java:67)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
2010-11-14 03:14:45.142:INFO::Started SelectChannelConnector@0.0.0.0:8080

adicione essas dependências:

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.6.1</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.6.1</version>
		</dependency>

Cara depois de verificar bastante o que estava acontecendo achei o problema!! O tiles-core precisa de uma dependência que se chama jcl-over-slf4j, e ela conflita com a versão do slf4j que o VRaptor usa. Pra resolver o problema foi só dar um exclude no tiles-core e adicionar a versão mais atual do jcl-over-slf4j. Meu pom.xml ficou assim:

	<dependencies>
		<dependency>
			<groupId>br.com.caelum</groupId>
			<artifactId>vraptor</artifactId>
			<version>3.2.0</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.5</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-core</artifactId>
			<version>2.2.2</version>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>jcl-over-slf4j</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-jsp</artifactId>
			<version>2.2.2</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>1.6.1</version>
		</dependency>
	</dependencies>

Ou seja, resumindo bastava eu colocar a versão do jcl-over-slf4j 1.6.1 que é a mesma versão do slf4j que o VRaptor usa e excluir a versão do tiles-core. Nem precisei adicionar o slf4j pq o VRaptor já tem como dependência.

Valeu Lucas.

[quote=leandros]Cara depois de verificar bastante o que estava acontecendo achei o problema!! O tiles-core precisa de uma dependência que se chama jcl-over-slf4j, e ela conflita com a versão do slf4j que o VRaptor usa. Pra resolver o problema foi só dar um exclude no tiles-core e adicionar a versão mais atual do jcl-over-slf4j. Meu pom.xml ficou assim:

	<dependencies>
		<dependency>
			<groupId>br.com.caelum</groupId>
			<artifactId>vraptor</artifactId>
			<version>3.2.0</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.5</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-core</artifactId>
			<version>2.2.2</version>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>jcl-over-slf4j</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.tiles</groupId>
			<artifactId>tiles-jsp</artifactId>
			<version>2.2.2</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>1.6.1</version>
		</dependency>
	</dependencies>

Ou seja, resumindo bastava eu colocar a versão do jcl-over-slf4j 1.6.1 que é a mesma versão do slf4j que o VRaptor usa e excluir a versão do tiles-core. Nem precisei adicionar o slf4j pq o VRaptor já tem como dependência.

Valeu Lucas.[/quote]

Vlw cara . Estava com o mesmo problema e resolveu aqui gracas a vc :slight_smile:

Olá pessoal,

Estava tentando implementar o Tiles 2 + Vraptor 3.4.1 e queria entender como eu devo fazer para chamar o tiles usando o vraptor:

Usando dessa forma funciona perfeitamenta o tiles, mas ao tentar pegar a mensagem na tela jsp, ele não aparece.

@Path(&quot;/&quot;)
    public void index() {
        result.include(&quot;mensagem&quot;, false);
        result.redirectTo(&quot;telaPrincipal.tiles&quot;);
    }

Meu web.xml abaixo, está definido assim:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;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"&gt;
	&lt;display-name&gt;VraptorTiles&lt;/display-name&gt;

        &lt;context-param&gt;
            &lt;param-name&gt;org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG&lt;/param-name&gt;
            &lt;param-value&gt;/WEB-INF/tiles.xml&lt;/param-value&gt;
	&lt;/context-param&gt;

        &lt;!-- servlet de inicialização do tiles --&gt;
        &lt;servlet&gt;
            &lt;servlet-name&gt;TilesServlet&lt;/servlet-name&gt;
            &lt;servlet-class&gt;org.apache.tiles.web.startup.TilesServlet&lt;/servlet-class&gt;
            &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
        &lt;/servlet&gt;

        &lt;!-- servlet que responde as requisições do tiles --&gt;
        &lt;servlet&gt;
            &lt;servlet-name&gt;TilesDispatchServlet&lt;/servlet-name&gt;
            &lt;servlet-class&gt;org.apache.tiles.web.util.TilesDispatchServlet&lt;/servlet-class&gt;
        &lt;/servlet&gt;

        &lt;!-- o tiles responderá por toda requisição *.tiles --&gt;
        &lt;servlet-mapping&gt;
            &lt;servlet-name&gt;TilesDispatchServlet&lt;/servlet-name&gt;
            &lt;url-pattern&gt;*.tiles&lt;/url-pattern&gt;
        &lt;/servlet-mapping&gt;

        &lt;!-- vraptor configuration --&gt;
         &lt;filter&gt;
             &lt;filter-name&gt;vraptor&lt;/filter-name&gt;
             &lt;filter-class&gt;br.com.caelum.vraptor.VRaptor&lt;/filter-class&gt;
         &lt;/filter&gt;

        &lt;filter-mapping&gt;
             &lt;filter-name&gt;vraptor&lt;/filter-name&gt;
             &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
             &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
             &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
         &lt;/filter-mapping&gt;
         &lt;!-- vraptor configuration --&gt;
&lt;/web-app&gt;

Estava vendo a documentação do vraptor, ele vi que eles usam o web.xml sem o DEFINITIONS_CONFIG, mas queria ver se existe uma forma de usar DEFINITIONS_CONFIG do tiles.

Obrigado.

tenta trocar o redirectTo por forwardTo.

Olá Lucas,

Então como eu já tava apanhando desde ontem acabei seguinda a documentação e implementando o tiles 2 + o vraptor 3.4.1, sem usar o tiles.xml, percebi que deixando o vraptor assumer os redirecionamentos, ficou muito melhor do que antes quando eu usava o Struts 2 + Tiles. Mas de qualquer forma valeu pela ajuda.

Abs.