Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Why my servlet component is in "satisfied" state. Will it affect servlet's working?

Avatar

Avatar
Boost 1
Level 1
sushmapoojitha
Level 1

Likes

2 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Validate 1
Give Back
View profile

Avatar
Boost 1
Level 1
sushmapoojitha
Level 1

Likes

2 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Validate 1
Give Back
View profile
sushmapoojitha
Level 1

16-05-2021

when i am starting my servlet, it is not working and in my friends aem instance it is working. 
When i checked in components in web console, it is in "satisfied" state. Will this affect the working of servlet. What can I do to make the servlet to work?

Thanks in advance!!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

570 likes

Total Posts

687 posts

Correct Reply

197 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

570 likes

Total Posts

687 posts

Correct Reply

197 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

16-05-2021

Hi @sushmapoojitha 

 

It looks like you are using the below service:

 

@Reference

RedisClusterService redisclusterservice;

 

Please ensure the service is in active state. 

 

Also I believe you must have a Impl Class that is implementing this service. So try to use 

 

@Reference

private RedisClusterServiceImpl redisclusterserviceImpl;

 

Update:

I see the "immediate = true" flag is missing in @component annotation. Please add the below line.

 

@Component(immediate = true, service = RedisClusterService.class)

This will make the component active and your servlet will resolve.

 

Hope this helps!

Thanks

sushmapoojitha
Hi @asutosh_jena, i tried but after adding "private RedisClusterServiceImpl redisclusterserviceImpl;", it is showing "unsatisfied" and service "redisclusterservice" is not added in components
asutosh_jena

Hi @sushmapoojitha Can you please post your service and serviceImpl class here? I see the service class is returning null which is why your servlet is not working.

sushmapoojitha

RedisClusterServiceImpl ::

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.api.RBucket;
import org.redisson.config.Config;
import org.redisson.config.ReadMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import.samplevodaidea.core.service.RedisClusterServiceImpl;

@component(service = RedisClusterService.class)
@Designate(ocd = RedisClusterServiceImpl.RedisClusterServerConfig.class)
public class RedisClusterServiceImpl implements RedisClusterService {
private RedisClusterServerConfig redisServerConfig;
private RedissonClient redisson;
public Logger log = LoggerFactory.getLogger(this.getClass());

@ObjectClassDefinition(name = "Redis Cluster Server Config", description = "Redis Cluster Server Config to setup connection")
public static @interface RedisClusterServerConfig {

@AttributeDefinition(name = "Redis server address")
String serverPath() default "http://127.0.0.1:6379";
}

@activate
@MODIFIED
protected void activate(RedisClusterServerConfig redisServerConfig) {
this.redisServerConfig = redisServerConfig;
redisson = getRedisClusteredClient();
log.info("redis client created");
}

@deactivate
protected void Deactivate() {
if (redisson != null) {
//log.debug("Shutting down redis client");
//redisson.shutdown();
}
}

@Override
public RedissonClient getRedisClusteredClient() {
if (!checkRedissonConnection()) {
try {
Config config = new Config();
config.useSingleServer().setAddress(redisServerConfig.serverPath());
log.debug("getRedissonClient :: config :: clusted servers");
redisson = Redisson.create(config);
return redisson;
} catch (Exception e) {
log.error("Exception ", e);
return null;
}finally{
if(redisson == null){
log.debug("#######################################");
log.debug("redis client is not created");
log.debug("#######################################");
}else{
log.debug("======================================");
log.debug("redis client is successfully created");
log.debug("======================================");
}
}
}else{
return redisson;
}
}

@Override
public Boolean sendDataToRedissonCluster(String key, String val) {
try {
log.info("Client created successfully");

if (redisson != null) {
log.info("client :: not null :: ");
RBucket<String> bucket = redisson.getBucket(key);
bucket.set(val);
log.info("sendJsonToRedissonCluster :: done :: " + bucket.get());
} else {
log.info("client :: null :: ");
return false;
}


} catch (Exception e) {
log.error("sendJsonToRedissonCluster: catch " , e);
return false;
}
return true;
}

@Override
public String getDataFromRedissonCluster(String key) {
String getData = "";
try {
log.debug("Client created successfully");

if (redisson != null) {
log.debug("client :: not null :: ");
RBucket<String> bucket = redisson.getBucket(key);
getData = bucket.get();
log.debug("GetJsonToRedissonCluster :: done :: " + bucket.get());

} else {
log.debug("client :: null :: ");
getData ="redis-error";
return getData;
}
} catch (Exception e) {
log.error("GetJsonToRedissonCluster: catch " , e);
getData ="redis-error";
return getData;
}
return getData;
}

@Override
public Boolean deleteDataFromRedissonCluster(String key) {
try {
redisson.getBucket(key).delete();
} catch (Exception e) {
log.error("deleteJsonData: " , e);
return false;
}
return true;
}

@Override
public Boolean checkRedissonConnection() {
if (redisson != null) {
log.info("Redis client is up and running");
return true;
}
log.info("Redis client is down");
return false;
}

}

