Skipping because it does not denote a directory - java

Every time I start my Spring Boot application I receive a warning saying Skipping [/opt/xxx/yyy.war] because it does not denote a directory.
Actually I found that error report on Spring Git Hub, but was on JSP application because it was in development mode, and probably solved on Spring Boot 1.3.3 than you could configure it on application properties.
I updated the Spring Boot, made the configuration setting the parameter server.jsp-servlet.init-parameters.development=false, but not solved.
This cause some performance issue on the system, any ideia?

Related

flyway migrations not found with spring boot 3 [resolved]

There is a SQL script V1.0.0_01__Init_from_ddl.sql in /src/main/resources/db/migration which initializes my database.
-> Running Spring Boot 2.7.6, this migration script is completely executed without any error.
-> Running Spring Boot 3.0.0, it says: No migrations found. Are your locations set up correctly?
I have not changed any properties regarding flyway. My database connection (MariaDB 10.6) is fine.
I have tried to rename the file to V1__Init.sql or V1_0_0__Init.sql (any many more tries) without any success.
Any ideas, what is going wrong?
It was a folder problem:
-> My current folder-structure (file-system) of Spring Boot 2.7.6 project:
../src/main/resources/db/migration/
-> My current folder-structure (file-system) of Spring Boot 3.0.0 project:
../src/main/resources/db.migration/
After setting the folder structure of the Spring Boot 3.0.0 project to the one of the Spring Boot 2.7.7 project, it works well, even with Spring Boot 3.0.0 :)
So, the problem, was not a spring boot migration problem, just a path problem.

Invalid logger interface org.hibernate.internal.EntityManagerMessageLogger

I am doing JPA without persistence.xml (without Spring Boot) and instead used the PersistenceUnitInfo to create the entity manager. When running the application from my IDE, there are no errors, but it logs sensitive persistence unit information. I've struggled to disable the logging.
It gets worse, when I run it from the command line, I get the following:
Kindly assist, I've lost quite a few hours to this one.
The issue you encounter is a classloading issue during initialization of your EntityManager on your JBoss application environement.
Disabling the logging will not fix this error, but hide it. Check your deployment classpath, and your JDK version. And verify that all required hibernate libraries are present. You can check which libraries you need on the classpath by looking at the dependencies on a site such as mvnRepository (example: https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core/6.0.2.Final).
Are you using a dependency manager, such as Maven or Gradle?

bean 'spring.sleuth.baggage-keys' already defined

I'm in the midst of upgrading an app from Spring Boot 1.x to Spring Boot 2.x. When I attempted to run an existing (and previously working) unit test, I saw the following output:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'spring.sleuth.baggage-keys', defined in class path resource [org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/sleuth/autoconfig/TraceBaggageConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
My Gradle project uses the following implementation: 'org.springframework.cloud:spring-cloud-sleuth-core:2.2.8.RELEASE'
I tried checking with the Gradle dependencies task to make sure there were no conflicting versions of spring-cloud-sleuth-core and friends. I also looked at this post and this post and they didn't solve my problem.
I need to avoid overriding beans, and I'm currently constrained to Spring Boot 2.4.x for my deploy target.
Check the compatibility matrix, you should use Spring Cloud 2020.0.x aka Ilford (Sleuth 3.x) with Spring Boot 2.4 (or 2.5).
Sleuth 2.2.8 is Spring Cloud Hoxton, it is not compatible with Boot 2.4.

Spring Boot Properties Migrator

I'm trying to run an application(spring boot v1.5.9.0) with dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
and getting this error:
org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/source/ConfigurationPropertySources
this error, apparently, did not occur before. How do I make the migrator work?
Do I have to change the spring-boot version to 2x before running the migrator?
If so, i don't really get the migrator usage.
As its scope is runtime - I have to make the app run before including it - which means I have to solve all the errors without migrator's advice? What do I use it for afterwards?
You've stated that you're running spring boot v1.5.9.0
It doesn't make sense to run the properties migrator with spring boot 1.5.x. Its primary intention is to "assist" in properties migrations that have changed during migration of spring boot 1.x to spring boot 2.x
As for the error, this specific class is available only since spring boot 2.0. See the comment #since in the sourcefile
In your project, application.properties or application.yml is present or not? Spring boot is auto-configuration. I think those properties will be expecting..Also check what are the annotations used in Spring boot main class..Share that Spring boot main class as well..will check

Eclipse does not pass mail properties to Spring Boot after migration

I am migrating my Spring Boot application from version 1.5.7 to 2.0.0 and I noticed that it no longer takes mail properties from ENV variables for some reason.
I am using java.mail.Sender and have the following propeties in my application.properties file:
spring.mail.host=smtp.example.com
spring.mail.username=username
spring.mail.password=password
spring.mail.port=587
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.defaultEncoding=UTF-8
This is there just to mock the mail properties in tests. I am injecting the real ones using the same keys as ENV variables: spring.mail.host=smtp.google.com, etc.
But when I try to send the email, I see that it is still using smtp.example.com. I thought that ENV variables had higher priority than values from application.properties. Did something change? Everything worked fine in Spring Boot 1.5.7.
EDIT:
The following command works so it is definitely some problem with Eclipse:
SPRING_PROFILES_ACTIVE=development SPRING_MAIL_HOST=smtp.gmail.com SPRING_MAIL_USERNAME=xxx SPRING_MAIL_PASSWORD=xxx ./gradlew clean bootRun
What I don't understand is why the exact same configuration works, when I switch back to 1.5.7. It is also strange that when passign env variables via Eclipse run configuration, it works for profile. So some env variables are applied and some not...
I was able to recreate this issue. Created a Spring boot App with 1.5.X and injected Environment variables from Eclipse. Now, when I migrate to 2.X release, the environment variables are not getting injected.
On further analysis, found out this interesting thread
One of the Spring-boot developers made this comment
Hence my conclusion is when we are using 2.X release, there is one of the component within Spring-boot-parent which is making the spring boot maven plugin to fork it and run in a separate JVM. Thus, the environment variable is not getting passed.
That answers the question why profile value is picked-up from the environment section. Profile flag is always passed as an argument irrespective of whether the app runs in the maven JVM or a new one
To confirm this, you can add the config entries to the JVM argument tab like the one below
You will now be able to see the new values passed to spring boot
I don't know much about your configurations, but if the project structure is okay with correct dependencies and the application.properties exit under src/main/resources and your startup class annotated with #SpringBootApplication, it should work fine.
you can test if the application reads your properties file by injecting a variable String with annotation #Value inside any class and log or print it.
#Value("${spring.mail.host}")
private String host;
first Make sure your IDE is running on Java 8 or later version .
With Spring Boot 2.0, many configuration properties were renamed/removed and developers need to update their application.properties/application.yml accordingly. To help you with that, Spring Boot ships a new spring-boot-properties-migrator module. Once added as a dependency to your project, this will not only analyze your application’s environment and print diagnostics at startup, but also temporarily migrate properties at runtime for you. This is a must have during your application migration:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
runtime("org.springframework.boot:spring-boot-properties-migrator")
Note Once you’re done with the migration, please make sure to remove this module from your project’s dependencies.
For more information follow this link
Spring Boot 2.X migration guide

Categories