Spring boot + ReactiveRedisTemplate StreamReceiver - spring-boot

Am trying to use Spring reactive stream to stream data. When i try to pass nested Object getting below error:
Java-17
Input:
{
"data":{
"start": "1",
"End": "5",
"name": "name",
"hello": {
"id":1
}
}
}
java.lang.reflect.InaccessibleObjectException: Unable to make field transient java.util.LinkedHashMap$Entry java.util.LinkedHashMap.head accessible: module java.base does not "opens java.util" to unnamed module #61f8bee4
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172) ~[na:na]
at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:791) ~[spring-core-5.3.18.jar:5.3.18]
Can someone please help example how to stream Json object using redis stream

Related

How to befriend Spring Boot 2.6.X with Actuator dependency and Swagger Starter 3.0.0

I saw this issue:
Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
Top answer say to put configuration property like that
spring.mvc.pathmatch.matching-strategy: ant-path-matcher And it's working perfectly, but not if you have Actuator dependency.
Is there a way to 'befriend' Spring Boot 2.6.x with Actuator with SpringFox 3.0.0?
Stacktrace:
2022-01-13 09:49:15.745 ERROR 31452 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.13.jar:5.3.13]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.0.jar:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0.jar:2.6.0]
at de.hdl.formstacksalesobjectinserter.FormstackSalesObjectInserterApplication.main(FormstackSalesObjectInserterApplication.java:10) ~[main/:na]
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113) ~[springfox-core-3.0.0.jar:3.0.0]
at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89) ~[springfox-spi-3.0.0.jar:3.0.0]
at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473) ~[na:na]
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) ~[na:na]
at java.base/java.util.TimSort.sort(TimSort.java:234) ~[na:na]
at java.base/java.util.Arrays.sort(Arrays.java:1307) ~[na:na]
at java.base/java.util.ArrayList.sort(ArrayList.java:1721) ~[na:na]
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:392) ~[na:na]
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
I have same question, and get answers from springfox issue. Here's github issue!
Maybe you can try the following two ways first, which I saw from this issue and solved my problem.
you can try add spring.mvc.pathmatch.matching-strategy=ant-path-matcher in your application.properties, or application.yml.
add this bean to your app, note the need to add #Configuration on your config class
#Bean
public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
return new BeanPostProcessor() {
#Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
}
return bean;
}
private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
List<T> copy = mappings.stream()
.filter(mapping -> mapping.getPatternParser() == null)
.collect(Collectors.toList());
mappings.clear();
mappings.addAll(copy);
}
#SuppressWarnings("unchecked")
private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
try {
Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
field.setAccessible(true);
return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
};
}
It's true that actuator doesn't work with springfox 2022 spring boot 3.0.1 and
springfox 3.0.0, springfox is using ant_path_matcher which you should configure in the properties file as:
spring.mvc.pathmatch.matching-strategy=ant-path-matcher.
Otherwise when you have actuator in place, try adding the stated bean above, it worked for me. Thanks. Happy coding friends!

Spring is failling to Autowire Azure Storage Blob

