Expand my Community achievements bar.

SOLVED

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

Avatar

Level 2

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!!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

10 Replies

Avatar

Community Advisor
 
 

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.

 

Avatar

Correct answer by
Community Advisor

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

Avatar

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

Avatar

Community Advisor

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.

Avatar

Level 2

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;
}

}

Avatar

Level 2

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();

}

Avatar

Community Advisor

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! 

Avatar

Level 2

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

Avatar

Community Advisor

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>

 

Avatar

Level 2

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

Thanks everyone!!