2
votes

I am having a problem with @Cacheable and using a custom key based on Spring expression language. I have the following code

@Cacheable(value = "myCache", key = "#providerDTO.identifier")
ClientVO loadClientVOByProviderDTO(ProviderDTO providerDTO);

This is throwing the following error

org.springframework.expression.spel.SpelEvaluation Exception: EL1007Epos 0): Field or property 'identifier' cannot be found on null

The providerDTO argument is not null, I have verified this many times. The docs say that this should work so I am very confused. The docs give the following example

@Cacheable(value="books", key="#isbn.rawNumber")

I have also tried with a static method. This throws a NullPointerException because the providerDTO is null here.

public static String cacheKey(ProviderDTO providerDTO)                                                                                                                                                                                                                    
{                                                                                                                                                                                                                                                                         
    return providerDTO.identifier + "-" + providerDTO.clientID + "-" + providerDTO.clubID;                                                                                                                                                                            
}

How can I debug this to find out what is happening? This is Spring 3.2.4-RELEASE. The @Cacheable tag is on an interface, but I am using standard spring AOP and not AspectJ so as far as I understand this should still work fine.

1
Just for the protocol: Cache is working without custom key generation? You tagged the concrete implementation and not the interface?micfra

1 Answers

0
votes

Possible duplicate of SpelEvaluationException: EL1007E:(pos 43): Field or property 'group' cannot be found on null and spring @Cacheable with Ehcache, spel find null for valid object – I believe you compile without debug information. Please check your Maven configuration; you might want to post the relevant bits here. Search your POM (or parent POM) for the maven-compiler-plugin and a line such as:

<debug>false</debug>