私はエンタープライズ統合パターンを使用して Spring Integration プロジェクトに取り組んでおり、MQ メッセージを消費し、何らかの処理を行ってから、それらを別のキューに書き込みます。
私の問題はこれと非常に似ているように見えますが、受け入れられた回答では解決されませんでした。
外部 Web サービスからの応答を受信した後、私の@Cacheable
@Component
クラスは本文をArrayList
. 次のエラーが表示されます。
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Property or field 'valid' cannot be found on object of type 'java.util.ArrayList' - maybe not public?
これが、私が信じている問題のあるクラスです。
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.curator.x.discovery.ServiceCache;
import org.apache.curator.x.discovery.ServiceInstance;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@Component
public class DirectoryRepo {
@Autowired
private CacheManager cacheManager;
@Autowired
private ServiceCache<ServiceDetail> directoryServiceCache;
@Autowired
private RestTemplate restTemplate;
private ArrayList<X> response;
private static final Logger logger = LogManager.getLogger();
@Cacheable(value = "X", unless = "!#result.valid")
public ArrayList<X> checkForX(String a,
String b, String c, String d) {
try {
//code omitted
HttpHeaders headers = new HttpHeaders();
headers.add("token", service.getPayload().getToken());
ResponseEntity<X[]> responseEntity = restTemplate
.exchange(request, HttpMethod.GET, new HttpEntity<>(
headers), X[].class);
if (responseEntity != null && responseEntity.hasBody()) {
response = new ArrayList<X>(Arrays.asList(responseEntity.getBody()));
return response;
} else {
logger.debug("received unexpected responseEntity: {}",
responseEntity);
}
} catch (RestClientException e) {
logger.error("failed to get X - {}",
e.getMessage(), e);
}
throw new ServiceException(
"failed to get X - Directory service unavailable");
}
public ArrayList<X> getResponse() {
return this.response;
}
/**
* Clears out all entries from the X cache.
*/
@CacheEvict(value = "X", allEntries = true)
public void clearXCache() {
logger.trace("cacheManager:{}", cacheManager);
}
}
ご覧のとおり、パブリック getter メソッドを設定しようとしましたが、例外が引き続き発生します。
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 1): Property or field 'valid' cannot be found on object of type 'java.util.ArrayList' - maybe not public
?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE
]
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4
.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:170) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:47) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:36) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) ~[spring-expression-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.ExpressionEvaluator.unless(ExpressionEvaluator.java:123) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.canPutToCache(CacheAspectSupport.java:623) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELE
ASE]
at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:675) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:361) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:302) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at somepackage.DirectoryRepo$$EnhancerBySpringCGLIB$$f7709589.checkForX(<generated>) ~[DirectoryRepo.class:?]
at somepackage.DirectoryService.getX(DirectoryService.java:66) ~[DirectoryService.class:?]
context.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="appName" path="/appName" copyXML="true">
</Context>