java.lang.VerifyError in struts2 - spring

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

Related

Grails Project Suddenly Missing Dependencies

I use multiple grails projects for various reporting and API related tasks. Yesterday when trying to build my projects I started getting various errors related to missing dependencies. I made no code changes to prompt these missing dependencies, some of which are coming from other packages that have been in use for years in my projects without ever complaining of these missing dependencies. Here is a sample of some of such errors:
C:\Users\Public\Grails3\fitment-app\grails-app\controllers\com\gammapowersports\FitmentProductController.groovy: 11: unable to resolve class org.apache.commons.io.FileUtils
And another:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class grails.plugin.springsecurity.rest.JwtService
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 23 common frames omitted
Caused by: org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class grails.plugin.springsecurity.rest.JwtService
at grails.core.ArtefactHandlerAdapter.isArtefact(ArtefactHandlerAdapter.java:129)
at grails.core.DefaultGrailsApplication.addOverridableArtefact(DefaultGrailsApplication.java:772)
at org.grails.plugins.AbstractGrailsPluginManager.registerProvidedArtefacts(AbstractGrailsPluginManager.java:310)
at grails.boot.config.GrailsApplicationPostProcessor.performGrailsInitializationSequence(GrailsApplicationPostProcessor.groovy:110)
at grails.boot.config.GrailsApplicationPostProcessor.initializeGrailsApplication(GrailsApplicationPostProcessor.groovy:93)
at grails.boot.config.GrailsApplicationPostProcessor.setApplicationContext(GrailsApplicationPostProcessor.groovy:225)
at grails.boot.config.GrailsApplicationPostProcessor.<init>(GrailsApplicationPostProcessor.groovy:77)
at grails.boot.config.GrailsAutoConfiguration.grailsApplicationPostProcessor(GrailsAutoConfiguration.groovy:69)
at com.gammapowersports.Application.grailsApplicationPostProcessor(Application.groovy)
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.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 24 common frames omitted
I can solve these errors by adding dependencies to satisfy the dependencies specifically, which I have done to get my projects building again.
My question is why did these dependencies suddenly start failing? I'm wondering if it is related to the migration away from Bintray as the main plugin provider for Grails. Has anyone else experienced these issues?
The most COMMON issue is just that you need to refresh your dependencies. Run this command:
./gradlew clean;./gradlew build --stacktrace --refresh-dependencies
This should give clean your cache and refresh your dependencies.
For the record, bintray has said they will continue to maintain all the old repos/archives but they will not acept any new ones.

Transitive dependency missing in development mode

In a simple REST service built with Quarkus, a ClassNotFoundException is thrown if the service is run in development mode. With the uber-jar, it works correctly.
How can I get the service working in development mode too?
The missing class belongs to a transitive dependency of a QR bill generator library, which is declared build.gradle:
dependencies {
...
implementation 'net.codecrete.qrbill:qrbill-generator:2.2.2'
...
}
The error occurs in development mode (gradle quarkusDev) only. It is triggered if a REST request would need to use the qrbill:qrbill-generator library:
2020-05-03 12:11:49,463 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /xxx/yyy failed, error id: 89c5b7f8-c762-4f7f-959b-67f16b2bc120-1: org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError: io/nayuki/qrcodegen/QrCode$Ecc
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:216)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:515)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:259)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:160)
[several lines omitted]
Caused by: java.lang.NoClassDefFoundError: io/nayuki/qrcodegen/QrCode$Ecc
at net.codecrete.qrbill.generator.QRCode.draw(QRCode.java:49)
at net.codecrete.qrbill.generator.BillLayout.drawPaymentPart(BillLayout.java:131)
at net.codecrete.qrbill.generator.BillLayout.draw(BillLayout.java:94)
[several lines omitted]
Caused by: java.lang.ClassNotFoundException: io.nayuki.qrcodegen.QrCode$Ecc
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:341)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:294)
... 44 more
When analyzing the dependencies, I can see that io.nayuki:qrcodegen:1.6.0 is part of the runtimeClasspath but not part of the compileClasspath. This looks ok.
Could it be that Quarkus dev mode uses the wrong classpath?

Spring boot run error

