Spring-boot Api not starting - spring-boot

APPLICATION FAILED TO START
Description:
Configuration property name 'carWasher' is not valid:
Invalid characters: 'W'
Bean: carWasher-com.carWasher.properties.CarWasherProperties
Reason: Canonical names should be kebab-case ('-' separated), lowercase alpha-numeric characters and must start with a letter
Action:
Modify 'carWasher' so that it conforms to the canonical names requirements.

You have a #ConfigurationProperties bean in your application with the prefix attribute set to carWasher It should be car-washer.

Related

Suspicious URL pattern in FilterRegistrationBean?

Recently I'm getting the following warning when starting my spring-boot application:
o.a.c.c.StandardContext: Suspicious URL pattern: [/rest/**] in context [], see sections 12.1 and 12.2 of the Servlet specification
Definition:
#Bean
public FilterRegistrationBean traceFilterRegistration(HttpTraceFilter filter) {
FilterRegistrationBean registration = new FilterRegistrationBean(filter);
registration.addUrlPatterns("/rest/**");
return registration;
}
Question: is nowadays /rest/* the same as /rest/** so I could switch that safely?
My goal is obviously to catch any sub path under the rest path, eg also /rest/this/is/my/sub.
The specs for Servlet 3.1 and 4.0 state the following:
12.2 Specification of Mappings
In the Web application deployment descriptor, the following syntax is used to define
mappings:
■ A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for
path mapping.
■ A string beginning with a ‘*.’ prefix is used as an extension mapping.
■ The empty string ("") is a special URL pattern that exactly maps to the
application's context root, i.e., requests of the form http://host:port/<contextroot>/. In this case the path info is ’/’ and the servlet path and context path is
empty string (““).
■ A string containing only the ’/’ character indicates the "default" servlet of the
application. In this case the servlet path is the request URI minus the context path
and the path info is null.
■ All other strings are used for exact matches only.
If the effective web.xml (after merging information from fragments and
annotations) contains any
Which means the pattern /rest/** is an invalid one and should be changed to /rest/*.

What is the use of star(*) in yaml file?

I was going through spring boot actuator when I stumbled upon this quote:
* has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints.
I tried to look over the internet about it without any luck. What is the use of * in yaml file?
* is used to remove the repeated nodes. Consider this yaml example:
myprop:
uid: &id XXX
myprop1:
id: *id
The above will expand to:
myprop:
uid: XXX
myprop1:
id: XXX
Now try running this code:
#Value("${myprop.uid}") String uid;
#Value("${myprop1.id}") String id;
#Bean
ApplicationRunner runner() {
return args -> {
System.out.println(uid); // prints "XXX"
System.out.println(id); // prints "XXX"
System.out.println(uid.equals(id)); // prints "true"
};
}
From the spec:
Repeated nodes (objects) are first identified by an anchor (marked with the ampersand - “&”), and are then aliased (referenced with an asterisk - “*”) thereafter.
It depends on the context of the YAML file. You said you was going through spring boot actuator, so you can take a look into the reference documentation of Spring Boot, the chapter 5.2.2. Exposing Endpoints to be exact.
* can be used to select all endpoints. For example, to expose everything over HTTP except the env and beans endpoints, use the following properties:
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
The asterisk * means that all the endpoints that belongs to a certain category are either included or exluded.
The sentence below just says that the asterisk * character must be quoted "*" in case of the YAML format usage over classic properties file.
* has a special meaning in YAML, so be sure to add quotes if you want to include (or exclude) all endpoints, as shown in the following example:
By the way, this sentence is the same one you have sited at your question.

Tomcat Startup exception: Failed to read schema document

This is idp.war deployment on tomcat 7(.69)
Failed to read schema document 'class path:/schema/shibboleth-2.0-services.xsd'
in the trace it suggests some things:
1) could not find the document.
2) the document could not be read.
3) the root element of the document is not <xsd:schema>
I can go into the deployment: idp/WEB-INF/lib/shibboleth-common-1.2.1.jar/schema/ and see all the shibboleth-2.0- .xsd files that the Service.xml file is declaring as schemaLocations
this folder was created by tomcat deployment for tomcat so I don't know why it can't be read, I'm guessing permissions issues wouldn't apply here.
and the root element of the .xsd document is
<schema ... >
so that qualifies as
<xsd:schema>
correct or no?
Two points:
(1) Whether a start-tag with the element-type name schema is effectively the same as one with the element-type name xsd:schema depends on the namespace bindings, which are omitted here. (The start-tag <xsd:schema> cannot occur as the first tag in a namespace-well-formed XML document, so I'm assuming you're paraphrasing, not quoting.)
If the unprefixed schema start-tag makes "http://www.w3.org/2001/XMLSchema" the default namespace, then that is not likely to be your problem. (Hint for the next time you ask a question, though: omitting salient information like namespace bindings makes your question less clear and less likely to get useful responses.)
(2) The error message you quote puts a blank between the strings 'class' and 'path' -- if your reference to the schema document actually does begin "class path:", then that is your problem: Shibboleth's documentation says:
Shibboleth defines a special URL scheme, classpath, which ensures that the schema files are resolved from the classpath.
As a matter of URI syntax, blanks are not allowed in the middle of a scheme name. You will need to start any URI you want to identify in this way with "classpath:/", not "class path:/".

How to access field value in a JSR-303 message?

I would like to customize my error message in the following way:
Assume following declaration of a class Person:
#Size(min=10, max=200, message="{name.size}")
private String name;
Within the declared error message in ValidationMessages.properties I would like to output the field value as well, i.e. I would like to do something like this:
name.size=The name '{name}' is invalid, its size must be between {min} and {max}
Assume the content of the field 'name' is “abc”. Then the error message should look like this:
The name 'abc' is invalid, its size must be between 10 and 200
The substitution for min and max works, but how can I do this for the field value?
With BeanValidation 1.0 I think there is a way to get the value using a message interpolater. I believe with the hibernate implementation of bean validation 1.0 this was available as part of their bundle.
With BeanValidation 1.1 this became available via EL expressions. The field value is now accessible via the name validatedValue. If you could try to use the latest version. Your message would look like this:
name.size=The name '${validatedValue}' is invalid, its size must be between {min} and {max}

Bad injection of maven properties in spring application context

I am trying to set up an activeMQ broker and apply it the following policyEntry:
<policyEntry
queue="${broker.destination.queue.prefix}>"
gcInactiveDestinations="${broker.destination.purge.inactives}"
inactiveTimoutBeforeGC="${broker.destination.inactive.max.time}">
</policyEntry>
The variables points to an jms.properties with next entries:
broker.destination.purge.inactives = true
broker.destination.inactive.max.time = ${maven.jms.broker.destination.inactive.max.time}
Because of I have diferent profiles, last property point to the following property in POM file:
<maven.jms.broker.destination.inactive.max.time>30000</maven.jms.broker.destination.inactive.max.time>
With this context, I am having a problem with the policy entry because:
gcInactiveDestinations: the broker expects a long value but it is being interpreted as Integer (I have tried with 30000L and 30000l and not work).
inactiveTimeoutBeforeGC: must be interpreted as boolean but it has been interpreted as string.
How can I manage this situation?
Thanks!

Resources