How to fix MongoTemplate --> MappingMongoConverter --> BeforeConvertCallback --> MongoTemplate circular dependency? - spring-boot

I am trying to create a custom Auditing callback in order to set the corresponding fields of my MongoDB documents.
This is my callback:
#Order(101)
#Component
#RequiredArgsConstructor
public class AuditingCallback implements BeforeConvertCallback<AuditingDocument<String>> {
private final AuditingConfiguration auditingConfiguration;
#Setter
#Autowired
private MongoTemplate mongoTemplate;
/**
* Entity callback method invoked before a domain object is converted to be persisted. Can return either the same or a
* modified instance of the domain object.
*
* #param entity the domain object to save.
* #param collection name of the collection.
* #return the domain object to be persisted.
*/
#Override
public AuditingDocument<String> onBeforeConvert(AuditingDocument<String> entity, String collection) {
System.out.println("Auditing Callback");
System.out.println(entity);
if(this.isNew(entity)){
System.out.println("Is new");
entity.setCreator(this.auditingConfiguration.getCurrentAuditor().orElse(null));
entity.setCreated(Instant.now());
}else{
System.out.println("Is not new");
// TODO
// Retrieve existing creator, created
Class<AuditingDocument<String>> clazz = (Class<AuditingDocument<String>>) entity.getClass();
AuditingDocument<String> existingEntity = this.mongoTemplate.<AuditingDocument<String>>findById(entity.getId(), clazz);
System.out.println("Existing Entity:");
System.out.println(existingEntity);
entity.setModifier(this.auditingConfiguration.getCurrentAuditor().orElse(null));
entity.setModified(Instant.now());
}
return entity;
}
private boolean isNew(AuditingDocument<String> entity){
return StringUtils.isBlank(entity.getId());
}
}
Now I need to find the existing entity from the DB, to keep the existing creator and created fields, hence the MongoTemplate field.
This results in a circular dependency:
┌─────┐
| mongoTemplate defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]
↑ ↓
| mappingMongoConverter defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]
↑ ↓
| auditingCallback (field private org.springframework.data.mongodb.core.MongoOperations org.myproject.configuration.database.auditing.callbacks.AuditingCallback.mongoOperations)
└─────┘
How can I break this circular dependency?
I also tried with MongoOperations but it is the same.
Note that I am already using the
allow-circular-references: true
property.
Is it not possible to load existing entities during MongoDB events callbacks?
Log 2
Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditingCallback': Unsatisfied dependency expressed through field 'mongoTemplate'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mongoTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditingCallback': Unsatisfied dependency expressed through field 'mongoTemplate'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mongoTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditingCallback': Unsatisfied dependency expressed through field 'mongoTemplate'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mongoTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditingCallback': Unsatisfied dependency expressed through field 'mongoTemplate'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mongoTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mongoTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?

Related

Spring Data: Mongo Repository can not be initialized

