Spring Throws NoSuchMethodError Exception - maven

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.

Related

Spring Initializr pane is blank in IntellJ, for both New Project and New Module

In Intellij, the Spring initializr option is available, but the pane where the options for adding dependencies reside is blank. I tried upgrading my IDE to no avail. This is true when either creating a new project or a new module. This was not an issue until my work issued me a PowerMac (was on Windows before).
When I try to access Initializr, idea.log shows the following stacktrace:
2019-02-12 13:52:16,116 [7322253] ERROR - plication.impl.ApplicationImpl - java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1488)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3018)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:489)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at com.intellij.util.io.HttpRequests.openConnection(HttpRequests.java:609)
at com.intellij.util.io.HttpRequests.access$300(HttpRequests.java:59)
at com.intellij.util.io.HttpRequests$RequestImpl.getConnection(HttpRequests.java:378)
at com.intellij.util.io.HttpRequests$RequestImpl.getInputStream(HttpRequests.java:387)
at com.intellij.util.io.HttpRequests$RequestImpl.getReader(HttpRequests.java:405)
at com.intellij.spring.boot.initializr.SpringInitializrOptionsLoader$1.process(SpringInitializrOptionsLoader.java:104)
at com.intellij.spring.boot.initializr.SpringInitializrOptionsLoader$1.process(SpringInitializrOptionsLoader.java:97)
at com.intellij.util.io.HttpRequests.doProcess(HttpRequests.java:523)
at com.intellij.util.io.HttpRequests.process(HttpRequests.java:499)
at com.intellij.util.io.HttpRequests.access$100(HttpRequests.java:59)
at com.intellij.util.io.HttpRequests$RequestBuilderImpl.connect(HttpRequests.java:352)
at com.intellij.spring.boot.initializr.SpringInitializrOptionsLoader.loadOptions(SpringInitializrOptionsLoader.java:97)
at com.intellij.spring.boot.initializr.SpringInitializrApplicationInfoStep.lambda$loadSpringInitializrOptions$3(SpringInitializrApplicationInfoStep.java:151)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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.NullPointerException
at com.sun.security.ntlm.Client.type3(Client.java:161)
at sun.net.www.protocol.http.ntlm.NTLMAuthentication.buildType3Msg(NTLMAuthentication.java:241)
at sun.net.www.protocol.http.ntlm.NTLMAuthentication.setHeaders(NTLMAuthentication.java:216)
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2096)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
... 20 more
How can I fix this?
It looks like a Java bug specific to your NTLM proxy.
It may help if you use IntelliJ IDEA 2019.1 EAP version with JetBrains Runtime 11 version where this issue should be fixed.

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

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>

"NoClassDefFoundError: GenericApplicationListener" when switching from Spring Boot 1.3.0M1 to 1.3.0M2

In my Spring Starter created Soring Boot application I switched from Spring Boot 1.3.0M1 to 1.3.0M2. When trying to start the application (either from STS 3.7.0 or via spring-boot:run at the command line) I get the following exception:
java.lang.reflect.InvocationTargetException
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:497)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:435)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.logging.ClasspathLoggingApplicationListener
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:385)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:362)
at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:231)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:206)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:971)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:960)
at com.daimler.daivb.services.application.dummyservice.DummyServiceApplication.main(DummyServiceApplication.java:18)
... 6 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:378)
... 12 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 25 more
The mentioned class has been added in spring-context version 4.2.0 but when looking at the dependency tree I can see that Spring Boot 1.3.0M2 still depends on spring-context 4.1.6:
[INFO] com.company.services.application:dummyservice:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.3.0.M2:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.3.0.M2:compile
[INFO] | | \- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.M2:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.15:compile
Spring Boot manages a bunch of dependencies for you and allows you to add them without specifying the version. Spring Boot is obviously based on Spring Framework and uses the latest and greatest so you should avoid at all cost to fix the spring framework version to use yourself.
If you have upgraded to a newer version (to include a bug fix or something) make sure to remove the override before you upgrade Spring Boot as the new version it requires may be incompatible with your override.
If you are using other projects that also provide a dependency management on Spring Framework (such as Spring Cloud) make sure that the dependency management of Spring Boot takes precedence. With Maven, make sure to add the spring-boot-dependencies BOM as the first entry in the <dependenciesManagement> section.
I had the same problem because my POM had a properties section with a <spring.version> tag copied from another project.
Remove any <abc.version> tag in your properties section that may conflict with Spring Boot libraries.
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener
From the above error, application is unable to find the class defined from the jar dependencies. GenericApplicationListener is added from spring version 4.2.
Upgrade your Spring version to 4.2 and recheck.

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.

java.lang.VerifyError in struts2

I have developed a strut2-spring-hibernate web application.Build is successful but while deploying in tomcat I am getting the following error:
Caused by: java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBl
obType overrides final method getReturnedClass.()Ljava/lang/Class;
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.7.0_09]
at java.lang.ClassLoader.defineClass(ClassLoader.java:791) ~[na:1.7.0_09]
Please help....
It happens when you have multiple versions of jars added in your maven dependency(mismatch of jar versions),
*Caused by: java.lang.VerifyError: class * so check your maven dependency.
for spring you can find all the dependencies here
for hibernate you can find all the dependencies here
for struts you can find all the dependencies here

Resources