1

I am studying Spring Mvc and Spring Boot and came across the following problem that until now could not identify. After running my main method I get the following message.

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Jul 20 21:22:43 BRT 2016 There was an unexpected error (type=Not Found, status=404). No message available

Controller

@Controller
@RequestMapping(value="/restauranteWeb")
public class HomeController {

    @RequestMapping(method=RequestMethod.GET)
    public String redirect() {
        return "login/login";
    }
}

Method Main

@SpringBootApplication()
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Configuration

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.gervasios.rsw")
public class ApplicationConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/pages/");
        viewResolver.setSuffix(".jsp");
        registry.viewResolver(viewResolver);
    }
}

@Bean
    public TilesConfigurer tilesConfigurer() {
        TilesConfigurer tilesConfigurer = new TilesConfigurer();
        tilesConfigurer.setDefinitions(new String[] {"/**/WEB-INF/**/tiles-config.xml"});
        tilesConfigurer.setCheckRefresh(true);
        return tilesConfigurer;
    }

AppInitializer

public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[] {ApplicationConfiguration.class};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[0];
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] {"/"};
    }

}

POM

<!-- Spring BOOT-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
    </parent>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </repository>
    </repositories>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.version>4.2.5.RELEASE</spring.version>          
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <!-- Javax - Jsf -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

LOG localhost:8080/restauranteWeb

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.5.RELEASE)

2016-07-21 22:24:17.632  INFO 4576 --- [           main] c.g.r.configuration.ApplicationExecute   : Starting ApplicationExecute on Helio-PC with PID 4576 (C:\Users\Helio\git\restauranteWeb\restauranteWeb\target\classes started by Helio in C:\Users\Helio\git\restauranteWeb\restauranteWeb)
2016-07-21 22:24:17.632  INFO 4576 --- [           main] c.g.r.configuration.ApplicationExecute   : No active profile set, falling back to default profiles: default
2016-07-21 22:24:17.695  INFO 4576 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1f32bf7: startup date [Thu Jul 21 22:24:17 BRT 2016]; root of context hierarchy
2016-07-21 22:24:19.433  INFO 4576 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1e356ee6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-07-21 22:24:20.124  INFO 4576 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-07-21 22:24:20.139  INFO 4576 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-07-21 22:24:20.155  INFO 4576 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.33
2016-07-21 22:24:20.358  INFO 4576 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-07-21 22:24:20.358  INFO 4576 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2663 ms
2016-07-21 22:24:20.514  INFO 4576 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-07-21 22:24:20.530  INFO 4576 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-07-21 22:24:20.612  INFO 4576 --- [           main] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: com.mysql.jdbc.Driver
2016-07-21 22:24:21.020  INFO 4576 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-07-21 22:24:21.036  INFO 4576 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2016-07-21 22:24:21.129  INFO 4576 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.11.Final}
2016-07-21 22:24:21.129  INFO 4576 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2016-07-21 22:24:21.129  INFO 4576 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2016-07-21 22:24:21.348  INFO 4576 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-07-21 22:24:21.426  INFO 4576 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-07-21 22:24:21.489  INFO 4576 --- [           main] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2016-07-21 22:24:21.801  INFO 4576 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-07-21 22:24:21.913  INFO 4576 --- [           main] o.h.e.t.i.TransactionFactoryInitiator    : HHH000399: Using default transaction strategy (direct JDBC transactions)
2016-07-21 22:24:21.913  INFO 4576 --- [           main] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2016-07-21 22:24:22.100  INFO 4576 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
2016-07-21 22:24:22.100  INFO 4576 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000102: Fetching database metadata
2016-07-21 22:24:22.116  INFO 4576 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000396: Updating schema
2016-07-21 22:24:22.116  INFO 4576 --- [           main] java.sql.DatabaseMetaData                : HHH000262: Table not found: RESADM.TUSUARIO
2016-07-21 22:24:22.116  INFO 4576 --- [           main] java.sql.DatabaseMetaData                : HHH000262: Table not found: RESADM.TUSUARIO
2016-07-21 22:24:22.116  INFO 4576 --- [           main] java.sql.DatabaseMetaData                : HHH000262: Table not found: RESADM.TUSUARIO
2016-07-21 22:24:22.131 ERROR 4576 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000388: Unsuccessful: create table RESADM.TUSUARIO (CODUSUARIO bigint not null auto_increment, DATCAD datetime, LOGIN varchar(255), SENHA varchar(255), SITUACAO varchar(255), primary key (CODUSUARIO))
2016-07-21 22:24:22.131 ERROR 4576 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : Table 'tusuario' already exists
2016-07-21 22:24:22.131  INFO 4576 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000232: Schema update complete
2016-07-21 22:24:22.392  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/restauranteWeb],methods=[GET]}" onto public java.lang.String com.gervasios.rsw.controller.HomeController.redirect()
2016-07-21 22:24:22.408  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/principal],methods=[GET]}" onto public java.lang.String com.gervasios.rsw.controller.PrincipalController.principal()
2016-07-21 22:24:22.408  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cadastroUsuario],methods=[GET]}" onto public java.lang.String com.gervasios.rsw.controller.UsuarioController.newUser(org.springframework.ui.Model)
2016-07-21 22:24:22.408  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cadastrarUsuario],methods=[POST]}" onto public java.lang.String com.gervasios.rsw.controller.UsuarioController.salvar(com.gervasios.rsw.model.Usuario,org.springframework.ui.ModelMap)
2016-07-21 22:24:22.408  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/usuariosSearch],methods=[GET]}" onto public void com.gervasios.rsw.controller.UsuarioController.buscarUsuarios(org.springframework.ui.Model)
2016-07-21 22:24:22.408  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-07-21 22:24:22.408  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-07-21 22:24:22.439  INFO 4576 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-21 22:24:22.533  INFO 4576 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1f32bf7: startup date [Thu Jul 21 22:24:17 BRT 2016]; root of context hierarchy
2016-07-21 22:24:22.611  INFO 4576 --- [           main] o.s.o.h.HibernateTransactionManager      : Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@1edc703] of Hibernate SessionFactory for HibernateTransactionManager
2016-07-21 22:24:23.048  INFO 4576 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-07-21 22:24:23.159  INFO 4576 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-07-21 22:24:23.159  INFO 4576 --- [           main] c.g.r.configuration.ApplicationExecute   : Started ApplicationExecute in 5.949 seconds (JVM running for 6.325)
2016-07-21 22:24:54.039  INFO 4576 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-07-21 22:24:54.039  INFO 4576 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2016-07-21 22:24:54.073  INFO 4576 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 34 ms
2016-07-21 22:24:54.198  WARN 4576 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound             : No mapping found for HTTP request with URI [/WEB-INF/pages/login/login.jsp] in DispatcherServlet with name 'dispatcherServlet'

