"Ambiguous search mapping detected" thrown after adding Springfox 3.0.0 to SpringBoot - spring-boot

I have a SpringBoot application (spring-boot-starter-parent:2.4.0) and I want to use Swagger. I followed this Baeldung-Tutorial, and I am unfortunately getting this exception on startup:
org.springframework.context.ApplicationContextException: Failed to
start bean 'documentationPluginsBootstrapper'; nested exception is
java.lang.IllegalStateException: Ambiguous search mapping detected.
This is due to the fact that I am in some cases overloading methods in my repositories as follows:
Page<Message> findByConversationId(Long conversationId, Pageable pageable);
List<Message> findByConversationId(Long conversationId);
The exception says that both methods
are mapped to /findByConversationId! Tweak configuration to
get to unambiguous paths!
Is there any way to overcome this issue ?
Thank you !

This is not an answer to your problem but it might help you.
Consider using springdoc instead of Springfox. It is a newer library that is easier to use and way less error-prone than Springfox. We moved to it 2 years ago and we are very glad we did. There is very good documentation and tutorials online for it:
https://springdoc.org/
https://www.baeldung.com/spring-rest-openapi-documentation
It is also very active and you usually get your issues answered very fast on the github page.

Related

stomp-chat web socket with embedded tomcat reactor error - type reactor.tuple.Tuple not found

I am having problems getting web socket subscriptions to work properly using Spring with an embedded Tomcat server.
When running this stomp-chat application I get the following error:
org.springframework.messaging.MessageHandlingException: Expression evaluation failed: #chatRoomSessions[headers.simpDestination].add(T(reactor.tuple.Tuple).of(headers.simpSessionId, headers.simpSubscriptionId));
nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1005E:(pos 58): Type cannot be found 'reactor.tuple.Tuple'
I tried to add the following dependency:
compile ("io.projectreactor:reactor-stream:$reactorVersion")
but it gave the same error. Any help would be appreciated.
OK. I see the problem.
The dependency for the io.projectreactor:reactor-stream:2.0.8 isn't enough.
The Tuple class has been moved to the new reactor.fn.tuple package.
So, you still have to fix all the reactor.tuple.Tuple mentioning in the stomp-server.xml to the new reactor.fn.tuple.Tuple.
The sample will be fixed soon: https://github.com/spring-projects/spring-integration-samples/issues/185
Sorry for inconvenience.

No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema could be loaded

When trying to expose a Service with Aegis databinding in CXF DOSGi I get this error in Java 8. In java 7 it works fine.
Caused by: java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema could be loaded
at javax.xml.validation.SchemaFactory.newInstance(SchemaFactory.java:215)
at org.apache.cxf.aegis.type.XMLTypeCreator.(XMLTypeCreator.java:122)
See full stacktrace here
I think the reason is that the code does not see the impl class com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.
Any ideas how to fix this?
Btw. the exception can be observed by running the CXF-DOSGi build in Java 8.
I still do not have found a real solution for this. For now I have committed a workaround on CXF master to ignore this exception in the static code. So the Aegis binding is not schema checked but at least works. See CXF-6959.
I would be happy about any hints to get this fully working again.

Hibernate Validator 5 on GAE?

Is it possible to run Hibernate Validator 5.x on GAE? I try with 5.2.2.Final and when I run it I get the following exception:
java.lang.NoClassDefFoundError: java.util.ResourceBundle$Control is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.apphosting.runtime.security.shared.stub.java.util.ResourceBundle$Control.<clinit>(ResourceBundle.java)
at org.hibernate.validator.resourceloading.PlatformResourceBundleLocator$AggregateResourceBundle.<clinit>(PlatformResourceBundleLocator.java:169)
at org.hibernate.validator.resourceloading.PlatformResourceBundleLocator.loadBundle(PlatformResourceBundleLocator.java:132)
at org.hibernate.validator.resourceloading.PlatformResourceBundleLocator.getResourceBundle(PlatformResourceBundleLocator.java:105)
at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.interpolateMessage(AbstractMessageInterpolator.java:264)
at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.interpolate(AbstractMessageInterpolator.java:228)
at org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator.interpolate(LocaleContextMessageInterpolator.java:50)
at org.hibernate.validator.internal.engine.ValidationContext.interpolate(ValidationContext.java:422)
at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolation(ValidationContext.java:300)
at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolations(ValidationContext.java:261)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:456)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:127)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:87)
at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:73)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:592)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:555)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:490)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:454)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:406)
at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:204)
at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:108)
at org.springframework.validation.DataBinder.validate(DataBinder.java:866)
This issue has already been fixed in the latest master and the fix will be part of the next Hibernate Validator release. HV-1023 is the issue number in case you want to track it.

Struts 2 Validation w/ annotations getting a null exception

We're trying to use Struts 2 Validation w/ Annotations and we've ran into a weird problem. We have a method that we have specified a string validation for. When we run that method we get a NullException in the AnnotationValidationConfigurationBuilder on line 580. We took a look and it appears that the validationFactory is null. We traced that back and can't find a reason why it would be null though we did notice an #Inject annotation on the setValidatorFactory.
As a side note we're also using Spring 2 in the mix and calling it from the jQuery plugin.
Has anyone run into this before? We've looked at all the docs and none of them talk about needing to register a bean with Spring or anything like that.
Thanks,
Shane
We found the answer. Apparently if you have a validators.xml you need to specify everything in the base validators.xml. This has changed since we used this in the past without needing to do this.

Tapestry5 : No service implements the interface org.springframework.context.ApplicationContext

I'm using the Tapestry5 tapx template library to send an html email, as per this example.
When I run the example I get the following error:
Caused by: java.lang.RuntimeException: No service implements the interface org.springframework.context.ApplicationContext.
at org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:560)
at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:44)
All the tapestry-* jars, including tapestry-spring-5.1.05.jar are in my classpath.
Any clues as to what I'm missing?
Figured it out. SpringIOC loads all modules it find on the classpath. The SpringModule, in tapestry-spring.jar, attempts to initialise the ApplicactionContext service, which causes the problem.
Removing tapestry-spring.jar from the classpath fixes the problem.
Follow the directions on the web site carefully; my guess is that you are not using the special TapestrySpringFilter (instead of the normal TapestryFilter).
It's been a while since I looked at this code; I can't remember if the ApplicationContext is exposed as a service or injectable object. Seems like it should be.
Fair enough; not sure what you situation is, but you should look in more detail at what TapestrySpringFilter does in terms of set up and replicate it into your standalone app's startup. There's some special bootstrapping magic that you will want to leverage.

Resources