I implemented my application in Heroku, just for testing ... Locally everything works fine, but in Heroku after I log in with the credentials I'm directed to the sac/index
page, which is correct, but me returns:
"Whitelabel Error Page
This application has no explicit mapping for / error, so you are seeing this as a fallback.
Tue May 30 19:56:32 UTC 2017 There was an unexpected error (type = Internal Server Error, status = 500). Error resolving template "/ sac / index", template might not exist or might not be accessible by any of the configured Template Resolvers "
However, when I access another page as /sac/listUsers
it works normally.
This is my Controller:
@RequestMapping("/sac/index")
public ModelAndView home(){
ModelAndView modelAndView = new ModelAndView();
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findUserByEmail(auth.getName());
modelAndView.addObject("userName", user.getName() + " (" + user.getEmail() + ")");
modelAndView.setViewName("/sac/index");
return modelAndView;
}
My http settings:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.
authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/login").permitAll()
.antMatchers("/sac/registration").hasAuthority("ADMIN")
.antMatchers("/sac/consultarUsuarios").hasAuthority("ADMIN")
.antMatchers("/sac/index").hasAnyAuthority("ADMIN", "SUPPORT")
.antMatchers("/sac/**").hasAnyAuthority("ADMIN", "SUPPORT").anyRequest()
.authenticated().and().csrf().disable().formLogin()
.loginPage("/login").failureUrl("/login?error=true")
.defaultSuccessUrl("/sac/index")
.usernameParameter("email")
.passwordParameter("password")
.and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login").and().exceptionHandling()
.accessDeniedPage("/access-denied");
}
Pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<finalName>${project.artifactId}</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}</finalName>
</configuration>
</plugin>
</plugins>
</build>
Application.properties:
# ===============================
# = Thymeleaf configurations
# ===============================
spring.thymeleaf.enabled=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
Does anyone know what I'm doing wrong?