Search code examples
javaspringspring-bootspring-mvcthymeleaf

Spring don't displaying webpage and can't found resource


I wrote simple Java application using Spring framework and Thymeleaf. On my IDE it's working complettly fine but when I'm making JAR artifact and exporting it to my linux server it's booting but I'm getting this errors:

02:56:06.447 [main] INFO com.ibcs.rfid.RfidApplication - Started RfidApplication in 142.158 seconds (JVM running for 151.664)
Jul 15, 2021 2:56:10 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring DispatcherServlet 'dispatcherServlet'
02:56:10.948 [http-nio-8080-exec-1] INFO org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
02:56:10.954 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Detected StandardServletMultipartResolver
02:56:10.959 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Detected AcceptHeaderLocaleResolver
02:56:10.964 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Detected FixedThemeResolver
02:56:11.171 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@1db0c88
02:56:11.251 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Detected org.springframework.web.servlet.support.SessionFlashMapManager@1384aac
02:56:11.257 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
02:56:11.261 [http-nio-8080-exec-1] INFO org.springframework.web.servlet.DispatcherServlet - Completed initialization in 308 ms
02:56:11.638 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - GET "/", parameters={}
02:56:11.745 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped to com.ibcs.rfid.controllers.ServiceControllers#loginForm(Model)
02:56:12.994 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.view.ContentNegotiatingViewResolver - Selected 'text/html' given [text/html, application/xhtml+xml, image/webp, application/xml;q=0.9, */*;q=0.8]
02:56:13.003 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.view.InternalResourceView - View name 'login', model {authentication=com.ibcs.rfid.models.Authentication@14147d2, org.springframework.validation.BindingResult.authentication=org.springframework.validation.BeanPropertyBindingResult: 0 errors}
02:56:13.065 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.view.InternalResourceView - Forwarding to [login]
02:56:13.265 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - "FORWARD" dispatch for GET "/login", parameters={}
02:56:13.383 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped to ResourceHttpRequestHandler [Classpath [META-INF/resources/], Classpath [resources/], Classpath [static/], Classpath [public/], ServletContext [/]]
02:56:13.434 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.resource.ResourceHttpRequestHandler - Resource not found
02:56:13.441 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Exiting from "FORWARD" dispatch, status 404
02:56:13.461 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND
02:56:13.480 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - "ERROR" dispatch for GET "/error", parameters={}
02:56:13.549 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)

My files tree:

├───.idea
│   ├───artifacts
│   └───libraries
├───.mvn
│   └───wrapper
├───out
│   └───artifacts
│       └───rfid_jar
├───src
│   ├───main
│   │   ├───java
│   │   │   ├───com
│   │   │   │   └───ibcs
│   │   │   │       └───rfid
│   │   │   │           ├───controllers
│   │   │   │           ├───models
│   │   │   │           └───storers
│   │   │   └───META-INF
│   │   └───resources
│   │       ├───jsons
│   │       ├───static
│   │       │   ├───css
│   │       │   ├───img
│   │       │   └───js
│   │       └───templates
│   └───test
│       └───java
│           └───com
│               └───ibcs
│                   └───rfid
└───target
    ├───classes
    │   ├───com
    │   │   └───ibcs
    │   │       └───rfid
    │   │           ├───controllers
    │   │           ├───models
    │   │           └───storers
    │   ├───jsons
    │   ├───static
    │   │   ├───css
    │   │   ├───img
    │   │   └───js
    │   └───templates
    ├───generated-sources
    │   └───annotations
    ├───generated-test-sources
    │   └───test-annotations
    └───test-classes
        └───com
            └───ibcs
                └───rfid

And my application.properties content:

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

Also here is part of my Controller:

    @GetMapping("/")
    public String loginForm(Model model)
    {
        model.addAttribute("authentication", new Authentication());
        return "login";
    }

Any ideas how can I fix it? Also I'm limited to only .jar file cause It have to run on Zebra FX9600


Solution

  • Solution (from comments):

    • Build it with maven

    Thanks M. Deinum