I have a Spring Batch that has a writer to an Azure Storage Blob.
I am using this Azure/Spring Dependency:
azure-spring-boot-starter-storage 3.4.0
On my application properties I have:
azure.storage.accountName=myAccount
azure.storage.accountKey=myKey
Then inside my BatchConfig class I autowired the AZ Storage:
#Autowired
private BlobServiceClientBuilder blobServiceClientBuilder;
private final BlobServiceAsyncClient blobServiceAsyncClient = blobServiceClientBuilder.buildAsyncClient();
Now when I start my application, I am getting a NullPointerException because the BlobServiceClientBuilder cannot be instantiated.
Caused by: java.lang.NullPointerException: null
at com.example.dbreader.configuration.BatchConfig.<init>(BatchConfig.java:55) ~[classes/:na]
at com.example.dbreader.configuration.BatchConfig$$EnhancerBySpringCGLIB$$58787751.<init>(<generated>) ~[classes/:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_221]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_221]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_221]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_221]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:212) ~[spring-beans-5.3.5.jar:5.3.5]
What am I doing wrong when autowiring the Azure Blob Bean?
One more thing I am using the Spring Resource to instantiate a blob file:
#Value("blob://{containerName}/" + "#{stepExecutionContext['marketName']}")
private Resource blobFile;
Encountered the same issue . Looks like its a mistake from documentation.
Azure.storage.blob-endpoint property is mandatory for blobClient and optional for fileClient. Add
Azure.storage.blob-endpoint= https://<account-name>.blob.core.windows.net
to resolve the issue
I encountered the same issue. finally I found that the buildClient() method couldn't be put in global or constructor. just put it in the GET/POST method, it'll work. FYR.
#Autowired
private BlobServiceClientBuilder blobServiceClientBuilder;
private BlobServiceClient blobServiceClient;
#GetMapping
public String readBlobFile() throws IOException {
blobServiceClient = blobServiceClientBuilder.buildClient();
AzureStorageResourcePatternResolver storageResourcePatternResolver = new AzureStorageResourcePatternResolver(blobServiceClient);

Elasticsearch error when re-running jhipster project: Error creating bean with name 'userSearchRepository'

After generating jhipster with elasticsearch I imported jdl file below.
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.nokat.gazna",
"nativeLanguage": "en"
},
"jhipsterVersion": "6.4.1",
"applicationType": "monolith",
"baseName": "gazna",
"packageName": "com.nokat.gazna",
"packageFolder": "com/nokat/gazna",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "NWNmMWNiOWM1YTQ2YjczYTkwYTlkODBmNDk5MzczOTA5MGIxNTk1ZGMzNzRjMDNhZTRmMWVkOGZiMWUzMDk5NTQzOGZhYTBlYWY0ZjQ4M2M5YzhjMDYwMmI1NTA1NjQ4M2EzYzE4NDgzZGVmMGE0ZTVlNDY3ZDQzOTU5NDdmMTU=",
"embeddableLaunchScript": false,
"testFrameworks": [],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": true,
"clientPackageManager": "npm",
"nativeLanguage": "en",
"languages": [
"en",
"ru",
"tr"
],
"blueprints": [],
"skipClient": true
}
}
entity Region {
regionName String
}
entity Country {
countryName String
}
// an ignored comment
/** not an ignored comment */
entity Location {
streetAddress String,
postalCode String,
city String,
stateProvince String
}
entity Department {
departmentName String required
}
/**
* Task entity.
* #author The JHipster team.
*/
entity Task {
title String,
description String
}
/**
* The Employee entity.
*/
entity Employee {
/**
* The firstname attribute.
*/
firstName String,
lastName String,
email String,
phoneNumber String,
hireDate Instant,
salary Long,
commissionPct Long
}
entity Job {
jobTitle String,
minSalary Long,
maxSalary Long
}
entity JobHistory {
startDate Instant,
endDate Instant,
language Language
}
enum Language {
FRENCH, ENGLISH, SPANISH
}
relationship OneToOne {
Country{region} to Region
}
relationship OneToOne {
Location{country} to Country
}
relationship OneToOne {
Department{location} to Location
}
relationship ManyToMany {
Job{task(title)} to Task{job}
}
// defining multiple OneToMany relationships with comments
relationship OneToMany {
Employee{job} to Job,
/**
* A relationship
*/
Department{employee} to
/**
* Another side of the same relationship
*/
Employee
}
relationship ManyToOne {
Employee{manager} to Employee
}
// defining multiple oneToOne relationships
relationship OneToOne {
JobHistory{job} to Job,
JobHistory{department} to Department,
JobHistory{employee} to Employee
}
// Set pagination options
paginate JobHistory, Employee with infinite-scroll
paginate Job with pagination
// Use Data Transfert Objects (DTO)
// dto * with mapstruct
// Set service options to all except few
service all with serviceImpl except Employee, Job
// Set an angular suffix
// angularSuffix * with mySuffix
First time it runs without error. But when I re-run the project I get an error.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService' defined in file [D:\Projects\JHipster\Gazna\backend\target\classes\com\nokat\gazna\service\UserService.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception; nested exception is com.github.vanroy.springdata.jest.exception.JestElasticsearchException: Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"}],"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"} , message : null
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:218)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:847)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at com.nokat.gazna.GaznaApp.main(GaznaApp.java:63)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception; nested exception is com.github.vanroy.springdata.jest.exception.JestElasticsearchException: Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"}],"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"} , message : null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1255)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1175)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
... 22 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception; nested exception is com.github.vanroy.springdata.jest.exception.JestElasticsearchException: Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"}],"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"} , message : null
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.lambda$getTargetRepositoryViaReflection$3(RepositoryFactorySupport.java:513)
at java.base/java.util.Optional.map(Optional.java:265)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepositoryViaReflection(RepositoryFactorySupport.java:513)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepositoryViaReflection(RepositoryFactorySupport.java:498)
at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory.getTargetRepository(ElasticsearchRepositoryFactory.java:74)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:305)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:211)
at org.springframework.data.util.Lazy.get(Lazy.java:94)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300)
at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean.afterPropertiesSet(ElasticsearchRepositoryFactoryBean.java:67)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
... 33 common frames omitted
Caused by: com.github.vanroy.springdata.jest.exception.JestElasticsearchException: Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"}],"type":"resource_already_exists_exception","reason":"index [user/ZZ-RPvKlRHWJnrd50KVGQA] already exists","index_uuid":"ZZ-RPvKlRHWJnrd50KVGQA","index":"user"} , message : null
at com.github.vanroy.springdata.jest.mapper.DefaultErrorMapper.mapError(DefaultErrorMapper.java:30)
at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.execute(JestElasticsearchTemplate.java:1126)
at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.executeWithAcknowledge(JestElasticsearchTemplate.java:1136)
at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndex(JestElasticsearchTemplate.java:197)
at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndexWithSettings(JestElasticsearchTemplate.java:1345)
at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndexIfNotCreated(JestElasticsearchTemplate.java:1330)
at com.github.vanroy.springdata.jest.JestElasticsearchTemplate.createIndex(JestElasticsearchTemplate.java:178)
at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.createIndex(AbstractElasticsearchRepository.java:96)
at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.<init>(AbstractElasticsearchRepository.java:87)
at org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository.<init>(NumberKeyedRepository.java:36)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
... 46 common frames omitted
Process finished with exit code 1
When I delete nodes in target/elasticsearch/data/nodes folder it runs succesfully but when I try to re-run again it fails with same error.
I am new to jhipster and I didn't do any code changes. Could you please help to solve this issue?
Try to run this two commands in your terminal
./mvnw clean
./mvnw

