Spring Boot app with Spring Data cannot find com.mysema.query.types EntityPath - spring

On July 30, 2015 our Spring Boot application was working fine, but when we tried running it on August 3, 2015 it failed with this error:
13:16:33.981 [org.directoryx.Application.main()] ERROR o.s.boot.SpringApplication
- Application startup failed
java.lang.NoClassDefFoundError: com/mysema/query/types/EntityPath
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_51]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_51]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_51]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:606)
~[spring-core-4.2.0.RC2.jar:4.2.0.RC2]...
We noticed the the Spring Framework had a new release within that time frame. We tried updating our Spring Boot dependency from 1.3.0.M1 to 1.3.0.M2 but that did not fix the issue.
See the full POM for more details.
Any help would be appreciated!

The dependency graph and effective POM in Intellij IDEA shows: Spring 4.2.0.RC2
Setting 4.2.0.RELEASE version explicitly in the properties of the POM seems to resolve the problem:
<properties>
<spring.version>4.2.0.RELEASE</spring.version>
</properties>

Related

java.lang.IllegalStateException: Unable to load config data from 'http://localhost:8888'

I am facing an issue with Spring cloud. The used versions are,
Spring boot version: 2.4.4
Spring cloud version: 2020.0.2
Your input will help me to resolve the microservice startup issue.
I have a spring cloud config server which pick the data from repository and the endpoint
http://localhost:8888/xyz-service/default returning data.
I am trying to read the configuration from microservice which fails to connect to the config server, please refer below error
13:25:09.887 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
*java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:http://localhost:8888*'
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:125)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:112)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:114)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:125)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:114)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:106)
at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:101)
at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93)
at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:81)
at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:119)
at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:230)
at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:217)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:88)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:80)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1510)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
at com.microservice.limitmicroservice.LimitMicroserviceApplication.main(LimitMicroserviceApplication.java:10)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/'
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferencesForFile(StandardConfigDataLocationResolver.java:200)
at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:122)
... 35 common frames omitted
Process finished with exit code 0
I see the person did not answer, I have two different applications. They have the same config and the same POM but one gives me this error.
This is the config for both applications, both uses spring boot version 2.4.4, uses java 11, spring cloud 2020.0.2
spring.cloud.config.enabled=false
spring.jmx.enabled=true
management.endpoints.web.exposure.include=*
but the second one fails with similar the error than above
java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:'
Make sure you have the following dependency in your pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
The main reason for this problem is that spring boot does not know how to read the configuration from (for example) repository on github. To solve this problem, you should check whether the following dependency exists in the corresponding module (versions can be different) :
implementation 'org.springframework.cloud:spring-cloud-starter-config:3.1.5'
Connecting this starter should solve your problem

Spring-Boot-Admin application not starting because of error creating bean with name adminHandlerMapping