The project spring boot 1..5.7 release. I am using Intellij IDEA 2017.2.4 and gradle for dependency management. When i build the project it builds successfully with no error. When I run the application with bootRun gradle task it shows the following error.
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392)
at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:378)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:291)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.kifiya.lmanagement.LmanagementApplication.main(LmanagementApplication.java:13)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105)
at org.springframework.boot.context.event.EventPublishingRunListener.(EventPublishingRunListener.java:56)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 7 more
It seems like a dependency problem within Spring, as it's mentioned above. The easiest way IMHO is to check your POM file.
Check out here for more info: https://docs.gradle.org/current/userguide/introduction_dependency_management.html
It looks like spring-aop doesn't match the rest of your libraries. Try running gradle dependencies and check that all Spring dependencies are in the same version. More on inspecting dependencies in Gradle User Manual.
Old question, but I had the same error after converting a Spring application to Spring Boot. Using the spring-boot-starter-aop instead of a direct dependency on a specific version of spring-aop resolved it for me, e.g. in build.gradle:
plugins {
id 'org.springframework.boot' version '1.5.17.RELEASE'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-aop'
}
instead of
dependencies {
compile 'org.springframework:spring-aop:4.2.4.RELEASE'
}

Spring Boot Thin Jar, How To?

I want to use thin jar created by Spring Boot Maven Plugin (jarname.jar.original). I got all dependencies in lib directory. Tried to run. But it is giving following exception related to Banner. I tried to switch it off using spring.main.banner_mode=off. Why it is so obscure information about Spring boot thin jar ? I did not find any useful by googling.
java -cp 'target/thin-jar-0.1.0.jar:target/lib/*' com.example.cloudpayables.api.Application
Exception in thread "restartedMain" 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.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.showBanner(Z)Lorg/springframework/boot/builder/SpringApplicationBuilder;
I would recommend looking at the maven-dependency-plugin to make sure you are capturing all the required dependencies for your project. What I am guessing is missing is some transitive dependency.
http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html
Josh Long will be very sad that the banner isn't showing and is causing the problem in your situation. :)

Maven jars classes conflicts

We are using maven in our project, we are facing some issue with
jars
Issue is :
We have ss_css2 jar and cssparser jar in project. Those two are being
used in different functionality.
The problem is those two jars have same class with same package
com.steadystate.css.parser.CSSOMParser
Because of that we are getting conflicts. The place where it actually
needs to get CSSOMParser class from cssparser instead it is
resolving class in ss_css2 jar because of that am getting below
exception
com.steadystate.css.parser.CSSOMParser.<init>(Lorg/w3c/css/sac/Parser;)V
java.lang.NoSuchMethodError:
com.steadystate.css.parser.CSSOMParser.<init>(Lorg/w3c/css/sac/Parser;)V
at
com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.parseCSS(CSSStyleSheet.java:882)
at
com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.<init>(CSSStyleSheet.java:193)
at
com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.loadStylesheet(CSSStyleSheet.java:341)
at
com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement.getSheet(HTMLLinkElement.java:152)
at
com.gargoylesoftware.htmlunit.javascript.host.css.StyleSheetList.item(StyleSheetList.java:167)
at
com.gargoylesoftware.htmlunit.javascript.host.Window.getComputedStyle(Window.java:1687)
at
com.gargoylesoftware.htmlunit.html.DomNode.isDisplayed(DomNode.java:749)
at
com.gargoylesoftware.htmlunit.html.HtmlElement.isDisplayed(HtmlElement.java:1319)
at
org.openqa.selenium.htmlunit.HtmlUnitWebElement.isDisplayed(HtmlUnitWebElement.java:490)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement$1.call(
If we remove that ss_css2 jar other functionality getting failed,
getting below exception while doing text to pdf convertion
ERROR core.JobRunShell:211 - Job
com.scraper.ScheduledAgentLauncher.ScheduledAgent_DMSAgentProcessor_8
threw an unhandled Exception:
org.springframework.scheduling.quartz.JobMethodInvocationFailedException:
Invocation of method 'run' on target class [class
com.highradius.dms.scheduler.DMSAgentScheduledAction] failed; nested
exception is java.lang.NoClassDefFoundError:
com/steadystate/css/parser/SACParser at
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:273)
at
org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
Caused by: java.lang.NoClassDefFoundError:
com/steadystate/css/parser/SACParser at
org.zefer.html.doc.css.d.<init>(Unknown Source) at
org.zefer.html.doc.css.c.<init>(Unknown Source) at
org.zefer.html.doc.css.c.<init>(Unknown Source)
Please suggest what is the best approach to solve this.
you may use maven-dependency-plugin and configure the include/exclude parameters to include or exclude classes.
See Unpacking specific artifacts
hope this helps.

Resources