Running Cassandra in Spring Boot

I have installed Cassandra in my windows environment, I run it with cassandra.bat.
Now, I have an Spring Boot application that contains the following cassandra configuration file:
#Configuration
#EnableCassandraRepositories(
basePackages = "org.manuel.cassandra.repositories")
public class CassandraConfig extends AbstractCassandraConfiguration {
#Override
protected String getKeyspaceName() {
return "testKeySpace";
}
#Bean
public CassandraClusterFactoryBean cluster() {
CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
cluster.setContactPoints("127.0.0.1");
cluster.setPort(9142);
return cluster;
}
#Override
protected boolean getMetricsEnabled() { return false; }
#Bean
public CassandraMappingContext cassandraMapping() throws ClassNotFoundException {
return new CassandraMappingContext();
}
}
But I can't run the application because I get this:
Caused by: java.lang.NoClassDefFoundError: com/datastax/driver/core/Session
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 27 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.datastax.driver.core.Session
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
... 31 common frames omitted
These are my cassandra related dependencies:
implementation 'org.springframework.boot:spring-boot-starter-data-cassandra'
implementation 'com.datastax.cassandra:cassandra-driver-core:4.0.0'
implementation 'io.dropwizard.metrics:metrics-jmx:4.1.0'
My application.yml file is empty and I also have declared a repository, but I think the error isn't related to that problem.
The spring-boot-starter-data-cassandra depends on the sprint-data-cassandra that uses Java driver 3.6.0, and you have specified the dependency on the 4.0.0 - this version is not binary compatible with 3.x releases, so you need to correct your dependencies.

Use Spring xd with gemfire-json-server to connect Apache geode. Json can't be parsed

