Grails 1.2.1 with Spring 3.0.0 dependency problem under Jetty - spring

Just moved to Grails 1.2.1 (used 1.1.1 before). Changed application.properties, ran grails upgrade, fixed BuildConfig and Bootstrap - everything works just fine from grails console.
However, getting a problem when deploy packaged war under jetty 6.1.22:
1581 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.setParameterNameDiscoverer(Lorg/springframework/core/ParameterNameDiscoverer;)V
My project is built with maven2. I researched the war dependencies and see that both spring 2.5.6 and 3.0.0.RELEASE are used there.
I then tried to suppress use of spring 2.5.6 and got a problem with Acegi plugin (using version 0.5.1):
2010-03-10 21:06:56.440:WARN::Nested in org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
Any help would be greatly appreciated.

The problem is caused by the fact that in new version of Spring
ConfigurableWebApplicationContext is located in spring-web.jar, but the interface it inherits ConfigurableApplicationContext, which contains setId(String) method is in located in spring-context.jar.
If you have a library which has been compiled against older version of spring-context it will fail with NoMethodFound exception.
The solution is to locate and recompile that library against latest Spring version.
If you are using Spring version below 3.0 you could try to put full Spring bundle Jar instead of separate packages.

Related

Module was compiled with an incompatible version of Kotlin error after upgrading spring_cloud.version to 2021.0.0

I am attempting to update the spring cloud dependency from spring_cloud.version=2020.0.3
to spring_cloud.version=2021.0.0.
This causes an error when running the gradle build due to the following error
> Task :dispute-visa:compileKotlin FAILED
e: /Users/my.name/.gradle/caches/modules-2/files-2.1/org.springframework.cloud/spring-cloud-function-context/3.2.1/3b1b11733424ba90bd0b030a924e6b7deb2ff845/spring-cloud-function-context-3.2.1.jar!/META-INF/spring-cloud-function-context.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.
/Users/my.name/.gradle/caches/modules-2/files-2.1/org.springframework.cloud/spring-cloud-function-context/3.2.1/3b1b11733424ba90bd0b030a924e6b7deb2ff845/spring-cloud-function-context-3.2.1.jar!/META-INF/spring-cloud-function-context.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.
The spring cloud dependency is implementation("org.springframework.cloud:spring-cloud-stream-binder-kafka")
If this spring cloud dependency is removed then the build works.
If the spring cloud dependency is replaced with another spring cloud dependency then the build will fail with a similar error.
These are the relevent versions of other parts
kotlin.version=1.5.32
spring_boot.version=2.5.6
I have tried changing kotlin version and spring boot version with no effect.
Any help appreciated!

javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode() Ljavax/persistence/SharedCacheMode;

I have persistence-api-1.0.2,hibernate-jpa-2.0-api-1.0.1.Final and other related jars in the lib directory. However, when I am deploying war file, I am getting the following error
nested exception is java.lang.NoSuchMethodError:
javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()
Ljavax/persistence/SharedCacheMode;
How can I resolve this issue?
Update
Jars in lib folder
Why would you have JPA API 1.0 (which is what persistence-api-1.0.2 is) and JPA API 2.0 (hibernate-jpa-2.0-api) in the CLASSPATH at the same time??
Decide which version of JPA you are using before you do anything else

Unit tests print exception after upgrading liquibase to 3.2.2

I have a spring boot/liquibase app and after upgrading liquibase to 3.2.2 unit tests starts to print this exception, but tests still pass:
[WARN] liquibase - Error initializing SpringLiquibase
java.io.FileNotFoundException: ServletContext resource [/] cannot be resolved to URL because it does not exist
at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:156) ~[spring-web-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.init(SpringLiquibase.java:74) [liquibase-core-3.2.2.jar:na]
at liquibase.resource.AbstractResourceAccessor.(AbstractResourceAccessor.java:19) [liquibase-core-3.2.2.jar:na]
at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.(SpringLiquibase.java:64) [liquibase-core-3.2.2.jar:na]
at liquibase.integration.spring.SpringLiquibase.createResourceOpener(SpringLiquibase.java:388) [liquibase-core-3.2.2.jar:na]
at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:349) [liquibase-core-3.2.2.jar:na]
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:300) [liquibase-core-3.2.2.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1613) [spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550) [spring-beans-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at ...
Spring Boot doesn't support Liquibase 3.2.2 at the moment. I haven't seen the exact error that you've posted in the question, but I suspect it's another symptom of the incompatibilities between Liquibase 3.0.x and 3.2.x.
To be safe, you should stick with Liquibase 3.0.x for now, although I believe that 3.1.x may work as well.
There's an open Spring Boot issue describing some of the problems with 3.2.x. There's also an open Spring Boot pull request that provides compatibility with Liquibase 3.2.x. It's scheduled for inclusion in Spring Boot 1.2 which is due for release in Novemeber.

EnvironmentCapable Not available Spring 3.2.3

Am trying to integrate Spring 3.2.3 with JSF 2.2.1 and getting an error like Caused by: java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable The class is available in my classpath (spring-core-3.2.3.RELEASE.jar) but not sure why this error occurs.
It worked fine when I removed the project from the server, clean/build and restarted again. Thanks.

grails 2.3 java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument

When i run my grails application in tomcat i get the following error
java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument. But the batik-svg-dom.1.7.jar is packaged in the war and in the classpath.
I don't however get this error when i am running the application in debug mode in STS.
I am using Grails 2.3 and building my war using maven. I am using FOP and have excluded the "xml-apis".
I have tried to place the batik-svg-dom.jar in the lib folder of tomcat, that did not work.
Thanks in advance.

Resources