org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class not found on server start - spring

Getting the below error when trying to start config server after upgrade to spring-boot version 2.6.6 and spring-cloud version 2021.0.2. These are defined in parent pom.
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.deloitte.insurcloud.microservices.config.ConfigServiceApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:610)
at org.springframework.context.annotation.ConfigurationClassParser.access$800(ConfigurationClassParser.java:111)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:812)
at java.util.ArrayList.forEach(ArrayList.java:1259)
Tried so many things like nearest version upgrade and downgrade. There is no explicit reference to ServerPropertiesAutoConfiguration in code checked after running dependency tree.

Related

javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String No such method

I am getting below exception while executing springboot application:
Caused by: java.lang.NoSuchMethodError: 'javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;
at org.hibernate.validator.internal.xml.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63) ~[hibernate-validator-6.0.7.Final.jar!/:6.0.7.Final]'
I included validation-api as a dependency with latest version & also made sure no other version is coming (not using hibernate validator as well) Still it is failing. Please suggest any solution.
Check the lib folder to differing version of validation-api -- for example
jakarta.validation-api-2.0.2.jar
validation-api-1.1.0.Final.jar
And try to see if you can remove validation-api-1.1.0.Final.jar

Grails 3 (Gradle) dependency without parent directory

Can I not use the following Gradle approach to dependencies in Grails? I do not have nor want a parent directory;
https://stackoverflow.com/a/19303545/2288004
When I try it, I get the the following error;
Caused by: java.lang.IllegalStateException: Expected method not found:
java.lang.NoSuchMethodException:
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.addApplicationListener(org.apache.catalina.deploy.ApplicationListener)
It works when I use a parent directory for the settings.gradle, but unfortunately it’s not how I want to structure the project.
The following was indeed the solution I was looking for,
include ":myplugin"
project(':myplugin').projectDir = new File(settingsDir, '../myplugin')
The error was down to how I was managing my tomcat dependencies between the two projects.
Tomcat was already being pulled in via the plugin but while I still needed to reference tomcat at compile time in the application, I also needed to make sure it was the same version, and so added the following just above "dependencies" to target the version I required;
ext['tomcat.version'] = '7.0.70'

I got ClassNotFoundException when i tried to switch spring to use load time weaving

I've added a <context:load-time-weaver/> in my application context. And i've added necessary libraries and javaagent to my pom.xml
Then i got following error
2014-05-23T17:48:11.549+0600 SEVERE Unable to find class 'com.myproject.dao.impl.BlobDataDaoTest$' in repository
java.lang.ClassNotFoundException: com.myproject.dao.impl.BlobDataDaoTest$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:485)
at org.aspectj.weaver.World.resolve(World.java:326)
How can i resolve it?
Obviously the weaver cannot find at least some of your application classes. This must be a class-loading issue. Maybe your aop.xml is not in the right location or configured in a wrong way - hard to tell with so little information.
There are external dependencies in my tests. They imported because in my tests i mock its. This Unable to find class errors all about this external classes.
2014-05-27T14:26:37.517+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
...
2014-05-27T14:26:37.517+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
...
2014-05-27T14:26:37.516+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
It was resolved when i've updated aspectj version from 1.6.12 to 1.8

Unable to invoke 'hadoop jar' command for class, which contains Spring persistance unit

The problem is that, the jar file uses Spring ORM for loading the persistance configurations, and based on these configurations, files are moved to suitable folders in HDFS. Now If i use, 'java -cp' instead of 'hadoop jar', it fails to copy to HDFS, with FileSystem error.
While invoking the jar with hadoop jar command (having spring orm injected) the exception is as:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'
defined in class path resource [applicationContext.xml
Error creating bean with name 'entityManagerFactory' defined in class
path resource [applicationContext.xml]: Invocation of init method
failed; nested exception is java.lang.IllegalStateException:
Conflicting persistence unit definitions for name 'Persistance':
file:/home/user/Desktop/ABC/apnJar.jar,
file:/tmp/hadoop-ABC/hadoop-unjar2841422106164401019/
Caused by: java.lang.IllegalStateException: Conflicting persistence
unit definitions for name 'Persistance'
Seems like Hadoop is unpacking the jar file to some tmp folder, is this really required?
Can we skip this step by any configuration change?
Any thoughts on this are welcome.
If you use "hadoop jar", hadoop will run org.apache.hadoop.util.RunJar. RunJar will unpackage your jar into a temp folder(In your case is /tmp/hadoop-ABC/hadoop-unjar2841422106164401019/) and load it in the current class loader. At last, it will invoke your main class to run your MapReduce application.
Did you add your jar in the CLASSPATH? If so, you will have your jar and the unpackaged folder in the class loader. I think that's why spring complains it.
As a work around, I extracted the configuration xmls from the jar, and placed them in the working directory.
This worked, however looking for the proper solution.
Hence If you are facing the similar issue, remove all configuration xmls and place the jar with only the compiled class files.

Groovy Spring Bean Classpath

I am attempting to run a groovy script on startup for a web application. I am first trying to follow an example from the book Spring Recipes.
I have a SimpleInterestCalculator in the following package - com.apress.springrecipes.interest
The beans package is in src/test/resources in a package com.wer.com, and that's where the bean is.
My entry in that is
<lang:groovy id="interestCalculator" script-source="classpath:com/apress/springrecipes/interest/SimpleInterestCalculator.groovy">
<lang:property name="rateCalculator" value="rateCalculator" />
</lang:groovy>
I am getting the following error.
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'simpleInterestCalculator':
Could not determine scripted object type for GroovyScriptFactory:
script source locator [classpath:src/com/apress/springrecipes/interest/SimpleInterestCalculator.groovy];
nested exception is java.io.FileNotFoundException:
class path resource [src/com/apress/springrecipes/interest/SimpleInterestCalculator.groovy] cannot be opened because it does not exist
The error you are getting is a FileNotFoundException. This means it is not finding the script file itself. If the file is present, then it may not be on the classpath at runtime.
Check your bin/out directory in your IDE to see if the .groovy file is present there. Sometimes if you have a .groovy in a source directory, your IDE assumes this is 'source' code and compiles it down to bytecode. The result is you would end up with a .class file on the classpath instead of the groovy script itself. This will vary with settings and what IDE you are using. If this seems to be the problem there may be an option for this or you can use an alternate extension that will not be picked up by the compiler.

Resources