Found 2 files with the path - migration liquibase from 3.7.0 to 4.15.0 - spring-boot

I am migrating a spring boot app from 2.1.8.RELEASE to 2.7.7.
I am getting a liquibase error when running integrations tests with h2.
Caused by: java.io.IOException: Found 2 files with the path '../sqlFiles/file_name.sql'
- file:/C:/yy/yy/target/test-classes/config/liquibase/sqlFiles/file_name.sql
- file:/C:/yy/yy/target/classes/config/liquibase/sqlFiles/file_name.sql
I tried spring.liquibase.duplicateFileMode=WARN >>> does not work.
Liquibase-maven-plugin is excluded from test context, but I still get this error ?

Related

Spring boot - Unsupported config data location 'optional:file:./config/*/'

We are migrating a spring boot application from 2.2.4 to 2.4.3
The application can be run with inbuilt tomcat / Tomcat war deployment.
Environment: Windows Azul Java 11 (Zulu 11) and Tomcat 9.0.33
If I run the code with my Netbeans linked tomcat, it works fine.
If I deploy the generated war directly in the same standalone tomcat, it throws the following error.
SEVERE [main] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [D:\apache-tomcat-9.0.33-without port - rest.war]
java.lang.IllegalStateException: Error starting child
................................................................
................................................................
Caused by: org.springframework.boot.context.config.UnsupportedConfigDataLocationException: Unsupported config data location 'optional:file:./config/*/'
at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:110)
On reading through the Spring document, it was mentioned that By default, Spring Boot includes config/*/ in the default search locations. Ref: https://docs.spring.io/spring-boot/docs/2.4.0-SNAPSHOT/reference/htmlsingle/#boot-features-external-config-files-wildcards
I further debugged with spring boot source and spring core source and identified that there is a mismatch in the classloader that happens that was the cause of this exception.
SpringFactoriesLoader is the class that gets loaded by ParallelWebAppClassLoader in NB linked tomcat and by URLClassLoader in standalone tomcat.
Ref: Line No 129 at https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java#L129
The cache at Line 136 has the config classes loaded by ParallelWebAppClassLoader, but not by the URLlassLoader. So the 2 resolvers - ConfigTreeConfigDataLocationResolver, StandardConfigDataLocationResolver in boot v2.4.3 are not getting identified when it tries to retrieve with the key URLlassLoader (Line 136).
Not sure whether this is an issue with Springboot / SpringCore / Tomcat / any new configuration to be added as a part of our upgrade.
Note: Our application.properties has spring.servlet.multipart related properties only.
"./" is not getting resolved in standalone tomcat.
Try using classpath:application.properties , or classpath:config/* -- this would require props inside war.
or absolute path of file:/var/myapp/config/*. Since tomcat is in D:, you may create a folder d:/var/myapp/config/.
Note that within spring you can ignore "d:" and just mention "/var/myapp/config/*", so, in-case tomcat is in "x:" your code need not change.
This was an issue in Spring boot.
Updating to version 2.4.6 will solve this issue.

Error occurred during initialization of boot layer java.lang.module.FindException: Module jdk.management.agent not found

I am setting up my first Spring Boot application using Eclipse > New > Spring-Starter project
The project files are appearing and compiling.
I am even able to RunAs > Java project with console output.
On choosing RunAs > Spring Boot, I am getting the above error in the console:
Error occurred during initialization of boot layer java.lang.module.FindException: Module jdk.management.agent not found
My Java version is Java15, and I have also verified the same path is being used by Eclipse in About Eclispse > Installation Details > Configuration which shows
-vm C:\Program Files\Java\jdk-15.0.1\bin\server\jvm.dll
Running java --list-modules shows the management.agent module in the list shown in the command line output:
jdk.localedata#15.0.1
jdk.management#15.0.1
jdk.management.agent#15.0.1
jdk.management.jfr#15.0.1
Maven version installed is 3.3.6
I am not sure what I am missing. Any ideas?

java.lang.NoClassDefFoundError: org.springframework.context.support.ClassPathXmlApplicationContext

What I am trying to achieve is to upload Temenos T24 Design Studio web services on Axis2.
Unfortunately, I am getting a Class not found error when uploading the service using "aar" (Axis2 archive) file.
I have already deployed Axis2 1.4.4 on IBM Websphere 9.
Note : There has been certain conflicts while deploying Axis2 application on IBM websphere JAX-WS, which I have used this guide to resolve them;
https://www-01.ibm.com/support/docview.wss?uid=swg21315686
Below is the error I am getting;
=================================
This Web axisService has deployment faults
Error: java.lang.NoClassDefFoundError: org.springframework.context.support.ClassPathXmlApplicationContext at com.temenos.services.designstudioinstaller.DesignStudioInstallerServiceSpringContext.loadServiceContext(DesignStudioInstallerServiceSpringContext.java:27)
You have to remove the following jar files from the t24lib directory:
t24-EB_ResourceProviderService-ejb.jar
t24-EB_ResourceProviderService-ProxyAdaptor.jar
t24-EB_ResourceProviderService-jws.aar
t24-EB_ResourceProviderService-provider.jar
t24-EB_ResourceProviderService-tafj-jws.aar
t24-EB_ResourceProviderService-tafj-provider.jar
For any service component such as EB_ResourceProviderService, only the below jars must be present within the t24lib directory:
EB_ResourceProviderService.jar
t24-EB_ResourceProviderService-Data.jar
t24-EB_ResourceProviderService-t24service.jar
Restart the application server after removing them and the axis2 should deploy successfully.
I had similar error deploying axis2.war inflated with Temenos aar files on JBoss EAP 7.1 and it was solved by removing the duplicated .jar and .aar files in t24lib:
[INFO] The t24-EB_ResourceProviderService-tafj-jws.aar service, which is not valid, caused java.lang.NoClassDefFoundError: org/springframework/context/support/ClassPathXmlApplicationContext
at com.temenos.services.resourceprovider.ResourceProviderServiceSpringContext.loadServiceContext(ResourceProviderServiceSpringContext.java:27)

Springboot Strange Resource Loading Behavior

I'm working on a springboot 1.5.1 application that I'm trying to load a WSDL included in my resources directory in the wsdl directory. Depending on where my application executes I'm getting different results (command line, intellij, cloud foundry) and I can't seem to get all three to work at the same time.
I've tried several ways of locating the resource:
From prior to the migration to springboot we had this (worked in IntelliJ but not java -jar myboot.jar):
this.getClass().getResource("/wsdl/my.wsdl");
I switched it to the typically more correct version and got it to work in IntelliJ and java -jar but not Cloud Foundry:
this.getClass().getClassLoader().getResource("/wsdl/my.wsdl");
I switched it to use the Spring Resource Loader version and it worked in IntelliJ and CloudFoundry but not java -jar:
#Value("classpath:/wsdl/my.wsdl")
private Resource wsdlResource;
wsdlResource.getURL();
On the command line what I've noticed is that it seems to be thinking that BOOT-INF/classes is a JAR file (Note the ! after classes):
Caused by: javax.xml.ws.WebServiceException: Failed to access the WSDL at: jar:file:/C:/dev/redacted/build/libs/redacted.jar!/BOOT-INF/classes!/wsdl/my.wsdl. It failed with:
JAR entry BOOT-INF/classes!/wsdl/my.wsdl not found in C:\dev\redacted\build\libs\redacted.jar.
From looking at IntelliJ's URL, it's referring to the actual source folder which explains why it seems to always work.
What is causing this and how might I universally load these class path resources successfully with springboot?

Jar entry not found by running gradle generated jar

I've downloaded the source code (zip file) from the spring getting started guide: http://spring.io/guides/gs/rest-service/
Building the whole project within the folder "complete" was successful. Also running the generated jar file using Gradle (gradle run) was successful. But when I try to run it manually in the Windows command line with "java -jar build\libs\gs-rest-service-0.1.0.jar" the startup process failed with the following error:
2014-06-25 14:17:22.414 ERROR 6864 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure during classpath scanning; nested exception is java.io.FileNotFoundException: JAR
entry /hello/ not found in D:\gs-rest-service-master\complete\build\libs\gs-rest-service-0.1.0.jar
Apparently spring can not find the folder "hello" even though it is located within the jar (I've checked it with the command "jar -ft").
You don't say which version of Boot you're using, but it sounds like you've hit a recently reported problem in 1.1.2 that's specific to Windows. You can either drop back to 1.1.1 or wait for 1.1.3 which, given the problems with 1.1.2 on Windows, should be available in the not too distant future.

Resources