Structure my page

Slava Semushin
  • 14,904
  • 7
  • 53
  • 69
Ger
  • 583
  • 2
  • 13
  • 35
  • Last line in your console (No mapping found for HTTP request with URI [/WEB-INF/pages/login/login.jsp] in DispatcherServlet with name 'dispatcherServlet') indicates that there is some issue in either locating the login.jsp because the jsp file does not exist at this location OR your servlet URL mappings for the DispatcherServlet are not defined correctly. – Naymesh Mistry Jul 22 '16 at 02:05
  • Thanks for the reply Naymesh Mistry and sorry for my English, I speak of Brazil. I understand the problem you described, but I could not identify problems with my mapping and the ways of my pages. I iditei my question inserting a picture with the print of my pages in my project structure. – Ger Jul 22 '16 at 02:44
  • I think it's a problem of your Java IDE. Are you using Maven? Doing maven clean and compile again to see if it helps. – Rocherlee Jul 22 '16 at 02:48
  • Ok, I try. Thank you. – Ger Jul 22 '16 at 03:01
  • Try the solution in this answer: http://stackoverflow.com/questions/31134333/this-application-has-no-explicit-mapping-for-error – tashi Jul 22 '16 at 06:05
  • Unsuccessfully. I tried the two alternatives that told me not funionou. I'm out of ideas. – Ger Jul 22 '16 at 21:28
  • I noticed one thing in tilesConfigurer method ApplicationConfiguration class, if I leave this /WEB-INF/tiles/tiles-config.xml form occurs error (No URL is ServletContext resource [ /WEB-INF/tiles/tiles-config.xml ] ) . If you leave ( /WEB-INF/**/tiles-config.xml ) The error occurs ( ServletContext resource [ / WEB -INF / ] can not be resolved to URL because it does not exist ) . – Ger Jul 22 '16 at 21:36

0 Answers0