I'm getting this strange error message when I start my spring boot service:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property storeMpi found for type Patient!
Service can't be started since this exception is raised.
My code is very straight:
public interface PatientRepository
extends MongoRepository<Patient, String>,
QuerydslPredicateExecutor<Patient>,
MPIPatientRepository
{
}
public interface MPIPatientRepository {
Patient storeMpi(Patient patient);
}
You can see, that storeMpi is a method, not an expected field of my Patient entity.
Implementation is straight as well:
#Repository
#RequiredArgsConstructor
public class MPIPatientRepository implements cat.gencat.catsalut.hes.mpi.repository.MPIPatientRepository {
private final MongoTemplate mongoTemplate;
/**
* {#inheritDoc}
*/
#Override
public Patient storeMpi(Patient patient) {
return this.mongoTemplate.save(patient);
}
I don't quite figure out what's wrong.
Formatted root CausedBy is:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ca.uhn.fhir.spring.boot.autoconfigure.FhirAutoConfiguration$FhirRestfulServerConfiguration': Bean instantiation via constructor failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [ca.uhn.fhir.spring.boot.autoconfigure.FhirAutoConfiguration$FhirRestfulServerConfiguration$$EnhancerBySpringCGLIB$$5fe4b535]: Constructor threw exception;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'patientResourceProvider' defined in file [/home/jeusdi/projects/salut/mpi/hes-mpi-fhir-mongodb/target/classes/cat/gencat/catsalut/hes/mpi/providers/PatientResourceProvider.class]: Unsatisfied dependency expressed through constructor parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'patientService' defined in file [/home/jeusdi/projects/salut/mpi/hes-mpi-fhir-mongodb/target/classes/cat/gencat/catsalut/hes/mpi/service/PatientService.class]: Unsatisfied dependency expressed through constructor parameter 2;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'patientRepository' defined in cat.gencat.catsalut.hes.mpi.repository.PatientRepository defined in #EnableMongoRepositories declared on MongoRepositoriesRegistrar.EnableMongoRepositoriesConfiguration: Invocation of init method failed;
nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract cat.gencat.catsalut.hes.mpi.model.Patient cat.gencat.catsalut.hes.mpi.repository.MPIPatientRepository.storeMpi(cat.gencat.catsalut.hes.mpi.model.Patient)! Reason: No property storeMpi found for type Patient!;
nested exception is org.springframework.data.mapping.PropertyReferenceException: No property storeMpi found for type Patient!
Any ideas?

How to resolve FatalBeanException in Spring?

I get the following exception:
org.springframework.beans.FatalBeanException: Context hybris Global Context Factory couldn't be created correctly due to, Error creating bean with name 'modifyPopulatorList$child#0' defined in class path resource [config/cmsfacades-cmsitems-spring.xml]: Initialization of bean failed;
Error creating bean with name 'ordermanagementOrderConverter' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementOrderPopulator' while setting bean property 'populators' with key [0];
Error creating bean with name 'ordermanagementOrderPopulator' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementOrderEntryConverter' while setting bean property 'orderEntryConverter';
Error creating bean with name 'ordermanagementOrderEntryConverter' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementOrderEntryPopulator' while setting bean property 'populators' with key [0];
Error creating bean with name 'warehousingOrderEntryPopulator' defined in class path resource [warehousingfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementProductConverter' while setting bean property 'productConverter';
Error creating bean with name 'ordermanagementProductConverter' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementProductPopulator' while setting bean property 'populators' with key [0];
Error creating bean with name 'ordermanagementProductPopulator' defined in class path resource [ordermanagementfacades-spring.xml]: Error setting property values;
Invalid property 'designerConverter' of bean class [de.hybris.platform.ordermanagementfacades.product.converters.populator.OrdermanagementProductBasicPopulator]: Bean property 'designerConverter' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
This is my bean registration :
<alias name="defaultCustomProductBasicPopulator" alias="productBasicPopulator"/>
<bean id="defaultCustomProductBasicPopulator" parent="defaultProductBasicPopulator"
class="de.hybris.NagAcc.facades.product.converters.populator.CustomProductBasicPopulator">
<property name="designerConverter" ref="designerConverter" />
</bean>
This is the class :
public class CustomProductBasicPopulator<SOURCE extends ProductModel, TARGET extends ProductData> extends ProductBasicPopulator<SOURCE,TARGET> {
private Converter<DesignerModel,DesignerData> designerConverter;
public Converter<DesignerModel, DesignerData> getDesignerConverter() {
return designerConverter;
}
public void setDesignerConverter(Converter<DesignerModel, DesignerData> designerConverter) {
this.designerConverter = designerConverter;
}
#Override
public void populate(SOURCE productModel, TARGET productData) throws ConversionException {
super.populate(productModel, productData);
if (productModel.getDesigner() != null)
{
DesignerData designerData = getDesignerConverter().convert(productModel.getDesigner());
productData.setDesigner(designerData);
}
}
This is the parent bean definition :
<alias name="defaultProductBasicPopulator" alias="productBasicPopulator"/>
<bean id="defaultProductBasicPopulator" parent="baseProductPopulator"
class="de.hybris.platform.commercefacades.product.converters.populator.ProductBasicPopulator">
<property name="productConfigurableChecker" ref="productConfigurableChecker"/>
</bean>
The complete stack trace:
org.springframework.beans.FatalBeanException: Context hybris Global Context Factory couldn't be created correctly due to, Error creating bean with name 'modifyPopulatorList$child#0' defined in class path resource [config/cmsfacades-cmsitems-spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordermanagementOrderConverter' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementOrderPopulator' while setting bean property 'populators' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordermanagementOrderPopulator' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementOrderEntryConverter' while setting bean property 'orderEntryConverter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordermanagementOrderEntryConverter' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementOrderEntryPopulator' while setting bean property 'populators' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'warehousingOrderEntryPopulator' defined in class path resource [warehousingfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementProductConverter' while setting bean property 'productConverter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordermanagementProductConverter' defined in class path resource [ordermanagementfacades-spring.xml]: Cannot resolve reference to bean 'ordermanagementProductPopulator' while setting bean property 'populators' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordermanagementProductPopulator' defined in class path resource [ordermanagementfacades-spring.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'designerConverter' of bean class [de.hybris.platform.ordermanagementfacades.product.converters.populator.OrdermanagementProductBasicPopulator]: Bean property 'designerConverter' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFactory.java:307)
at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.buildSelf(HybrisContextFactory.java:179)
at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.build(HybrisContextFactory.java:165)
at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(HybrisContextHolder.java:122)
at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisContextHolder.java:101)
at de.hybris.platform.core.HybrisContextHolder.getAppCtxFactory(HybrisContextHolder.java:152)
at de.hybris.platform.core.HybrisContextHolder.getApplicationInstance(HybrisContextHolder.java:78)
at de.hybris.platform.core.AbstractTenant.createCoreApplicationContext(AbstractTenant.java:758)
at de.hybris.platform.core.AbstractTenant.doStartupSafe(AbstractTenant.java:799)
... 22 more
According to me all getters and setters are fine, I can not resolve this error. Please help.
I don't have access to hybris sources to have a look (thank god!), but I think it's worth to have a look at the Javadoc of OrdermanagementProductBasicPopulator:
public void populate​(ProductModel productModel, ProductData productData)
Description copied from interface: Populator
Populate the target instance with values from the source instance.
Overrides:
populate in class ProductBasicPopulator
So I guess, the class OrdermanagementProductBasicPopulator extends ProductBasicPopulator but the bean definition of OrdermanagementProductBasicPopulator has your productBasicPopulator as a parent, which means that spring tries to inject the property of your bean definition, which is not a property in the inheritance chain of OrdermanagementProductBasicPopulator.
As mentioned, this is just a guess because I don't see the sources...
If my guess is correct, it depends on your requirements how to get rid of this problem. You can either give your bean a new alias and modify the populator list(s) where necessary or you override the bean alias of OrdermanagementProductBasicPopulator accordingly.
If thats's not the problem, please post the bean definition of OrdermanagementProductBasicPopulator.

Why creating been in Spring occurs with error?

Hello I am creating program which will communicate and send information using channel. When I run program it doesn't work.
Errors:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-05-02 13:47:37.938 ERROR 12584 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helloWorldQueueProducer' defined in file [C:\workspace\target\classes\edu\producer\HelloWorldQueueProducer.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jmsTemplate' defined in class path resource [org/springframework/boot/autoconfigure/jms/JmsAutoConfiguration$JmsTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'jmsTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryConfiguration$SimpleConnectionFactoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jms.connection.CachingConnectionFactory]: Factory method 'cachingJmsConnectionFactory' threw exception; nested exception is java.lang.IllegalStateException: Unable to create ActiveMQConnectionFactory
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.5.jar:5.3.5]
#Component
#RequiredArgsConstructor
public class HelloWorldQueueProducer {
private final JmsTemplate jmsTemplate;
#Scheduled(fixedRate = 2000)
public void sendHello() {
HelloMessage message = HelloMessage.builder()
.id(HelloMessage.nextId())
.createdAt(LocalDateTime.now())
.message("Hello world!")
.build();
jmsTemplate.convertAndSend(JmsConfig.QUEUE_HELLO_WORLD, message);
System.out.println("HelloWorldQueueProducer.sendHello - sent message: " + message);
}
}
Not quite sure about it, but have you defined the necessary properties in your application.properties? You need to set them like this i. e.
spring.artemis.mode=native
spring.artemis.host=localhost
spring.artemis.port=61616
spring.artemis.user=developer
spring.artemis.password=developer
jms.queue.destination=myqueue
Otherwise the autoconfiguration of spring boot wouldn't bootstrap the necessary beans. I had this problem once.

Junit in Spring Boot keeps failing

I have very simple SpringBoot Junit but it keeps failing.
#RunWith(SpringRunner.class)
//#SpringBootTest
#WebMvcTest(TokenServiceImpl.class)
public class TokenTest {
#Test
public void getOauthToken()
{
System.out.println( " done test");
}
my TokenServiceImpl class has
public class TokenServiceImpl implements TokenService{
public String getToken() throws RuntimeException{
return " Token returned" ;
}
I get the below error : -Snippet
2019-11-27 19:12:45.884 WARN 15864 --- [ main]
o.s.w.c.s.GenericWebApplicationContext : Exception encountered
during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'runApplication': Unsatisfied dependency
expressed through field 'job'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'job' defined in class path resource
[com/mycompany/project1/batch/configurations/BatchBDREntityConfig.class]:
Unsatisfied dependency expressed through method 'job' parameter 4;
nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'batchDBWriter': Unsatisfied dependency
expressed through field 'BDREntityRepository'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type
'com.mycompany.project1.batch.repositories.BDREntityRepository'
available: expected at least 1 bean which qualifies as autowire
candidate. Dependency annotations:
{#org.springframework.beans.factory.annotation.Autowired(required=true)}
Field BDREntityRepository in
com.mycompany.project1.batch.services.BatchDBWriter required a bean of
type 'com.mycompany.project1.batch.repositories.BDREntityRepository'
that could not be found.
Consider defining a bean of type
'com.mycompany.project1.batch.repositories.BDREntityRepository' in
your configuration.
Caused by:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'runApplication': Unsatisfied dependency
expressed through field 'job'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'job' defined in class path resource
[com/mycompany/project1/batch/configurations/BatchBDREntityConfig.class]:
Unsatisfied dependency expressed through method 'job' parameter 4;
nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'batchDBWriter': Unsatisfied dependency
expressed through field 'BDREntityRepository'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type
'com.mycompany.project1.batch.repositories.BDREntityRepository'
available: expected at least 1 bean which qualifies as autowire
candidate. Dependency annotations:
{#org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'batchDBWriter': Unsatisfied dependency
expressed through field 'BDREntityRepository'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type
'com.mycompany.project1.batch.repositories.BDREntityRepository'
available: expected at least 1 bean which qualifies as autowire
candidate. Dependency annotations:
{#org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type
'com.mycompany.project1.batch.repositories.BDREntityRepository'
available: expected at least 1 bean which qualifies as autowire
candidate. Dependency annotations:
{#org.springframework.beans.factory.annotation.Autowired(required=true)}
My main method has following
#SpringBootApplication
#ComponentScan(basePackages= {"com.mycompany.project1"})
public class RunApplication{
private static final Logger logger = Logger.getLogger(BatchController.class);
#Autowired
JobLauncher jobLauncher;
#Autowired
Job job;
/*
* jmxBean will get loaded when this managed bean is called from RMI, and it will fire batch execution
*/
public static void main(String[] args){
ApplicationContext app = SpringApplication.run(RunApplication.class, args);
logger.debug("Batch Application has been started...");
BatchController controller = app.getBean(BatchController.class);
//Start batch process when application starts or restart, its optional call and can be commented out
//as we have JMX to expose load method on demand
//BatchController batch = new BatchController();
controller.startBatchProessFromMain();
}
}
#Component
public class BatchDBWriter implements ItemWriter<BDREntity> {
private static final Logger logger = Logger.getLogger(BatchDBWriter.class);
#Autowired
private BDREntityRepository bDREntityRepository;
/*
* this method call the JPArepository's saveAll
* function and saves all the list of bdrEntitiesat a time.
*/
#Override
public void write(List<? extends BDREntity> bdrEntities) throws Exception {
bDREntityRepository.saveAll(bdrEntities);
}
}
How can i fix my Junit ?
You are using #WebMvcTest that is a test-slice annotation. It's specifically intended for testing the WebMvc-related components in your application and is a form of integration test.
You've said in the comments that you're not trying to integration test your application. In that case, you should not be using #SpringBootTest or any of the other #…Test annotations that are provided by Spring Boot.
Assuming that your goal is to unit test TokenServiceImpl, I'd expect your test class to look something like this:
public class TokenTest {
private final TokenServiceImpl tokenService = new TokenServiceImpl();
#Test
public void getOauthToken() {
String token = this.tokenService.getToken();
// Assertions to check the token go here
}
}

grails cdn-asset-pipeline plugin

We are currently using grails cdn-asset-pipeline plugin. For pushing our assets into s3. The cdn-asset-pipeline plugin use loadApp() inside _AssetCdn.groovy. Which causes JNDI issues. The JNDI is available in our production tomcat. When we use grails run-app we are able to run our app without issues. Can you let me know what changes we can do to overcome this issue.
_AssetCdn.groovy:
target(loadConfig: "Load CDN assets config") {
depends(compile, parseArguments)
if (argsMap['help']) {
println USAGE
exit 0
}
loadApp()
configureApp()
initKarman()
providers = []
def cdnAssetsConfig = grailsApp.config.grails.assets?.cdn
providers = cdnAssetsConfig.providers ?: []
if (!providers) {
def providerObject = [:]
providerObject.provider = argsMap['provider'] ?: cdnAssetsConfig?.provider ?: ''
providerObject.directory = argsMap['directory'] ?: cdnAssetsConfig?.directory ?: ''
providerObject.accessKey = argsMap['access-key'] ?: cdnAssetsConfig?.accessKey ?: ''
providerObject.secretKey = argsMap['secret-key'] ?: cdnAssetsConfig?.secretKey ?: ''
providerObject.region = argsMap['region'] ?: cdnAssetsConfig?.region ?: ''
providers << providerObject
}
When we run, the below command before building the war
grails asset-cdn-push --provider=S3 --directory="my directory" --gzip=true --storage-path="storage path" --access-key="access key" --secret-key="secret key"
The Error:
| Error executing script AssetCdnPush: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'transactionManager': Cannot resolve reference to bean 'transactionManager_bonita' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager_bonita': Cannot resolve reference to
bean 'sessionFactory_bonita' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_bonita': Cannot resolve reference to bean 'dataSource_bonita' while setting bean property 'dataSource
'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource_bonita': Cannot resolve reference to bean 'dataSourceLazy_bonita' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSourceLazy_bonita': Cannot resolve reference to bean 'dataSourceUnproxied_bonita' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied_bonita': Invocatio
n of init method failed; nested exception is javax.naming.NameNotFoundException: Name [java:comp/env/bonitaDS] not bound; 2 bindings: [bonitaSequenceManagerDS,bonitaDS]
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied_bonita': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [java:comp/env/bonitaDS] not bound; 2 bindings: [bonitaSequenceManagerDS,
bonitaDS]
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied_bonita': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [java:comp/env/bonitaDS] not bound; 2 bindings: [bonitaSequenceManagerDS,
bonitaDS]
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied_bonita': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [java:comp/env/bonitaDS] not bound; 2 bindings: [bonitaSequenceManagerDS,
bonitaDS] (Use --stacktrace to see the full trace)

Resources