I ended up getting this log as a result of running my Spring Boot App with a jsp.
2017-12-29 13:30:52.412 WARN 12631 --- [nio-8080-exec-2]
o.s.web.servlet.PageNotFound No mapping found for HTTP
request with URI [/SpringBootTrial/] in DispatcherServlet with name
'dispatcherServlet'
2017-12-29 13:30:56.463 WARN 12631 --- [nio-8080-exec-3]
o.s.web.servlet.PageNotFound No mapping found for HTTP
request with URI [/SpringBootTrial/display] in DispatcherServlet with
name 'dispatcherServlet'
2017-12-29 13:30:56.464 ERROR 12631 --- [nio-8080-exec-3]
o.s.boot.web.support.ErrorPageFilter : Cannot forward to error
page for request [/welcome] as the response has already been
committed. As a result, the response may have the wrong status code.
If your application is running on WebSphere Application Server you may
be able to resolve this problem by setting
com.ibm.ws.webcontainer.invokeFlushAfterService to false
It's evident that in Spring Boot, manual configuration is not needed. So, how should I fix this error?
I am clueless how to fix. I configured the jsp resolver in application.properties.
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
I have tomcat-embedded-jasper in the pom.xml.
Related
I have created a hilla app using this:
npx #vaadin/cli init --hilla --auth hilla-with-auth
Works fine!
Now I am trying to add that to an existing spring boot application, but I am having issues with Vite not starting as it should. No exception. No help in the debug output.
I have added:
relevant files in the root (package.json, vite.config.ts, etc.)
vaadin-featureflags.properties in resources folder
hilla dependencies in pom.xml as well as the build plugin
hill annotations to my application class (#Theme, #PWA) and made it extends SpringBootServletInitializer implements AppShellConfigurator
But even if everything seems to be initialized correctly, Vite does not start. Can anyone guide me in the right direction?
This is the most relevant output log:
2022-06-07 08:04:54.046 DEBUG 4947 --- [restartedMain] c.v.f.s.f.s.FullDependenciesScanner :
List of npm dependencies found in the project:
- #hilla/form 1.0.1 dev.hilla.EndpointController
....
2022-06-07 08:04:54.057 DEBUG 4947 --- [restartedMain] c.v.f.s.f.TaskGeneratePackageJson : writing file /Users/michael/Development/Previsto/previsto-server/target/flow-frontend/package.json.
2022-06-07 08:05:02.102 INFO 4947 --- [restartedMain] o.a.container.JSR356AsyncSupport : JSR 356 Mapping path /vaadinServlet
2022-06-07 08:05:02.176 INFO 4947 --- [restartedMain] c.v.f.s.DefaultDeploymentConfiguration :
Vaadin is running in DEBUG MODE.
When deploying application for production, remember to disable debug features. See more from https://vaadin.com/docs/
The following EXPERIMENTAL features are enabled:
- Use Vite for faster front-end builds
2022-06-07 08:05:02.207 DEBUG 4947 --- [restartedMain] c.v.f.s.c.PushRequestHandler : Using pre-initialized Atmosphere for servlet springServlet
2022-06-07 08:05:02.210 DEBUG 4947 --- [restartedMain] c.v.flow.server.VaadinServletService : Using 'com.vaadin.flow.server.communication.IndexHtmlRequestHandler' in client mode bootstrapping
2022-06-07 08:05:02.212 DEBUG 4947 --- [restartedMain] com.vaadin.flow.server.VaadinService : The application has the following routes:
2022-06-07 08:05:02.956 INFO 4947 --- [restartedMain] c.v.flow.server.frontend.FrontendTools : Project node version 16.10.0 is older than 16.14.0. Using node from /Users/michael/.vaadin.
2022-06-07 08:05:03.404 DEBUG 4947 --- [http-nio-8080-exec-1] c.v.f.s.s.VaadinDefaultRequestCache : Saving request to /
2022-06-07 08:05:03.471 DEBUG 4947 --- [http-nio-8080-exec-2] c.v.b.devserver.AbstractDevServerRunner : Requesting resource from Vite http://localhost:0/login
2022-06-07 08:05:03.486 ERROR 4947 --- [http-nio-8080-exec-2] o.a.c.c.C.[.[.[/].[springServlet] : Servlet.service() for servlet [springServlet] threw exception
java.net.ConnectException: Can't assign requested address (connect failed)
at ...
I see issues in the Spring cloud config server (Springboot) logs when connecting to the repo where configs are stored. I'm not sure if it's unable to clone because of credentials or something else (git-upload-pack not permitted). Any pointers to this would be great.
2021-10-06 22:52:51.763 INFO 1 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-10-06 22:52:51.764 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-10-06 22:52:51.765 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2021-10-06 22:52:54.769 WARN 1 --- [nio-8080-exec-1] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.
org.eclipse.jgit.api.errors.TransportException: https://github.asdf.asdf.asdf.com/asdfad/sdasdf: git-upload-pack not permitted on 'https://github.asdf.asdf.adsf.com/sdfdf/asdfsad-configs/'
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:612) [spring-cloud-config-server-3.0.4.jar!/:3.0.4]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.copyRepository(JGitEnvironmentRepository.java:587) [spring-cloud-config-server-3.0.4.jar!/:3.0.4]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.createGitClient(JGitEnvironmentRepository.java:570) [spring-cloud-config-server-3.0.4.jar!/:3.0.4]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:267) [spring-cloud-config-server-3.0.4.jar!/:3.0.4]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.getLocations(JGitEnvironmentRepository.java:245) [spring-cloud-config-server-3.0.4.jar!/:3.0.4]
at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.getLocations(MultipleJGitEnvironmentRepository.java:139) [spring-cloud-config-server-3.0.4.jar!/:3.0.4]
The Spring boot app.properties for the config server app looks like this -
spring.cloud.config.server.git.uri=https://github.sdf.sdasdf.asdf.com/asdf/asdf-configs
spring.cloud.config.server.git.username=github-token
spring.cloud.config.server.git.password={github_token}
The endpoint returns the response below:
{"status":"DOWN","components":{"clientConfigServer":{"status":"UNKNOWN","details":{"error":"no property sources located"}},"configServer":{"status":"DOWN","details":{"repository":{"application":"app","profiles":"default"},"error":"org.springframework.cloud.config.server.environment.NoSuchRepositoryException: Cannot clone or checkout repository: https://github-token#github.sdf.sdf.dsfs.com/sdf/sdfsd-configs"}},"discoveryComposite":{"description":"Discovery Client not initialized","status":"UNKNOWN","components":{"discoveryClient":{"description":"Discovery Client not initialized","status":"UNKNOWN"}}},"diskSpace":{"status":"UP","details":{"total":103880232960,"free":24558080000,"threshold":10485760,"exists":true}},"livenessState":{"status":"UP"},"ping":{"status":"UP"},"readinessState":{"status":"UP"},"refreshScope":{"status":"UP"}},"groups":["liveness","readiness"]}
Github token needs to be passed as username which I was configuring against the password property for the spring boot app. The password property needs to be left empty and the Github-token needs to be assigned to the username like below-
spring.cloud.config.server.git.username=asdfasdxxxxxxxyssssysysyssysy
spring.cloud.config.server.git.password=
Token authentication requirements are necesary for Git operations, see this link for more info.:
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
Try to add .git in the end of the URI in app.properties
spring.cloud.config.server.git.uri=https://github.sdf.sdasdf.asdf.com/asdf/asdf-configs.git
In my Spring Web Application project I've already configured an mvc:resources tag in order to exclude CSS, JS, images ... from DispatcherServlet mapping
Now I need to exclude also a foobar.txt and is placed under /webapp directory like the other static resources but ... It doesn't work.
Here my code snippet
<mvc:resources mapping="/assets/**" location="/assets/" />
<mvc:resources mapping="/foobar.txt" location="/foobar.txt" />
my folder structure is:
/webapp
/webapp/assets
/webapp/foobar.txt
/webapp/...
It's seems like the the first mvc:resources tag (assets) works but the second one (version.txt) doesn't.
I get a 404 page.
These are the difference in console log.
2018-07-12 13:58:25,093 DEBUG [http-nio-8080-exec-6] (DispatcherServlet.java:845) - DispatcherServlet with name 'dispatcher' processing GET request for [/mscbackend/foobar.txt]
2018-07-12 13:58:25,093 DEBUG [http-nio-8080-exec-6] (AbstractHandlerMethodMapping.java:297) - Looking up handler method for path /foobar.txt
2018-07-12 13:58:25,096 DEBUG [http-nio-8080-exec-6] (AbstractHandlerMethodMapping.java:305) - Did not find handler method for [/foobar.txt]
2018-07-12 13:58:25,097 DEBUG [http-nio-8080-exec-6] (AbstractUrlHandlerMapping.java:123) - Mapping [/foobar.txt] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/foobar.txt]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#66894a78]]] and 1 interceptor
2018-07-12 14:08:27,165 DEBUG [http-nio-8080-exec-7] (DispatcherServlet.java:845) - DispatcherServlet with name 'dispatcher' processing GET request for [/mscbackend/assets/css/style.css]
2018-07-12 14:08:27,165 DEBUG [http-nio-8080-exec-7] (AbstractHandlerMethodMapping.java:297) - Looking up handler method for path /assets/css/style.css
2018-07-12 14:08:27,169 DEBUG [http-nio-8080-exec-7] (AbstractHandlerMethodMapping.java:305) - Did not find handler method for [/assets/css/style.css]
2018-07-12 14:08:27,169 DEBUG [http-nio-8080-exec-7] (AbstractUrlHandlerMapping.java:168) - Matching patterns for request [/assets/css/style.css] are [/assets/**]
The weird thing is that in another similar project same configuration works without problems.
Thanks in advance for your support.
Try below configuration.
<mvc:resources location="/", mapping="/resources/**"/>
OR if you want to give classpath for a particular location use below.
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>
Try this configuration.
<mvc:resources mapping="/resources/**" location="/resources/" />
I don't why, but sometimes it works. you can give a try.
I am using spring boot web secure jdbc sample spring-boot-sample-web-secure-jdbc and want to modify it to load static html files (no template like thymeleaf or jsp needed). I have tried putting the html files under src/main/resources but they are not loading.
I noticed that static file example in samples spring-boot-sample-web-static inherits SpringBootServletInitializer for main class while web secure jdbc use WebMvcConfigurerAdapter. I suppose there might be some more configuration needed to make it work them. Below is my dir tree:
src/main/java/hello/MyController.java
src/main/resources/backupshell.html
src/main/resources/myscripts.js
After moving resources to src/main/resources/resources direct url load works fine but via request url mapping as below is not loading:
#RequestMapping("/admin")
//#ResponseBody
String admin() {
//return "Hello World admin!";
return "backupshell";
}
and logs snippet is as below:
2016-04-18 16:16:51.716 DEBUG 8896 --- [nio-8081-exec-9] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/backupshell] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#7a9c84a5]]] and 1 interceptor
2016-04-18 16:16:51.716 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/backupshell] is: -1
2016-04-18 16:16:51.717 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2016-04-18 16:16:51.717 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Successfully completed request
2016-04-18 16:16:51.718 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Successfully completed request
2016-04-18 16:16:51.718 DEBUG 8896 --- [nio-8081-exec-9] o.s.b.c.web.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade#24880cb8
2016-04-18 16:16:51.718 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2016-04-18 16:16:51.720 DEBUG 8896 --- [nio-8081-exec-9] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
Regards,
Miten.
The root resource directory src/main/resources/ isn't exposed publicly. As described in this post there are 4 directories which are automatically loaded by Spring Boot to serve static content:
/public/
/static/
/resources/
/META-INF/resources/
In your case you can put the HTML and the JS file inside ,e.g., the /public directory:
src/main/resources/public/backupshell.html
src/main/resources/public/myscripts.js
Then you can access the files with the address of your application, with default configuration it would be:
localhost:8080/backupshell.html
Note that 3rd option /resource/ doesn't mean that src/main/resources/ is exposed. It's the src/main/resources/resources/ directory, which can feel quite cumbersome.
I am investigating integrating Spring Cloud Sleuth into a new Spring Boot service we are building and want to exclude certain URL's from generating spans for example health check endpoints which are polled periodically.
Checking the code I can see that the TraceFilter created in the TraceWebAutoConfiguration.java has a DEFAULT_SKIP_PATTERN which can be overridden by setting spring.sleuth.instrument.web.skipPattern.
However even if I access a resource under the DEFAULT_SKIP_PATTERN I am still observing that a trace & span are being created i.e.
17:28:46.142 [XNIO-2 task-1] INFO o.s.c.sleuth.log.Slf4jSpanListener - Starting span: MilliSpan(begin=1454394526140, end=0, name=http/info, traceId=908b24a3-143f-4949-8f86-5df867e3985b, parents=[], spanId=908b24a3-143f-4949-8f86-5df867e3985b, remote=false, exportable=false, annotations={}, processId=null, timelineAnnotations=[])
17:28:46.143 [XNIO-2 task-1] INFO o.s.c.sleuth.log.Slf4jSpanListener - Continued span: MilliSpan(begin=1454394526140, end=0, name=http/info, traceId=908b24a3-143f-4949-8f86-5df867e3985b, parents=[], spanId=908b24a3-143f-4949-8f86-5df867e3985b, remote=false, exportable=false, annotations={}, processId=null, timelineAnnotations=[])
17:28:46.146 [XNIO-2 task-1] INFO io.undertow.servlet - Initializing Spring FrameworkServlet 'dispatcherServlet'
17:28:46.146 [XNIO-2 task-1] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization started
17:28:46.170 [XNIO-2 task-1] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization completed in 24 ms
17:28:46.216 [XNIO-2 task-1] INFO o.s.c.sleuth.log.Slf4jSpanListener - Stopped span: MilliSpan(begin=1454394526140, end=1454394526215, name=http/info, traceId=908b24a3-143f-4949-8f86-5df867e3985b, parents=[], spanId=908b24a3-143f-4949-8f86-5df867e3985b, remote=false, exportable=false, annotations={}, processId=null, timelineAnnotations=[])
Am I missing something? I am currently using 1.0.0.M4
A skipped resource does not stop a span from being created, it only stops the data from being collected and exported. So your logs look normal to me. In snapshots you would see the "exportable" flag set to false in skipped resources.