Try to search your question here, if you can't find : Ask Any Question Now ?

Whitelabel Error Page in Spring Boot

HomeCategory: stackoverflowWhitelabel Error Page in Spring Boot
sourav asked 3 weeks ago

I tried to create a spring boot starter project. When I tried to run this I got this error.

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing
this as a fallback.

Fri Dec 29 14:16:46 IST 2017 There was an unexpected error (type=Not
Found, status=404). /

I added jsp files to src/web-inf/views/

Added

spring.mvc.view.prefix = /WEB-INF/views/ spring.mvc.view.suffix = .jsp
spring.mvc.static-path-pattern=/resources/**

to application.property file.

Created another controller:

@Controller
public class HomeController {

    @RequestMapping(value = "/", method = RequestMethod.GET)
   public String index() {
      return "index";
   }

   @PostMapping("/hello")
   public String sayHello(@RequestParam("name") String name, Model model) {
      model.addAttribute("name", name);
      return "hello";
   }
}

But still when I tried to run the same error occurs.

After lots of research, I found that I should add WebMvcConfigurerAdapter:

I added new class:

@Configuration
@EnableWebMvc
@ComponentScan
public class ViewConfig extends WebMvcConfigurerAdapter {

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

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Bean
    public InternalResourceViewResolver jspViewResolver() {
        InternalResourceViewResolver bean = new InternalResourceViewResolver();
        bean.setPrefix("/WEB-INF/views/");
        bean.setSuffix(".jsp");
        return bean;
    }
}

my POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.paymark</groupId>
    <artifactId>paymark</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>paymark</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>


    <dependencies>
        <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>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

         <!-- JSTL tag lib -->
    <dependency>
      <groupId>javax.servlet.jsp.jstl</groupId>
      <artifactId>javax.servlet.jsp.jstl-api</artifactId>
      <version>1.2.1</version>
    </dependency>

    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>

         <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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


</project>

File Structure:

enter image description here
Still the same error:

what am i doing here wrong? Please help

Log:

2017-12-29 15:40:01.756  INFO 12571 --- [           main] com.paymark.app.PaymarkApplication       : Starting PaymarkApplication on Karthiks-MacBook-Air.local with PID 12571 (/Applications/MAMP/htdocs/paymark/target/classes started by karthikcp in /Applications/MAMP/htdocs/paymark)
2017-12-29 15:40:01.759  INFO 12571 --- [           main] com.paymark.app.PaymarkApplication       : No active profile set, falling back to default profiles: default
2017-12-29 15:40:01.812  INFO 12571 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7f77e91b: startup date [Fri Dec 29 15:40:01 IST 2017]; root of context hierarchy
2017-12-29 15:40:03.035  INFO 12571 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-12-29 15:40:03.048  INFO 12571 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-12-29 15:40:03.049  INFO 12571 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.23
2017-12-29 15:40:03.258  WARN 12571 --- [ost-startStop-1] o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/Users/karthikcp/.m2/repository/javax/servlet/jsp/jstl/javax.servlet.jsp.jstl-api/1.2.1/javax.servlet.jsp.jstl-api-1.2.1.jar] from classloader hierarchy

java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method) ~[na:1.8.0_131]
    at java.util.zip.ZipFile.access$1400(ZipFile.java:60) ~[na:1.8.0_131]
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717) ~[na:1.8.0_131]
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419) ~[na:1.8.0_131]
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) ~[na:1.8.0_131]
    at sun.misc.IOUtils.readFully(IOUtils.java:65) ~[na:1.8.0_131]
    at java.util.jar.JarFile.getBytes(JarFile.java:425) ~[na:1.8.0_131]
    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193) ~[na:1.8.0_131]
    at java.util.jar.JarFile.getManifest(JarFile.java:180) ~[na:1.8.0_131]
    at org.apache.tomcat.util.scan.JarFileUrlJar.getManifest(JarFileUrlJar.java:151) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.tomcat.util.scan.StandardJarScanner.processManifest(StandardJarScanner.java:387) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:340) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [tomcat-embed-jasper-8.5.23.jar:8.5.23]
    at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [tomcat-embed-jasper-8.5.23.jar:8.5.23]
    at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101) [tomcat-embed-jasper-8.5.23.jar:8.5.23]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]

2017-12-29 15:40:03.262  WARN 12571 --- [ost-startStop-1] o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/Users/karthikcp/.m2/repository/taglibs/standard/1.1.2/standard-1.1.2.jar] from classloader hierarchy

java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method) ~[na:1.8.0_131]
    at java.util.zip.ZipFile.access$1400(ZipFile.java:60) ~[na:1.8.0_131]
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717) ~[na:1.8.0_131]
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419) ~[na:1.8.0_131]
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) ~[na:1.8.0_131]
    at sun.misc.IOUtils.readFully(IOUtils.java:65) ~[na:1.8.0_131]
    at java.util.jar.JarFile.getBytes(JarFile.java:425) ~[na:1.8.0_131]
    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193) ~[na:1.8.0_131]
    at java.util.jar.JarFile.getManifest(JarFile.java:180) ~[na:1.8.0_131]
    at org.apache.tomcat.util.scan.JarFileUrlJar.getManifest(JarFileUrlJar.java:151) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.tomcat.util.scan.StandardJarScanner.processManifest(StandardJarScanner.java:387) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:340) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [tomcat-embed-jasper-8.5.23.jar:8.5.23]
    at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [tomcat-embed-jasper-8.5.23.jar:8.5.23]
    at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101) [tomcat-embed-jasper-8.5.23.jar:8.5.23]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.23.jar:8.5.23]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]

2017-12-29 15:40:03.267  INFO 12571 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2017-12-29 15:40:03.269  INFO 12571 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-12-29 15:40:03.270  INFO 12571 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1461 ms
2017-12-29 15:40:03.382  INFO 12571 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-12-29 15:40:03.385  INFO 12571 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-12-29 15:40:03.937  INFO 12571 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-12-29 15:40:03.948  INFO 12571 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2017-12-29 15:40:04.015  INFO 12571 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.12.Final}
2017-12-29 15:40:04.016  INFO 12571 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2017-12-29 15:40:04.017  INFO 12571 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2017-12-29 15:40:04.046  INFO 12571 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-12-29 15:40:04.134  INFO 12571 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-12-29 15:40:04.288  INFO 12571 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
2017-12-29 15:40:04.292  INFO 12571 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete
2017-12-29 15:40:04.307  INFO 12571 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-12-29 15:40:04.408  INFO 12571 --- [           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)
2017-12-29 15:40:04.409  INFO 12571 --- [           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)
2017-12-29 15:40:04.440  INFO 12571 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-29 15:40:04.444  INFO 12571 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
2017-12-29 15:40:04.487  INFO 12571 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7f77e91b: startup date [Fri Dec 29 15:40:01 IST 2017]; root of context hierarchy
2017-12-29 15:40:05.046  INFO 12571 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-12-29 15:40:05.107  INFO 12571 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-12-29 15:40:05.111  INFO 12571 --- [           main] com.paymark.app.PaymarkApplication       : Started PaymarkApplication in 3.584 seconds (JVM running for 4.494)
1 Answers
Best Answer
Mannu answered 3 weeks ago
Your Answer

0 + 19 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com