sushmapoojitha

RedisClusterService::

import org.redisson.api.RedissonClient;
public interface RedisClusterService {
public RedissonClient getRedisClusteredClient();

public Boolean sendDataToRedissonCluster(String key, String val);

public String getDataFromRedissonCluster(String key);

public Boolean deleteDataFromRedissonCluster(String key);

public Boolean checkRedissonConnection();

}

asutosh_jena

Hi @sushmapoojitha 

I see the "immediate = true" flag is missing in @component annotation. Please add the below line.

 

@Component(immediate = true, service = RedisClusterService.class)

This will make the component active and your servlet will resolve.

 

Thanks! 

sushmapoojitha

added it, and status of RedisClusterServiceImpl is showing "failed activation" status with this failure message ::: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/Module at org.redisson.config.Config.(Config.java:105) at org.redisson.Redisson.(Redisson.java:113) at org.redisson.Redisson.create(Redisson.java:152) at com.samplevodaidea.core.service.RedisClusterServiceImpl.getRedisClusteredClient(RedisClusterServiceImpl.java:63) at com.samplevodaidea.core.service.RedisClusterServiceImpl.activate(RedisClusterServiceImpl.java:44) 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.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317) at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) at

asutosh_jena

Hi @sushmapoojitha Now you have a different error with Redisson.java class with com/fasterxml/jackson/databind/Module.

Do you have the dependency for com.fasterxml.jackson?

Can you check if all the codes and references are added in the below classes are correct and there is no other error? Also please check if all bundles are active state.

 

See if you have the below dependency else you need to add it:

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>

 

Answers (2)

Answers (2)

Avatar

Avatar
Boost 1
Level 1
sushmapoojitha
Level 1

Likes

2 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Validate 1
Give Back
View profile

Avatar
Boost 1
Level 1
sushmapoojitha
Level 1

Likes

2 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Validate 1
Give Back
View profile
sushmapoojitha
Level 1

27-05-2021

There was a jar file issue. Added correct jar and it is working fine now.

Thanks everyone!!

Avatar

Avatar
Boost 5
Level 6
Ritesh_M
Level 6

Likes

123 likes

Total Posts

99 posts

Correct Reply

37 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 5
Level 6
Ritesh_M
Level 6

Likes

123 likes

Total Posts

99 posts

Correct Reply

37 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Ritesh_M
Level 6

16-05-2021

 
 

Hi @sushmapoojitha ,

 

Satisfied means all the dependencies/service reference of that component is reachable. Can you just follow below steps

 

1. Disable the servlet from http://localhost:4502/system/console/components.

2. Clear the error.log file.

3. Try activating the servlet again.

4. Check the error log.

 

Also, I notice that the first letter of reference and component annotations should be in upper case, but I assume that would be just typo error while posting.