I am following this blog to try out a Spring-Boot-Admin application. And when I run the app it fails with the below error:
Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'adminHandlerMapping' defined in class path resource [de/codecentric/boot/admin/server/config/AdminServerWebConfiguration$ServletRestApiConfirguation.class]:
Invocation of init method failed; nested exception is java.lang.StackOverflowError
I look further below and find these below lines:
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_231]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.2.1.RELEASE.jar:2.2.1.RELEASE]
Caused by: java.lang.StackOverflowError: null
at de.codecentric.boot.admin.server.web.servlet.AdminControllerHandlerMapping.withPrefix(AdminControllerHandlerMapping.java:48) ~[spring-boot-admin-server-2.1.0.jar:2.1.0]
at de.codecentric.boot.admin.server.web.servlet.AdminControllerHandlerMapping.registerHandlerMethod(AdminControllerHandlerMapping.java:44) ~[spring-boot-admin-server-2.1.0.jar:2.1.0]
Not sure if there is some circular dependency in the jars. Any idea please?
The comment by #the hand of NOD made me relook into my pom.xml file and the pom.xml file provided in the blog
The problem lies in the version number of the spring-boot-starter-parent. The tutorial uses a version 2.1.0.RELEASE whereas the latest one when you prepare a project from Spring Intializr is 2.2.1.RELEASE
I downgraded to 2.1.0.RELEASE and it worked! With 2.2.1.RELEASE there is some dependency that is going cyclic with spring-boot-admin-starter-server
P.S. It seems that the codecentric team is already working upon it and would release the 2.2.0 compliant version by 22 Nov 2019 (https://github.com/codecentric/spring-boot-admin/milestones)
It works for me upgrade spring-boot-admin-starter-admin to 2.2.4 and using
spring-boot-starter-parent 2.2.8.RELEASE, spring-boot-admin-starter-client 2.1.6 on service's pom

Spring Boot 1.4 to 1.5, unable to deploy

I have a very large and working Spring Boot project that is running OK with Boot 1.4.2. When I try to upgrade to 1.5.3 it works from my IDE (Intellij Idea) but it does not work on deployment. It's a Maven project, so I use the "package" directive to generate a WAR file and I get the error bellow on deployment. From what I can see, it says something is missing on the WAR but I even inspected it and the files are there... Any ideas?
Caused by: java.io.FileNotFoundException: file:(...)/target/ultraip-intranet-2.0-RELEASE.war*/WEB-INF/classes/com/ultraip/intranet/entities (No such file or directory)
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_131]
at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[na:1.8.0_131]
at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[na:1.8.0_131]
at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_131]
at java.util.jar.JarFile.<init>(JarFile.java:103) ~[na:1.8.0_131]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingJarResources(PathMatchingResourcePatternResolver.java:593) ~[spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:475) ~[spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:279) ~[spring-core-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.buildDefaultPersistenceUnitInfo(DefaultPersistenceUnitManager.java:525) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
... 105 common frames omitted
Screenshot of the generated WAR file
http://imgur.com/a/5aORQ
A change was made in Tomcat such that it now uses a * as the separator in war:file: URLs. This broke Spring Framework's resource resolution where the * was incorrectly interpreted as a wildcard.
The problem should have been been fixed in Spring Framework 4.3.8 which is used in Spring Boot 1.5.3 but it appears that you have found a case that wasn't considered. Can you please open a Spring Boot issue with a small sample that reproduces the problem?
You don't see the problem when you package your application as a jar file as that stops Tomcat from producing war:file: URLs for resources.

Spring Throws NoSuchMethodError Exception

When I'm trying to run the below code
#Override
public List<EventDetails> process(int event_status) throws EventDetailDataException {
String sql="select * from MicroServiceEventDetails where event_status=?";
List<EventDetails> EventDetailsList = template.query(sql, new BeanPropertyRowMapper<EventDetails>(EventDetails.class),new Object[] {event_status});
return EventDetailsList;
}
It throws the following exception and here's the error log:-
Apr 02, 2017 6:26:04 AM org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler handleError
SEVERE: Unexpected error occurred in scheduled task.
java.lang.NoSuchMethodError: org.springframework.core.convert.support.DefaultConversionService.getSharedInstance()Lorg/springframework/core/convert/ConversionService;
at org.springframework.jdbc.core.BeanPropertyRowMapper.<init>(BeanPropertyRowMapper.java:91)
at com.syntel.boot.dao.EventProcessDaoImpl.process(EventProcessDaoImpl.java:38)
at com.syntel.boot.services.EventDetailServiceImpl.process(EventDetailServiceImpl.java:73)
at com.syntel.boot.scheduler.microeventschudler.eventExcuter(microeventschudler.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Maybe maven dependencies would be the reason i'm not sure, help?
I assume you are using Maven/Gradle, any build tool.
I was working on a spring MVC project and added LDAP functionality, however I added the LDAP jar dependency on the top of the dependency list in pom.xml and the jar version I used, utilized a lower version of spring core which did not have the ConversionService class. I identified this by back tracking to what was the most recent change to the Spring jar versions I made(i.e. added ldap libs) and using the Maven - Dependency hierarchy tab to identify what had changed. Once I removed the new dependency. did a clean, install, add the dependencies to the bottom of the list. The issue was fixed.
Your resolved dependencies should have the highest spring core version referenced on the column on the left. Any lower version should be omitted. In the screenshot, notice that spring core 4.3.9 is omitted for 4.3.4. Avoid this by adding the dependencies that use lower spring core versions below those which use higher versions.

Spring Boot Using No Longer Supported Version Of BouncyCastle (through CrashHub)

Spring boot is using an older version of CrashHub (crashub.version in POM) that uses an old version of bouncycastle that using the class PemReader. This conflicts with the latest version of bouncycastle I am using in my application. Can you update Spring Boot or is there a work around I can do. Right now I get the exception below when I try to ssh into my application:
java.lang.NoClassDefFoundError: org/bouncycastle/openssl/PEMReader
at org.crsh.ssh.term.URLKeyPairProvider.loadKeys(URLKeyPairProvider.java:54)
at org.apache.sshd.common.keyprovider.AbstractKeyPairProvider.getKeyTypes(AbstractKeyPairProvider.java:53)
at org.apache.sshd.server.session.ServerSession.sendKexInit(ServerSession.java:127)
at org.apache.sshd.server.session.ServerSession.<init>(ServerSession.java:60)
at org.apache.sshd.server.session.SessionFactory.doCreateSession(SessionFactory.java:43)
at org.apache.sshd.common.session.AbstractSessionFactory.createSession(AbstractSessionFactory.java:38)
at org.apache.sshd.common.AbstractSessionIoHandler.sessionCreated(AbstractSessionIoHandler.java:36)
at org.apache.sshd.common.io.nio2.Nio2Acceptor$AcceptCompletionHandler.completed(Nio2Acceptor.java:128)
at org.apache.sshd.common.io.nio2.Nio2Acceptor$AcceptCompletionHandler.completed(Nio2Acceptor.java:109)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.openssl.PEMReader
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:170)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:136)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 15 common frames omitted
1.3.0 is the latest version of Crashub and that's the version that Spring Boot supports so there's nothing that can be done on the Spring Boot side of things. Assuming that you don't want to downgrade your Bouncycastle dependency, your only easy choice is to stop using Crashub.
A more involved alternative would be to fork Crashub and make the changes necessary for it to work with your desired version of Bouncycastle.

Resources