I am upgrading an application to Spring Boot 2.1.3 (from 1.5.x), and I am facing an issue at startup time. Below block can't be bound properly :
spring:
zipkin:
enabled: true
base-url: http://myZipkinServer
sender:
type: web
I am getting this error :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.zipkin.sender.type' to org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties$SenderType:
Property: spring.zipkin.sender.type
Value: web
Origin: class path resource [application.yml]:68:13
Reason: 0
Action:
Update your application's configuration
A bit before I am getting a WARN log announcing the issue :
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.zipkin.sender-org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties': Could not bind properties to 'ZipkinSenderProperties' : prefix=spring.zipkin.sender, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.zipkin.sender.type' to org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties$SenderType
I am trying to follow in debug, and I end up pretty deep in Spring Boot internals
in org.springframework.boot.context.properties.bind.Binder .
I have a similar app with more or less same version for which it works just fine. I am trying to find a difference, compare the execution flows, but not finding anything obvious.
In IntelliJ, I get the auto-completion so I know my yaml is formatted properly : the "web" value is proposed to me.
Any idea of how to investigate this kind of issue ?
Alright, so after a few hours struggling, I made some progress, and now the app starts - even though the root cause of the issue is not fully clear to me at this time.
Below are my findings :
one strange thing I noticed : if I change the sender.type from web to rabbit, then the application starts with no error.
I also found this Spring Boot issue report, very similar to mine, that was pointing at a JDK bug. And indeed, upgrading from jdk1.8.0_25 to jdk1.8.0_201 .
Finally, I also found that if I was using jdk1.8.0_25 and wasn't providing the sender.type at all, then the app was also starting with no issue.
For some reason, in the other app that I have and that works, I am able to use jdk1.8.0_25 and sender.type: web
If anyone has a methodology to figure out this kind of issue quickly, don't hesitate to add it in the comment or edit this answer.
Related
I have been working with Spring for 8 years now, and very often I run into this exception.
BeanCreationException: Error creating bean with name
For example, I am working on a service right now that fails to start because a Bean requires a connection to Azure (on AMQP port) to be successful. The stack trace says nothing about the cause of the error though. Enabling com.azure.core or org.apache.http logging DEBUG also not helping.
Is it possible to intercept the Bean instantiation to reveal more information about the cause of the error? Is there a Spring coding pattern for this kind of thing?
Would love to solve this once and for all so that users of services I create are never confused about a Bean loading exception.
This page elaborates on the issue: https://www.baeldung.com/spring-beancreationexception but never tells you what to do when dealing with Beans being loaded from a 3rd party lib rather than your own code.
We are modernizing one of our applications and we decided to use Spring Boot together with Apache Camel.
One of the configuration files from old version has something like this:
<camel:threadPoolProfile id="myThreadPoolProfile"
poolSize="10" maxPoolSize="20" maxQueueSize="1000" rejectedPolicy="DiscardOldest" />
What I saw in camel documentation on this link is that there is possibility to configure basically the same thing we have in old version. But then I got stuck on id field. It's missing, but there is property camel.threadpool.config which explanation sounds something I need (Adds a configuration for a specific thread pool profile (inherits default values)), but so far I am struggling to make a use of it. I tried something like this:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config:
id: "myThreadPoolProfile"
I am getting following error:
Description:
Failed to bind properties under 'camel.threadpool.config.id' to org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties:
Reason: No converter found capable of converting from type [java.lang.String] to type [org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties]
I guess I don't understand how this spring boot configuration works.
Ok I found an answer, or better to say example here. So the syntax for what I was trying to do would be following:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config[myThreadPoolProfile]:
id: "myThreadPoolProfile"
If you carefully notice the error you are trying to map String to Properties(Map).
See below there is no such property available in configuration map hence its failing.
I have also checked in detail with latest javadoc for the same class. You can refer the same to check what all fields are available.
https://javadoc.io/doc/org.apache.camel.springboot/camel-spring-boot/latest/org/apache/camel/spring/boot/threadpool/CamelThreadPoolConfigurationProperties.ThreadPoolProfileConfigurationProperties.html
Below are the available properties in spring boot camel starter.
https://camel.apache.org/camel-spring-boot/latest/spring-boot.html
I have a Spring-Boot application, which exposes some of its Interfaces to other projects. The basic process of this has been tried and tested within the project structure very often, so this SHOULD not be a "simple" RMI issue like missing serialization or incorrect registry.
This project (coded on java7) and an older project (also java7) are to be deployed in a wildfly 10.x container.
Basically, it is planned that our old application talks to the Spring-Boot application to get specific data sets. When starting the application, the beans are instantiated correctly, and the basic connection seems to be okay. However, when using an entirely valid call, I get this:
ERROR [io.undertow.request] (default task-5) UT005023: Exception handling request to /servlet/Foo: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/omg/CORBA/COMM_FAILURE
I tried debugging the application, and when using the offending method call, the remote class is being triggered and does its work normally, the return value is as expected and is being returned to the spring context.
The weird thing is this part of the Stack Trace:
java.lang.NoClassDefFoundError: org/omg/CORBA/COMM_FAILURE
at org.springframework.remoting.rmi.RmiClientInterceptorUtils.isCorbaConnectFailure(RmiClientInterceptorUtils.java:229)
at org.springframework.remoting.rmi.RmiClientInterceptorUtils.isConnectFailure(RmiClientInterceptorUtils.java:213)
at org.springframework.remoting.rmi.RmiClientInterceptor.isConnectFailure(RmiClientInterceptor.java:282)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:347)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:259)
because when I try to access RmiClientInterceptorUtils.java:229, Eclipse tells me that 229 is not a valid line number. This would lead me to believe that there is a versioning difference in Spring webMVC between server and client. This persisted, even after changing the version number (now using 3.2.8.RELEASE of spring-webmvc), the errors persisted.
I checked if there might be a dependency problem, but CONN_FAILURE is part of rt.jar and should, as far as I know, be present in every java project. Further testing revealed that:
Checked Exceptions are transferred normally
primitive values (like boolean) are transferred correctly
complex Objects cause the exception to be thrown
I'd appreciate any help with this matter, as I am at a loss to explain or correct this.
Thanks.
NOTE:
The general reason for the raised exception has been found - a class was missing the Serializable interface. This does, however, not answer the question why the COMM_FAILURE raised a NoClassDefFoundError, which is something I still would like to know.
Does anyone used this Jersey SSE feature already in a Dropwizard application? I tried it with DW 0.9.1 but all I get is this Exception at startup:
[main]: /:?:?- unavailable
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public org.glassfish.jersey.media.sse.EventOutput .......
Authentication and Authorization is also done like here with SecurityContext. I tried also a very simple no authentication/authorization app and there is the same problem. Perhaps I have to register SSE, but I dont know how if this solves my problem, because Jersey documentation says that there is a automated registering since version 2.8.x.
What i tried, but does not help:
environment.jersey().register(SseFeature.class);
environment.jersey().getResourceConfig().register(SseFeature.class);
System.out.println("sse feature:" + environment.jersey().getResourceConfig().getConfiguration().isRegistered(SseFeature.class));
Output:
...
sse feature:true
WARN [2015-11-11 10:12:58,845] [main]: org.glassfish.jersey.internal.Errors:?:?- The following warnings have been detected: WARNING: Cannot create new registration for component type class org.glassfish.jersey.media.sse.SseFeature: Existing previous registration found for the type.
...
Does anyone know how to solve this problem or have any ideas?
This is a really strange problem. Dont know why it works now. Perhaps if others have the same problem, I have done this:
environment.jersey().register(new EventOutputMesssageBodyWriter());
The MsgBodyWriter does no write (writeTo method is empty), but it works. Really strange ...
I'm getting the following exception when starting a Tomcat instance with my web app after upgrading to Hibernate 3.5.0:
org.hibernate.annotations.common.AssertionFailure: Fail to process type argument in a generic declaration. Type: class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
at org.hibernate.ejb.metamodel.AttributeFactory$PluralAttributeMetadataImpl.getClassFromGenericArgument(AttributeFactory.java:836)
at org.hibernate.ejb.metamodel.AttributeFactory$PluralAttributeMetadataImpl.getClassFromGenericArgument(AttributeFactory.java:833)
at org.hibernate.ejb.metamodel.AttributeFactory$PluralAttributeMetadataImpl.<init>(AttributeFactory.java:748)
at org.hibernate.ejb.metamodel.AttributeFactory$PluralAttributeMetadataImpl.<init>(AttributeFactory.java:723)
at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:518)
at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:93)
As this happens on Tomcat startup, I have no idea where to look in my code to prevent that :-(
Putting that error message into google would have shown you any number of explanations, including this JIRA issue:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5098