The stream:
stream create --name stocks --definition "http --port=9000 | gemfire-json-server --host=localhost --port=10334 --useLocator=true --regionName=Stocks --keyExpression=payload.getField('symbol')" --deploy
Then Post Data:
http post --target http://localhost:9000 --data {"symbol":"FAKE","price":73}
then it fail:
2016-12-14T09:51:20+0800 1.3.1.RELEASE ERROR pool-15-thread-4
http.NettyHttpInboundChannelAdapter - Error sending message
org.springframework.integration.transformer.MessageTransformationException:
Failed to transform Message; nested exception is
org.springframework.messaging.MessageHandlingException: nested
exception is com.gemstone.gemfire.pdx.JSONFormatterException: Could
not parse JSON document: [Source: {"symbol":"FAKE","price":73}; line:
1, column: 29] at
org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:95)
~[spring-integration-core-4.2.5.RELEASE.jar:na] at
org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
~[spring-integration-core-4.2.5.RELEASE.jar:na] at
org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
~[spring-integration-core-4.2.5.RELEASE.jar:na] ......
Caused by: org.springframework.messaging.MessageHandlingException:
nested exception is com.gemstone.gemfire.pdx.JSONFormatterException:
Could not parse JSON document: [Source: {"symbol":"FAKE","price":73};
line: 1, column: 29] at
org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:96)
~[spring-integration-core-4.2.5.RELEASE.jar:na] at
org.springframework.integration.transformer.AbstractMessageProcessingTransformer.transform(AbstractMessageProcessingTransformer.java:90)
~[spring-integration-core-4.2.5.RELEASE.jar:na] at
org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:89)
~[spring-integration-core-4.2.5.RELEASE.jar:na] ... 51 common frames
omitted Caused by: com.gemstone.gemfire.pdx.JSONFormatterException:
Could not parse JSON document: [Source: {"symbol":"FAKE","price":73};
line: 1, column: 29] at
com.gemstone.gemfire.pdx.JSONFormatter.fromJSON(JSONFormatter.java:62)
~[na:na] at
org.springframework.integration.x.gemfire.JsonStringToObjectTransformer.toObject(JsonStringToObjectTransformer.java:37)
~[na:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) ~[na:1.8.0_25] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_25] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_25] at java.lang.reflect.Method.invoke(Method.java:483)
~[na:1.8.0_25]
......
Caused by: com.gemstone.gemfire.cache.client.ServerOperationException:
java.lang.ClassNotFoundException:
org.apache.geode.pdx.PdxInitializationException at
com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.handleException(OpExecutorImpl.java:686)
~[na:na] at
com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.handleException(OpExecutorImpl.java:613)
~[na:na] at
com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:171)
~[na:na] at
com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:115)
~[na:na] at
com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:696)
~[na:na] at
com.gemstone.gemfire.cache.client.internal.GetPDXIdForTypeOp.execute(GetPDXIdForTypeOp.java:34)
~[na:na] at
com.gemstone.gemfire.pdx.internal.ClientTypeRegistration.defineType(ClientTypeRegistration.java:56)
~[na:na] at
com.gemstone.gemfire.pdx.internal.TypeRegistry.defineType(TypeRegistry.java:179)
~[na:na] at
com.gemstone.gemfire.pdx.internal.TypeRegistry.defineLocalType(TypeRegistry.java:224)
~[na:na] at
com.gemstone.gemfire.pdx.internal.PdxWriterImpl.completeByteStreamGeneration(PdxWriterImpl.java:477)
~[na:na] at
com.gemstone.gemfire.pdx.internal.PdxInstanceFactoryImpl.create(PdxInstanceFactoryImpl.java:53)
~[na:na] at
com.gemstone.gemfire.pdx.internal.json.PdxInstanceHelper.endObjectField(PdxInstanceHelper.java:175)
~[na:na] at
com.gemstone.gemfire.pdx.JSONFormatter.getPdxInstance(JSONFormatter.java:152)
~[na:na] at
com.gemstone.gemfire.pdx.JSONFormatter.fromJSON(JSONFormatter.java:56)
~[na:na] ... 69 common frames omitted Caused by:
java.lang.ClassNotFoundException:
org.apache.geode.pdx.PdxInitializationException at
java.net.URLClassLoader$1.run(URLClassLoader.java:372) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
~[na:1.8.0_25] at java.security.AccessController.doPrivileged(Native
Method) ~[na:1.8.0_25] at
java.net.URLClassLoader.findClass(URLClassLoader.java:360)
~[na:1.8.0_25]
....
springxd Stream created successfully. I think whether i miss some libs? the reason it show the fail : Noclassfound. But i just download the package from the website and change nothing. so I don't know why. May someone can help me. Thanks.
Thanks Procrastinatus Maximus .
Hi everyone I find the problem was caused by the Geode version. The newest
package change the class path from "gemfire" to "geode".
so the problem comes.
what you should do is use the previous version:
I use the v1.0.0-incubating.M2.
Problem solved!

Resources